1 10 package examples.gp.tictactoe; 11 12 import org.jgap.gp.*; 13 import org.jgap.*; 14 import org.jgap.gp.impl.*; 15 16 public class ReadBoard 17 extends CommandGene { 18 19 private final static String CVS_REVISION = "$Revision: 1.2 $"; 20 21 private Board m_board; 22 23 public ReadBoard(final GPConfiguration a_conf, Board a_board) 24 throws InvalidConfigurationException { 25 this(a_conf, a_board, 0, null); 26 } 27 28 public ReadBoard(final GPConfiguration a_conf, Board a_board, 29 int a_subReturnType, int[] a_subChildTypes) 30 throws InvalidConfigurationException { 31 super(a_conf, 2, CommandGene.IntegerClass, a_subReturnType, a_subChildTypes); 32 m_board = a_board; 33 } 34 35 public String toString() { 36 return "read_board(&1, &2)"; 37 } 38 39 45 public String getName() { 46 return "Read Board(x,y)"; 47 } 48 49 public int execute_int(ProgramChromosome c, int n, Object [] args) { 50 check(c); 51 int x = c.execute_int(n, 0, args); 52 int y = c.execute_int(n, 1, args); 53 return m_board.readField(x, y); 56 } 57 } 58 | Popular Tags |