Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/app/ant/func/Right.java @ 6152

Last change on this file since 6152 was 6152, checked in by bfarka, 13 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 2.2 KB
Line 
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
8package ec.app.ant.func;
9import ec.*;
10import ec.app.ant.*;
11import ec.gp.*;
12import ec.util.*;
13
14/*
15 * Right.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
27public class Right extends GPNode implements EvalPrint
28    {
29    public String toString() { return "right"; }
30
31    public void checkConstraints(final EvolutionState state,
32        final int tree,
33        final GPIndividual typicalIndividual,
34        final Parameter individualBase)
35        {
36        super.checkConstraints(state,tree,typicalIndividual,individualBase);
37        if (children.length!=0)
38            state.output.error("Incorrect number of children for node " +
39                toStringForError() + " at " +
40                individualBase);
41        }
42
43    public void eval(final EvolutionState state,
44        final int thread,
45        final GPData input,
46        final ADFStack stack,
47        final GPIndividual individual,
48        final Problem problem)
49        {
50        Ant p = (Ant)problem;
51        switch (p.orientation)
52            {
53            case Ant.O_UP:
54                p.orientation = Ant.O_RIGHT;
55                break;
56            case Ant.O_LEFT:
57                p.orientation = Ant.O_UP;
58                break;
59            case Ant.O_DOWN:
60                p.orientation = Ant.O_LEFT;
61                break;
62            case Ant.O_RIGHT:
63                p.orientation = Ant.O_DOWN;
64                break;
65            default:  // whoa!
66                state.output.fatal("Whoa, somehow I got a bad orientation! (" + p.orientation + ")");
67                break;
68            }
69        p.moves++;
70        }
71
72    public void evalPrint(final EvolutionState state,
73        final int thread,
74        final GPData input,
75        final ADFStack stack,
76        final GPIndividual individual,
77        final Problem problem,
78        final int[][] map2)
79        {
80        eval(state,thread,input,stack,individual,problem);
81        }
82    }
83
84
85
Note: See TracBrowser for help on using the repository browser.