Print

Print


1. The function of the toString() method is to provide a short,  
typically one word, description of the function.

2. Your eval function is empty -- but this is where you need to  
actually have your function do its work, the work you described in  
toString().
Sean

On Aug 24, 2006, at 9:44 PM, Richard Hague wrote:

> I am using ECJ 15.
> I have designed a GP using ECJ that should create a
> program that controls a soccer agent. I am just unsure
> that I have designed it correctly.
>
> #Below is one of my functions I have used to create my
> move function set:
>
> public class ballfar extends GPNode
> {
>     public String toString() {
>     return " if(ball != null && ball.m_distance > 0.7)
> "
> 	      + "{"
> 		  +	" if( ball.m_direction != 0 )"
> 		  +			" m_krislet.turn(ball.m_direction); "
> 		  +	" else "
> 		  +	   		" m_krislet.dash(10*ball.m_distance); "
> 		  + "justKicked = false;"
> 		  + "}"; }
>
>     public void checkConstraints(final EvolutionState
> state,
>                                  final int tree,
>                                  final GPIndividual
> typicalIndividual,
>                                  final Parameter
> individualBase)
>         {
>
> super.checkConstraints(state,tree,typicalIndividual,individualBase);
>         if (children.length!=2)
>             state.output.error("Incorrect number of
> children for node " +
>                                toStringForError() + "
> at " +
>                                individualBase);
>         }
>
>
>      public void eval(final EvolutionState state,
> 		     final int thread,
> 		     final GPData input,
> 		     final ADFStack stack,
> 		     final GPIndividual individual,
> 		     final Problem problem)
> 	{
> 		
>
> children[0].eval(state,thread,input,stack,individual,problem);
>
> children[1].eval(state,thread,input,stack,individual,problem);
>
> 		
> 	}	
>
>  }
>
> I put the code that the main robot class needs in the
> toString() method because I didn't know if there was
> anyway to print out the code within GPNodes from the
> finished tree of the individual. When the best
> individual is found I copy the tree from the out.stat
> file then play one game of soccer with it. The
> performance of the tree is calculated according to how
> well the soccer agent's play. This performance is used
> to calculate the fitness of the next generation.
>
>  Am I doing this in the correct way??
> Will the GP be able to learn which functions produce a
> program using this method???
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com