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))
46 XMLNode xInd = XMLNode::parseFile(
"./best.txt",
"Individual");
47 IndividualP ind = (IndividualP)
new Individual(state);
49 std::cout << ind->toString();
51 std::cout <<
"\nBest ant's performance on test trail(s):" << std::endl;
57 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 step
show the ant's movement interactive step by step (no effect if trace is false!)
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.
Individual class - inherits a vector of Genotype objects.
void read(XMLNode &)
read individual from XML node
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.