ECF 1.5
AntEvalOp.h
1#ifndef AntEvalOp_h
2#define AntEvalOp_h
3
4
50class AntEvalOp : public EvaluateOp
51{
52 friend ostream& operator<<(ostream& os, AntEvalOp& ant);
53protected:
54 // ant properties
55 uint x_, y_;
56 uint facing_;
57 uint moves_;
58 uint foodEaten_;
59
60 // environments properties
61 std::vector<uint> rowNo;
62 std::vector<uint> columnNo;
63 std::vector<uint> maxSteps;
64 std::vector<uint> foodNo;
65 std::vector<char*> board;
66
67 // temp enviroments properties
68 uint tmpRow;
69 uint tmpColumn;
70 uint tmpMaxSteps;
71 uint tmpFoodNo;
72 uint boardNo;
73 uint boardNo2;
74 char *tmpBoard;
75
76 StateP state_;
77
78 // interactive mode
79 static const char LEFT, RIGHT, UP, DOWN;
80 string currentTree;
81 void showStep(string action);
82
83public:
84 // flags
85 static bool trace;
86 static bool step;
87
88 void registerParameters(StateP);
89 FitnessP evaluate(IndividualP individual);
90 bool initialize(StateP);
91
92 // function set
93 void turnLeft();
94 bool facingFood();
95 void turnRight();
96 void moveAhead();
97
98};
99typedef boost::shared_ptr<AntEvalOp> AntEvalOpP;
100
101#endif
Artificial ant evaluation class (and environment simulator)
Definition: AntEvalOp.h:51
friend ostream & operator<<(ostream &os, AntEvalOp &ant)
Output the current state of the board (show ant movements)
Definition: AntEvalOp.cpp:23
void turnRight()
Turn ant on the right.
Definition: AntEvalOp.cpp:197
void showStep(string action)
Show the ant's current action (interactive)
Definition: AntEvalOp.cpp:277
bool initialize(StateP)
Initialize the simulator, read environments from input file.
Definition: AntEvalOp.cpp:45
static bool step
show the ant's movement interactive step by step (no effect if trace is false!)
Definition: AntEvalOp.h:86
static bool trace
trace the ant's movement in the simulator (for visual output)
Definition: AntEvalOp.h:85
void moveAhead()
Move ant ahead.
Definition: AntEvalOp.cpp:211
void registerParameters(StateP)
Register evaluator parameters. Called before EvaluateOp::initialize method.
Definition: AntEvalOp.cpp:35
FitnessP evaluate(IndividualP individual)
Evaluation function, simulates ant movement and counts the eaten food.
Definition: AntEvalOp.cpp:98
bool facingFood()
Check if there's food in front.
Definition: AntEvalOp.cpp:256
void turnLeft()
Turn ant on the left.
Definition: AntEvalOp.cpp:183
Evaluation base class.
Definition: EvaluateOp.h:17