6#include "IfFoodAhead.h"
14int main(
int argc,
char **argv)
16 StateP state (
new State);
26 tree->addFunction(ifa);
27 Tree::PrimitiveP prog2 (
new Prog2);
28 tree->addFunction(prog2);
29 Tree::PrimitiveP prog3 (
new Prog3);
30 tree->addFunction(prog3);
32 tree->addTerminal(tl);
34 tree->addTerminal(tr);
36 tree->addTerminal(mv);
39 state->addGenotype(tree);
42 if(!state->initialize(argc, argv))
48 std::vector<IndividualP> hof = state->getHoF()->getBest();
49 IndividualP ind = hof[0];
50 std::cout << ind->toString();
51 std::cout <<
"\nBest ant's performance on learning trail(s):" << std::endl;
60 state->getEvalOp()->evaluate(ind);
64 std::cout <<
"\nBest ant's performance on test trail(s):" << std::endl;
68 state->getRegistry()->modifyEntry(
"learning_trails", state->getRegistry()->getEntry(
"test_trails"));
Artificial ant evaluation class (and environment simulator)
bool initialize(StateP)
Initialize the simulator, read environments from input file.
static bool trace
trace the ant's movement in the simulator (for visual output)
FitnessP evaluate(IndividualP individual)
Evaluation function, simulates ant movement and counts the eaten food.
GP function, checks if the food is ahead.
GP terminal, moves the ant one square ahead.
GP function, executes 2 subtrees in sequence.
GP function, executes 3 subtrees in sequence.
State class - backbone of the framework.
Tree class - implements genotype as a tree.
GP terminal, turns the ant left.
GP terminal, turns the ant right.