KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > gp > tictactoe > TicTacToeTest


1 package examples.gp.tictactoe;
2
3 import org.jgap.gp.*;
4 import org.jgap.gp.impl.*;
5 import junit.framework.*;
6
7 public class TicTacToeTest
8     extends GPTestCase {
9   /** String containing the CVS revision. Read out via reflection!*/
10   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
11
12   public static Test suite() {
13     TestSuite suite = new TestSuite(TicTacToeTest.class);
14     return suite;
15   }
16
17   public void setUp() {
18     super.setUp();
19   }
20
21   /**
22    * @throws Exception
23    *
24    * @author Klaus Meffert
25    * @since 3.2
26    */

27   public void testConstruct_0()
28       throws Exception JavaDoc {
29     // Player 1
30
GPConfiguration config = new GPConfiguration();
31     config.setGPFitnessEvaluator(new DeltaGPFitnessEvaluator());
32     config.setMaxInitDepth(8);
33     config.setPopulationSize(40);
34     config.setStrictProgramCreation(false);
35     config.setProgramCreationMaxTries(5);
36     config.setMaxCrossoverDepth(12);
37 // INodeValidator validator = new GameNodeValidator();
38
TicTacToeMain game1 = new TicTacToeMain(config);
39     GPGenotype player1 = game1.create(config,1,null,2);
40     // Player 2
41
GPConfiguration config2 = new GPConfiguration();
42     config2.setGPFitnessEvaluator(new DeltaGPFitnessEvaluator());
43     config2.setMaxInitDepth(8);
44     config2.setPopulationSize(40);
45     config2.setStrictProgramCreation(false);
46     config2.setProgramCreationMaxTries(5);
47     config2.setMaxCrossoverDepth(12);
48     TicTacToeMain game2 = new TicTacToeMain(config2);
49     GPGenotype player2 = game2.create(config2,2,null,1);
50     // Preset program of player 1
51
}
52 }
53 /**
54  * for(int x=0;x<2;x++) {
55  * mem0 = 0;
56  * for(int y=0;y<2;y++) {
57  * IfColor(2) {
58  * mem0+1;
59  * }
60  * mem0 = ReadBoard(x,y);
61  *
62  * }
63  * }
64  */

65
Popular Tags