• Main Page
  • Modules
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/examples/GPArtificialAnt/IfFoodAhead.h

00001 #include "AntEvalOp.h"
00002 
00003 
00010 class IfFoodAhead : public Tree::Primitives::Primitive
00011 {
00012 public:
00013     IfFoodAhead()
00014     {
00015         nArguments_ = 2;
00016         name_ = "ifa";
00017     }
00018 
00019     void execute(void* evalOp, Tree::Tree& tree)
00020     {
00021         // get pointer to simulator from the context
00022         AntEvalOp* ant = (AntEvalOp*) state_->getContext()->environment;
00023 
00024         // query the simulator: are we facing food?
00025         if(ant->facingFood()) {
00026             // if yes, execute the first subtree
00027             getNextArgument(evalOp, tree);
00028             // and skip the second one
00029             skipNextArgument(tree);
00030         } else {
00031             // otherwise...
00032             skipNextArgument(tree);
00033             getNextArgument(evalOp, tree);
00034         }
00035     }
00036 
00037     ~IfFoodAhead()
00038     {   }
00039 };

Generated on Tue Nov 4 2014 13:04:32 for ECF by  doxygen 1.7.1