1 | /*
|
---|
2 | Copyright 2006 by Sean Luke
|
---|
3 | Licensed under the Academic Free License version 3.0
|
---|
4 | See the file "LICENSE" for more information
|
---|
5 | */
|
---|
6 |
|
---|
7 |
|
---|
8 | package ec.app.lawnmower.func;
|
---|
9 | import ec.*;
|
---|
10 | import ec.app.lawnmower.*;
|
---|
11 | import ec.gp.*;
|
---|
12 | import ec.util.*;
|
---|
13 |
|
---|
14 | /*
|
---|
15 | * V8a.java
|
---|
16 | *
|
---|
17 | * Created: Wed Nov 3 18:26:37 1999
|
---|
18 | * By: Sean Luke
|
---|
19 | */
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * @author Sean Luke
|
---|
23 | * @version 1.0
|
---|
24 | */
|
---|
25 |
|
---|
26 | public class V8a extends GPNode
|
---|
27 | {
|
---|
28 | public final static int MODULO = 8; // odd that it doesn't change with map size
|
---|
29 |
|
---|
30 | public String toString() { return "v8a"; }
|
---|
31 |
|
---|
32 | public void checkConstraints(final EvolutionState state,
|
---|
33 | final int tree,
|
---|
34 | final GPIndividual typicalIndividual,
|
---|
35 | final Parameter individualBase)
|
---|
36 | {
|
---|
37 | super.checkConstraints(state,tree,typicalIndividual,individualBase);
|
---|
38 | if (children.length!=2)
|
---|
39 | state.output.error("Incorrect number of children for node " +
|
---|
40 | toStringForError() + " at " +
|
---|
41 | individualBase);
|
---|
42 | }
|
---|
43 |
|
---|
44 | public void eval(final EvolutionState state,
|
---|
45 | final int thread,
|
---|
46 | final GPData input,
|
---|
47 | final ADFStack stack,
|
---|
48 | final GPIndividual individual,
|
---|
49 | final Problem problem)
|
---|
50 | {
|
---|
51 | int resultx;
|
---|
52 | int resulty;
|
---|
53 |
|
---|
54 | LawnmowerData rd = ((LawnmowerData)(input));
|
---|
55 |
|
---|
56 | children[0].eval(state,thread,input,stack,individual,problem);
|
---|
57 | resultx = rd.x;
|
---|
58 | resulty = rd.y;
|
---|
59 |
|
---|
60 | children[1].eval(state,thread,input,stack,individual,problem);
|
---|
61 | rd.x = (resultx + rd.x) % MODULO;
|
---|
62 | rd.y = (resulty + rd.y) % MODULO;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|