[jgogears commit] r47 - trunk/jgogears/jgogears/engine

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 3, 2008, 9:40:33 PM3/3/08
to jgog...@googlegroups.com
Author: syeates
Date: Mon Mar 3 18:39:42 2008
New Revision: 47

Modified:
trunk/jgogears/jgogears/engine/VertexLineariserTest.java

Log:
more tests, including lenth of linearisation and uniqueness

Modified: trunk/jgogears/jgogears/engine/VertexLineariserTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/VertexLineariserTest.java (original)
+++ trunk/jgogears/jgogears/engine/VertexLineariserTest.java Mon Mar 3
18:39:42 2008
@@ -12,6 +12,8 @@
*/
public class VertexLineariserTest extends TestCase {

+ public static final boolean DEBUG = true;
+
/**
* test what happens when linearising boards of different sizes
*
@@ -135,6 +137,101 @@

}

+ }
+
+ /**
+ * Test trained model.
+ */
+ public void testVerbose() {
+ BoardI board = new Board();
+ assertNotNull(board);
+ board = board.newBoard(new Move("white b2"));
+ board = board.newBoard(new Move("black k4"));
+ board = board.newBoard(new Move("white c3"));
+ board = board.newBoard(new Move("black g4"));
+ board = board.newBoard(new Move("white d4"));
+ board = board.newBoard(new Move("black h4"));
+ board = board.newBoard(new Move("white n4"));
+
+ assertNotNull(board);
+ if (DEBUG)
+ System.err.print("VertexLineariserTest::testVertexLineariser()
Black = " + Board.parseColour("black"));
+ if (DEBUG)
+ System.err.print(" White = " + Board.parseColour("white"));
+ if (DEBUG)
+ System.err.print(" Empty = " + Board.VERTEX_EMPTY);
+ if (DEBUG)
+ System.err.print(" Off = " + Board.VERTEX_OFF_BOARD);
+ if (DEBUG)
+ System.err.println("");
+ for (short j = 0; j < 8; j++) {
+ Iterator<Short> linear = new VertexLineariser(board, (short) 2,
(short) 2, j, false);
+ assertTrue(linear != null);
+ while (linear.hasNext()) {
+ Short s = linear.next();
+ assertTrue(s != null);
+ if (DEBUG)
+ System.err.print(" " + s + ", ");
+ }
+ if (DEBUG)
+ System.err.println();
+ }
+
+ }
+
+ /**
+ * make sure that all the linearisations are different
+ */
+ public void testAllDifferent() {
+ BoardI board = new Board();
+ assertNotNull(board);
+ board = board.newBoard(new Move("white b2"));
+ board = board.newBoard(new Move("black k4"));
+ board = board.newBoard(new Move("white c3"));
+ board = board.newBoard(new Move("black g4"));
+ board = board.newBoard(new Move("white d4"));
+ board = board.newBoard(new Move("black h4"));
+ board = board.newBoard(new Move("white n4"));
+
+ assertNotNull(board);
+ for (short j = 0; j < 8; j++)
+ for (short i = 0; i < 8; i++) {
+ if (i!= j){
+ Iterator<Short> lineara = new VertexLineariser(board, (short) 2,
(short) 2, j, false);
+ Iterator<Short> linearb = new VertexLineariser(board, (short) 2,
(short) 2, i, false);
+ assertTrue(lineara != null);
+ assertTrue(linearb != null);
+ boolean differenceFound = false;
+ while (lineara.hasNext() && linearb.hasNext()) {
+ Short a = lineara.next();
+ Short b = linearb.next();
+ assertTrue(a != null);
+ assertTrue(b != null);
+ if (!a.equals(b))
+ differenceFound = true;
+ }
+ assertTrue(i + " "+ j, differenceFound);
+ }
+ }
+
+ }
+
+ /**
+ * Test trained model.
+ */
+ public void testSize() {
+ BoardI board = new Board();
+ assertNotNull(board);
+ int count = 0;
+ Iterator<Short> linear = new VertexLineariser(board, (short) 2,
(short) 2, (short) 0, false);
+ while (linear.hasNext()) {
+ Short s = linear.next();
+ assertNotNull(s);
+ count++;
+ }
+ int plussize = (board.getSize() + 2) * (board.getSize() + 2);
+
+ assertTrue(count + "/" + plussize, count == plussize);
}

}

Reply all
Reply to author
Forward
0 new messages