00001
00002 #include <ecf/ECF.h>
00003 #include <utility>
00004 #include "AgentEvalOp.h"
00005 #include "IfWallAhead.h"
00006 #include "IfWallLeft.h"
00007 #include "IfWallRight.h"
00008 #include "IfVisited.h"
00009 #include "MoveFoward.h"
00010 #include "TurnLeft.h"
00011 #include "TurnRight.h"
00012
00013 using namespace std;
00014
00015 int main(int argc, char **argv)
00016 {
00017 StateP state (new State);
00018 int answer = 0;
00019
00020 state->setEvalOp(static_cast<EvaluateOpP> (new AgentEvalOp));
00021
00022 TreeP tree (new Tree::Tree);
00023
00024 Tree::PrimitiveP ifa (new IfWallAhead);
00025 tree->addFunction(ifa);
00026 Tree::PrimitiveP ifl (new IfWallLeft);
00027 tree->addFunction(ifl);
00028 Tree::PrimitiveP ifr (new IfWallRight);
00029 tree->addFunction(ifr);
00030 Tree::PrimitiveP ifv (new IfVisited);
00031 tree->addFunction(ifv);
00032
00033 Tree::PrimitiveP tl (new TurnLeft);
00034 tree->addTerminal(tl);
00035 Tree::PrimitiveP tr (new TurnRight);
00036 tree->addTerminal(tr);
00037 Tree::PrimitiveP mv (new MoveFoward);
00038 tree->addTerminal(mv);
00039
00040 state->addGenotype(tree);
00041
00042 state->initialize(argc, argv);
00043
00044 cout << "Run/evaluate (0/1):";
00045 cin >>answer;
00046
00047 if(!answer)
00048 {
00049 state->run();
00050 }
00051 else {
00052 XMLNode xInd = XMLNode::parseFile("./ind.txt", "Individual");
00053 IndividualP ind = (IndividualP) new Individual(state);
00054 ind->read(xInd);
00055 state->getAlgorithm()->evaluate(ind);
00056 cout << ind->toString();
00057 system("pause");
00058 }
00059
00060 return 0;
00061 }