1 10 package examples.gp.anttrail; 11 12 import org.jgap.*; 13 import org.jgap.gp.*; 14 import org.jgap.gp.impl.*; 15 16 22 public class Right 23 extends AntCommand implements IMutateable { 24 25 private final static String CVS_REVISION = "$Revision: 1.3 $"; 26 27 public Right(final GPConfiguration a_conf) 28 throws InvalidConfigurationException { 29 super(a_conf); 30 } 31 32 public CommandGene applyMutation(int index, double a_percentage) 33 throws InvalidConfigurationException { 34 Left mutant = new Left(getGPConfiguration()); 35 return mutant; 36 } 37 38 public void execute_void(ProgramChromosome a_chrom, int a_n, Object [] a_args) { 39 AntMap map = getMap(a_chrom); 40 int orient = map.getOrientation(); 41 switch (orient) { 42 case AntMap.O_DOWN: 43 orient = AntMap.O_LEFT; 44 break; 45 case AntMap.O_LEFT: 46 orient = AntMap.O_UP; 47 break; 48 case AntMap.O_RIGHT: 49 orient = AntMap.O_DOWN; 50 break; 51 case AntMap.O_UP: 52 orient = AntMap.O_RIGHT; 53 break; 54 } 55 map.setOrientation(orient); 56 map.IncrementMoveCounter(); 57 } 58 59 public String toString() { 60 return "right"; 61 } 62 } 63 | Popular Tags |