00001 #include <ecf/ECF.h>
00002 #include "AntEvalOp.h"
00003 #include "Prog2.h"
00004 #include "Prog3.h"
00005 #include "TurnLeft.h"
00006 #include "IfFoodAhead.h"
00007 #include "TurnRight.h"
00008 #include "MoveAhead.h"
00009 #include <iostream>
00010 #include <fstream>
00011 #include <string.h>
00012
00013
00014 int main(int argc, char **argv)
00015 {
00016 StateP state (new State);
00017
00018
00019 state->setEvalOp(new AntEvalOp);
00020
00021
00022 TreeP tree (new Tree::Tree);
00023
00024
00025 Tree::PrimitiveP ifa (new IfFoodAhead);
00026 tree->addFunction(ifa);
00027 Tree::PrimitiveP prog2 (new Prog2);
00028 tree->addFunction(prog2);
00029 Tree::PrimitiveP prog3 (new Prog3);
00030 tree->addFunction(prog3);
00031 Tree::PrimitiveP tl (new TurnLeft);
00032 tree->addTerminal(tl);
00033 Tree::PrimitiveP tr (new TurnRight);
00034 tree->addTerminal(tr);
00035 Tree::PrimitiveP mv (new MoveAhead);
00036 tree->addTerminal(mv);
00037
00038
00039 state->addGenotype(tree);
00040
00041
00042 if(!state->initialize(argc, argv))
00043 return 1;
00044
00045
00046 XMLNode xInd = XMLNode::parseFile("./best.txt", "Individual");
00047 IndividualP ind = (IndividualP) new Individual(state);
00048 ind->read(xInd);
00049 std::cout << ind->toString();
00050
00051 std::cout << "\nBest ant's performance on test trail(s):" << std::endl;
00052 AntEvalOp* evalOp = new AntEvalOp;
00053 AntEvalOp::trace = 1;
00054 AntEvalOp::step = 1;
00055
00056
00057 state->getRegistry()->modifyEntry("learning_trails", state->getRegistry()->getEntry("test_trails"));
00058 evalOp->initialize(state);
00059 evalOp->evaluate(ind);
00060
00061 return 0;
00062 }