[jgogears commit] r55 - in trunk/jgogears: doc jgogears jgogears/engine sgf/2004-12/2004/12/1

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 10, 2008, 2:22:57 AM3/10/08
to jgog...@googlegroups.com
Author: syeates
Date: Sun Mar 9 23:21:36 2008
New Revision: 55

Removed:
trunk/jgogears/jgogears/CopyOfRank.java
trunk/jgogears/jgogears/CopyOfRankTest.java
trunk/jgogears/jgogears/CopyOfRankToRating.java
trunk/jgogears/sgf/2004-12/2004/12/1/ADK-FAKK.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/Albatur-Cobra.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/ArekM-Ryba.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/Asshi1-rosechina.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/abane-jean1.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/aladar-Derial.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/asaw-frog04.sgf
trunk/jgogears/sgf/2004-12/2004/12/1/ayende-alanw.sgf
Modified:
trunk/jgogears/doc/TODO
trunk/jgogears/jgogears/AllTests.java
trunk/jgogears/jgogears/Board.java
trunk/jgogears/jgogears/BoardI.java
trunk/jgogears/jgogears/BoardTest.java
trunk/jgogears/jgogears/BoardToASCII.java
trunk/jgogears/jgogears/CachingKoRule.java
trunk/jgogears/jgogears/CorpusBuilder.java
trunk/jgogears/jgogears/FastBoardTest.java
trunk/jgogears/jgogears/FasterBoard.java
trunk/jgogears/jgogears/FasterBoardTest.java
trunk/jgogears/jgogears/Game.java
trunk/jgogears/jgogears/GlobalTests.java
trunk/jgogears/jgogears/GnuGoEngine.java
trunk/jgogears/jgogears/NoKoRuleSetTest.java
trunk/jgogears/jgogears/RuleSet.java
trunk/jgogears/jgogears/TwoGTP.java
trunk/jgogears/jgogears/ZobristTest.java
trunk/jgogears/jgogears/engine/ModelTest.java
trunk/jgogears/jgogears/engine/Node.java
trunk/jgogears/jgogears/engine/NodeTest.java
trunk/jgogears/jgogears/engine/Scorer.java
trunk/jgogears/jgogears/engine/Trainer.java
trunk/jgogears/jgogears/engine/VertexLineariserTest.java

Log:
Better tests related to the SGF files. remembered to format everything
this time. Removed duplicate files

Modified: trunk/jgogears/doc/TODO
==============================================================================
--- trunk/jgogears/doc/TODO (original)
+++ trunk/jgogears/doc/TODO Sun Mar 9 23:21:36 2008
@@ -2,6 +2,7 @@
====

Short Term
+==========
* trace lack of symmetry in testTrainedModelEmptyBoard
* work on ASCIIToBoard -> BoardI round triping
* update javacc generated files in svn (eclipse javacc plugin is
preventing this happening via eclipse)
@@ -12,16 +13,19 @@
* find a decent training corpus

SGF Support
+===========
* parse tt in SGF files
* work out the differences between SGF 3 and 4
* wider range of test inputs
* find a better set of tests

-BoardSupport
+Board Support
+=============
* 3-4 different types of KO detection
* finish CachingKoRule

General
+=======
* Decent ASCII board output
* Parse GnuGo board output
* direct
@@ -31,7 +35,8 @@
* SGF saving (use SGFC for validation)
* generate and quality-check the javadoc

-Speed improvements, test and improve:
+Speed improvements, test and improve
+====================================
* attribute parsing
* game structure creation


Modified: trunk/jgogears/jgogears/AllTests.java
==============================================================================
--- trunk/jgogears/jgogears/AllTests.java (original)
+++ trunk/jgogears/jgogears/AllTests.java Sun Mar 9 23:21:36 2008
@@ -23,15 +23,19 @@
suite.addTestSuite(GTPScoreTest.class);
suite.addTestSuite(SGFGameTest.class);
suite.addTestSuite(GnuGoEngineTest.class);
+ suite.addTestSuite(TwoGTPTest.class);
suite.addTestSuite(GnuGoEngineTest2.class);
- suite.addTestSuite(CopyOfRankTest.class);
suite.addTestSuite(NoKoRuleSetTest.class);
+ suite.addTest(AllTests.suite());
suite.addTestSuite(RankTest.class);
+ suite.addTestSuite(ZobristTest.class);
suite.addTestSuite(SGFNodeTest.class);
suite.addTestSuite(FasterBoardTest.class);
suite.addTestSuite(SGFPropertyTest.class);
suite.addTestSuite(BoardTest.class);
+ suite.addTestSuite(BoardToASCIITest.class);
suite.addTestSuite(SGFParserTest.class);
+ suite.addTest(GlobalTests.suite());
suite.addTestSuite(MoveTest.class);
suite.addTestSuite(FastBoardTest.class);
// $JUnit-END$

Modified: trunk/jgogears/jgogears/Board.java
==============================================================================
--- trunk/jgogears/jgogears/Board.java (original)
+++ trunk/jgogears/jgogears/Board.java Sun Mar 9 23:21:36 2008
@@ -203,7 +203,7 @@
// throw new Error("Bad board size or play off the edge of the board
(remember we're zero indexed) "
// + column + "/" + this.getSize() + " ");

- this.board[row][column] = (short)colour;
+ this.board[row][column] = (short) colour;
}

}

Modified: trunk/jgogears/jgogears/BoardI.java
==============================================================================
--- trunk/jgogears/jgogears/BoardI.java (original)
+++ trunk/jgogears/jgogears/BoardI.java Sun Mar 9 23:21:36 2008
@@ -237,7 +237,7 @@
if (move.getColour() == VERTEX_KO || move.getColour() ==
VERTEX_EMPTY) {
break;
} else {
- throw new Error(move + "");
+ throw new Error(move + "\n " + old);
}
case VERTEX_OFF_BOARD:
if (move.getColour() != VERTEX_OFF_BOARD) {

Modified: trunk/jgogears/jgogears/BoardTest.java
==============================================================================
--- trunk/jgogears/jgogears/BoardTest.java (original)
+++ trunk/jgogears/jgogears/BoardTest.java Sun Mar 9 23:21:36 2008
@@ -147,19 +147,19 @@
BoardI board1 = new Board();
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));

@@ -177,19 +177,19 @@
BoardI board1 = new Board(true);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));

@@ -207,13 +207,13 @@
BoardI board1 = new Board(false);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
@@ -244,34 +244,33 @@
// directory, parsing as an SGF file");

Game game = Game.loadFromFile(file);
- Iterator<Move> i = game.getMoves();
- Move move = null;
- BoardI board = new Board(game.getSize());
- // System.err.println("board size is: \"" + goGame.getSize()
- // + "\"");
- while (i.hasNext()) {
- move = i.next();
- assertNotNull(move);
- // System.err.print("move: \"" + move + "\"");
- // assertTrue("" + board + "\n" +
- // move.toString(),board.isLegalMove(move));
- board = board.newBoard(move);
- // System.err.println(" board size is: \"" +
- // board.getSize() + "\"");
+ if (game.getSize() == 19) {
+ Iterator<Move> i = game.getMoves();
+ Move move = null;
+ BoardI board = new Board(game.getSize());
+ // System.err.println("board size is: \"" + goGame.getSize()
+ // + "\"");
+ while (i.hasNext()) {
+ move = i.next();
+ assertNotNull(move);
+ // System.err.print("move: \"" + move + "\"");
+ // assertTrue("" + board + "\n" +
+ // move.toString(),board.isLegalMove(move));
+ board = board.newBoard(move);
+ // System.err.println(" board size is: \"" +
+ // board.getSize() + "\"");
+ }
+ // System.err.println();
}
- // System.err.println();
-
- // TODO allow us to actually read all the files
- return;
-
} else {
System.err.println("\"" + filename + "\" is a directory");
String[] children = file.list();
- for (int i = 0; i < children.length; i++) {
- // System.err.println("pushing \"" + children[i] +
- // "\"");
- files.push(filename + "/" + children[i]);
- }
+ if (!file.getName().contains(".svn"))
+ for (int i = 0; i < children.length; i++) {
+ // System.err.println("pushing \"" + children[i] +
+ // "\"");
+ files.push(filename + "/" + children[i]);
+ }
}
}
}

Modified: trunk/jgogears/jgogears/BoardToASCII.java
==============================================================================
--- trunk/jgogears/jgogears/BoardToASCII.java (original)
+++ trunk/jgogears/jgogears/BoardToASCII.java Sun Mar 9 23:21:36 2008
@@ -52,6 +52,12 @@
return true;
return false;
}
+ if (size == 9) {
+ if (row == 3 || row == 5)
+ if (column == 3 || column == 5)
+ return true;
+ return false;
+ }
throw new Error("not implemented");
}


Modified: trunk/jgogears/jgogears/CachingKoRule.java
==============================================================================
--- trunk/jgogears/jgogears/CachingKoRule.java (original)
+++ trunk/jgogears/jgogears/CachingKoRule.java Sun Mar 9 23:21:36 2008
@@ -3,9 +3,8 @@
import java.util.TreeSet;

/**
- * A RuleSet that caches the results to speed things up.
- *
- * TODO this class is still a skeleton, it doesn't actually do
anything yet.
+ * A RuleSet that caches the results to speed things up. TODO this
class is still a skeleton, it doesn't actually do
+ * anything yet.
*
* @author syeates
*/

Modified: trunk/jgogears/jgogears/CorpusBuilder.java
==============================================================================
--- trunk/jgogears/jgogears/CorpusBuilder.java (original)
+++ trunk/jgogears/jgogears/CorpusBuilder.java Sun Mar 9 23:21:36 2008
@@ -19,10 +19,10 @@
* the exception
*/
public static void main(String[] args) throws Exception {
- if (args.length > 0){
+ if (args.length > 0) {
System.err.println("arguments are not examined ");
}
-
+
CorpusBuilder builder = new CorpusBuilder();
builder.files.push(new File(builder.from));

@@ -37,7 +37,7 @@
* the exception
*/
public static void mainold(String[] args) throws Exception {
- if (args.length > 0){
+ if (args.length > 0) {
System.err.println("arguments are not examined ");
}
Stack<String> files = new Stack<String>();

Modified: trunk/jgogears/jgogears/FastBoardTest.java
==============================================================================
--- trunk/jgogears/jgogears/FastBoardTest.java (original)
+++ trunk/jgogears/jgogears/FastBoardTest.java Sun Mar 9 23:21:36 2008
@@ -108,34 +108,34 @@
// directory, parsing as an SGF file");

Game game = Game.loadFromFile(file);
- Iterator<Move> i = game.getMoves();
- Move move = null;
- BoardI board = new FastBoard(game.getSize());
- // System.err.println("board size is: \"" + goGame.getSize()
- // + "\"");
- while (i.hasNext()) {
- move = i.next();
- assertNotNull(move);
- // System.err.print("move: \"" + move + "\"");
- // assertTrue("" + board + "\n" +
- // move.toString(),board.isLegalMove(move));
- board = board.newBoard(move);
- // System.err.println(" board size is: \"" +
- // board.getSize() + "\"");
- }
- // System.err.println();
-
- // TODO allow us to actually read all the files
- return;
+ if (game.getSize() == 19) {
+ Iterator<Move> i = game.getMoves();
+ Move move = null;
+ BoardI board = new FastBoard(game.getSize());
+ // System.err.println("board size is: \"" + goGame.getSize()
+ // + "\"");
+ while (i.hasNext()) {
+ move = i.next();
+ assertNotNull(move);
+ // System.err.print("move: \"" + move + "\"");
+ // assertTrue("" + board + "\n" +
+ // move.toString(),board.isLegalMove(move));
+ board = board.newBoard(move);
+ // System.err.println(" board size is: \"" +
+ // board.getSize() + "\"");
+ }
+ // System.err.println();

+ }
} else {
// System.err.println("\"" + filename + "\" is a directory");
String[] children = file.list();
- for (int i = 0; i < children.length; i++) {
- // System.err.println("pushing \"" + children[i] +
- // "\"");
- files.push(filename + "/" + children[i]);
- }
+ if (!file.getName().contains(".svn"))
+ for (int i = 0; i < children.length; i++) {
+ // System.err.println("pushing \"" + children[i] +
+ // "\"");
+ files.push(filename + "/" + children[i]);
+ }
}
}
}
@@ -337,19 +337,19 @@
BoardI board1 = new FastBoard();
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));

@@ -367,19 +367,19 @@
BoardI board1 = new FastBoard(true);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));

@@ -397,19 +397,19 @@
BoardI board1 = new FastBoard(false);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));


Modified: trunk/jgogears/jgogears/FasterBoard.java
==============================================================================
--- trunk/jgogears/jgogears/FasterBoard.java (original)
+++ trunk/jgogears/jgogears/FasterBoard.java Sun Mar 9 23:21:36 2008
@@ -99,8 +99,10 @@
/**
* Create a new board.
*
- * @param zobrist are we using zobrist hashes?
- * @param size the board size
+ * @param zobrist
+ * are we using zobrist hashes?
+ * @param size
+ * the board size
*/
public FasterBoard(short size, boolean zobrist) {
super(zobrist);
@@ -125,8 +127,10 @@
*
* @param size
* the size of the board
- * @param zobrist are we using zobrist hashes?
- * @param rule the ruleset in use
+ * @param zobrist
+ * are we using zobrist hashes?
+ * @param rule
+ * the ruleset in use
*/
public FasterBoard(short size, RuleSet rule, boolean zobrist) {
super(zobrist);

Modified: trunk/jgogears/jgogears/FasterBoardTest.java
==============================================================================
--- trunk/jgogears/jgogears/FasterBoardTest.java (original)
+++ trunk/jgogears/jgogears/FasterBoardTest.java Sun Mar 9 23:21:36 2008
@@ -138,25 +138,25 @@
// directory, parsing as an SGF file");

Game game = Game.loadFromFile(file);
- Iterator<Move> i = game.getMoves();
- Move move = null;
- BoardI board = new FasterBoard(game.getSize());
- // System.err.println("board size is: \"" + goGame.getSize()
- // + "\"");
- while (i.hasNext()) {
- move = i.next();
- assertNotNull(move);
- // System.err.print("move: \"" + move + "\"");
- // assertTrue("" + board + "\n" +
- // move.toString(),board.isLegalMove(move));
- board = board.newBoard(move);
- // System.err.println(" board size is: \"" +
- // board.getSize() + "\"");
- }
- // System.err.println();
-
- // TODO allow us to actually read all the files
+ if (game.getSize() == 19) {
+ Iterator<Move> i = game.getMoves();
+ Move move = null;
+ BoardI board = new FasterBoard(game.getSize());
+ // System.err.println("board size is: \"" + goGame.getSize()
+ // + "\"");
+ while (i.hasNext()) {
+ move = i.next();
+ assertNotNull(move);
+ // System.err.print("move: \"" + move + "\"");
+ // assertTrue("" + board + "\n" +
+ // move.toString(),board.isLegalMove(move));
+ board = board.newBoard(move);
+ // System.err.println(" board size is: \"" +
+ // board.getSize() + "\"");
+ }
+ // System.err.println();

+ }
} else {
System.err.println("\"" + filename + "\" is a directory");
if (!file.getName().contains(".svn")) {
@@ -214,19 +214,19 @@
BoardI board1 = new FasterBoard();
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));

@@ -244,19 +244,19 @@
BoardI board1 = new FasterBoard(true);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));

@@ -274,19 +274,19 @@
BoardI board1 = new FasterBoard(false);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));

assertTrue(board1.equals(board1));
assertTrue(board2.equals(board2));
assertTrue(board3.equals(board3));
- //assertTrue(board4.equals(board4));
-
+ // assertTrue(board4.equals(board4));
+
assertFalse(board1.equals(board2));
assertFalse(board2.equals(board1));
assertFalse(board1.equals(board3));
assertFalse(board3.equals(board1));
- //assertTrue(board4.equals(board1));
- //assertTrue(board1.equals(board4));
+ // assertTrue(board4.equals(board1));
+ // assertTrue(board1.equals(board4));
assertTrue(board2.equals(board3));
assertTrue(board3.equals(board2));


Modified: trunk/jgogears/jgogears/Game.java
==============================================================================
--- trunk/jgogears/jgogears/Game.java (original)
+++ trunk/jgogears/jgogears/Game.java Sun Mar 9 23:21:36 2008
@@ -153,7 +153,7 @@
* @return the boardlist
*/
public final LinkedList<BoardI> getBoardlist() {
- if (this.boardlist == null)
+ if (this.boardlist == null)
getBoards();
return this.boardlist;
}

Modified: trunk/jgogears/jgogears/GlobalTests.java
==============================================================================
--- trunk/jgogears/jgogears/GlobalTests.java (original)
+++ trunk/jgogears/jgogears/GlobalTests.java Sun Mar 9 23:21:36 2008
@@ -36,13 +36,13 @@
suite.addTestSuite(GnuGoEngineTest.class);
suite.addTestSuite(BoardTest.class);
suite.addTestSuite(SGFGameTest.class);
- suite.addTestSuite(CopyOfRankTest.class);
suite.addTestSuite(GTPScoreTest.class);
suite.addTestSuite(GnuGoEngineTest2.class);
suite.addTestSuite(FastBoardTest.class);
suite.addTestSuite(FasterBoardTest.class);
suite.addTestSuite(NoKoRuleSetTest.class);
suite.addTestSuite(ZobristTest.class);
+ suite.addTestSuite(CheckAllSGFFilesTest.class);
return suite;
}


Modified: trunk/jgogears/jgogears/GnuGoEngine.java
==============================================================================
--- trunk/jgogears/jgogears/GnuGoEngine.java (original)
+++ trunk/jgogears/jgogears/GnuGoEngine.java Sun Mar 9 23:21:36 2008
@@ -59,7 +59,8 @@
/**
* Instantiates a new gnu go engine.
*
- * @param size the board size we're playing on
+ * @param size
+ * the board size we're playing on
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@@ -71,7 +72,8 @@
/**
* Instantiates a new gnu go engine.
*
- * @param size the board size we're playing on
+ * @param size
+ * the board size we're playing on
* @throws IOException
* Signals that an I/O exception has occurred.
*/

Modified: trunk/jgogears/jgogears/NoKoRuleSetTest.java
==============================================================================
--- trunk/jgogears/jgogears/NoKoRuleSetTest.java (original)
+++ trunk/jgogears/jgogears/NoKoRuleSetTest.java Sun Mar 9 23:21:36 2008
@@ -645,22 +645,25 @@
filecount++;

Game game = Game.loadFromFile(file);
- BoardI board = BoardI.newBoard(game.getSize());
- System.err.println(filename);
+ if (game.getSize() == 19) {
+ BoardI board = BoardI.newBoard(game.getSize());
+ System.err.println(filename);

- Iterator<Move> i = game.getMovelist().iterator();
- while (i.hasNext()) {
- Move move = i.next();
- if (!rule.moveIsLegal(game, board, move)) {
- assertTrue(move + "\n " + BoardToASCII.Transform(board), false);
+ Iterator<Move> i = game.getMovelist().iterator();
+ while (i.hasNext()) {
+ Move move = i.next();
+ if (!rule.moveIsLegal(game, board, move)) {
+ assertTrue(move + "\n " + BoardToASCII.Transform(board), false);
+ }
+ board = board.newBoard(move);
}
- board = board.newBoard(move);
}
} else {
String[] children = file.list();
- for (int i = 0; i < children.length; i++) {
- files.push(filename + "/" + children[i]);
- }
+ if (!file.getName().contains(".svn"))
+ for (int i = 0; i < children.length; i++) {
+ files.push(filename + "/" + children[i]);
+ }
}
}
}

Modified: trunk/jgogears/jgogears/RuleSet.java
==============================================================================
--- trunk/jgogears/jgogears/RuleSet.java (original)
+++ trunk/jgogears/jgogears/RuleSet.java Sun Mar 9 23:21:36 2008
@@ -59,11 +59,16 @@
public short countLiberties(short rowb, short columnb, BoardI board) {
return (short) this.getLiberties(rowb, columnb, board).size();
}
+
/**
* Get all the legal moves
- * @param game the game being played
- * @param board the current state of the baord
- * @param colour the colour being played
+ *
+ * @param game
+ * the game being played
+ * @param board
+ * the current state of the baord
+ * @param colour
+ * the colour being played
* @return the collection of moves
*/

@@ -77,13 +82,18 @@
}
return moves;
}
-/**
- * Get all the legal moves
- * @param game the game being played
- * @param board the current state of the baord
- * @param colour the colour being played
- * @return the collection of vertexes
- */
+
+ /**
+ * Get all the legal moves
+ *
+ * @param game
+ * the game being played
+ * @param board
+ * the current state of the baord
+ * @param colour
+ * the colour being played
+ * @return the collection of vertexes
+ */
public Collection<Vertex> getAllLegalVertexes(Game game, BoardI
board, short colour) {
Stack<Vertex> moves = new Stack<Vertex>();
for (int i = 0; i < board.getSize(); i++)

Modified: trunk/jgogears/jgogears/TwoGTP.java
==============================================================================
--- trunk/jgogears/jgogears/TwoGTP.java (original)
+++ trunk/jgogears/jgogears/TwoGTP.java Sun Mar 9 23:21:36 2008
@@ -1,6 +1,5 @@
package jgogears;

-
/**
* An incomplete clone of the TwoGTP program included in the GnuGo
distribution. It runs a go game between a pair of
* GTP-capiable players TODO finish this implementation
@@ -9,7 +8,7 @@
*/

public class TwoGTP {
-/** are we spewing debugging information? */
+ /** are we spewing debugging information? */
public static final boolean DEBUG = false;

/** The black player. */

Modified: trunk/jgogears/jgogears/ZobristTest.java
==============================================================================
--- trunk/jgogears/jgogears/ZobristTest.java (original)
+++ trunk/jgogears/jgogears/ZobristTest.java Sun Mar 9 23:21:36 2008
@@ -91,11 +91,11 @@
BoardI board1 = BoardI.newBoard(true);
BoardI board2 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
BoardI board3 = board1.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
- //BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
+ // BoardI board4 = board2.newBoard(new Move((short) 1, (short) 1, BoardI.VERTEX_BLACK));
// make sure the hashes are the same
assertFalse(board1.getZobrist().equals(board2.getZobrist()));
assertFalse(board1.getZobrist().equals(board3.getZobrist()));
- //assertTrue(board1.getZobrist().equals(board4.getZobrist()));
+ // assertTrue(board1.getZobrist().equals(board4.getZobrist()));
assertTrue(board2.getZobrist().equals(board3.getZobrist()));

}

Modified: trunk/jgogears/jgogears/engine/ModelTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/ModelTest.java (original)
+++ trunk/jgogears/jgogears/engine/ModelTest.java Sun Mar 9 23:21:36 2008
@@ -18,7 +18,6 @@
/** The model. */
static Model model = null;

-
/**
* Instantiates a new model test.
*
@@ -116,7 +115,7 @@
public void testEmptyModelEmptyBoard() throws IOException {
assertNotNull(model);
BoardI board = BoardI.newBoard();
- double[][] r = new Scorer().getScores(model,board, false);
+ double[][] r = new Scorer().getScores(model, board, false);
assertNotNull(r);
assertTrue(r.length == r[0].length);
if (DEBUG) {
@@ -229,7 +228,7 @@
public void testTrainedModel() throws IOException {
assertNotNull(model);
System.err.println("ModeTest::testTrainedModel() model size = " + model.getRoot().size());
- new Trainer().train(model,this.loadTestGame());
+ new Trainer().train(model, this.loadTestGame());
System.err.println("ModeTest::testTrainedModel() model size = " + model.getRoot().size());
BoardI board = BoardI.newBoard(19);
board = board.newBoard(new Move("white b2"));
@@ -260,10 +259,10 @@
public void testTrainedModelEmptyBoard() throws IOException {
assertNotNull(model);
System.err.println("ModeTest::testTrainedModelEmptyBoard() model
size = " + model.getRoot().size());
- new Trainer().train(model,this.loadTestGame());
+ new Trainer().train(model, this.loadTestGame());
System.err.println("ModeTest::testTrainedModelEmptyBoard() model
size = " + model.getRoot().size());
BoardI board = BoardI.newBoard(19);
- double[][] r = new Scorer().getScores(model,board, false);
+ double[][] r = new Scorer().getScores(model, board, false);
assertNotNull(r);
assertTrue(r.length == r[0].length);
if (DEBUG) {

Modified: trunk/jgogears/jgogears/engine/Node.java
==============================================================================
--- trunk/jgogears/jgogears/engine/Node.java (original)
+++ trunk/jgogears/jgogears/engine/Node.java Sun Mar 9 23:21:36 2008
@@ -83,70 +83,71 @@
public final Node getEmpty() {
return this.empty;
}
-///**
-// * find a particular leaf in this tree
-// * @param board
-// * @param colour
-// * @param row
-// * @param column
-// * @param sym
-// * @param node
-// * @return the leaf node
-// */
-// static public Node getLeaf(BoardI board, short colour, short row,
short column, short sym, Node node) {
-// if (board == null)
-// throw new Error();
-// VertexLineariser linear = null;
-// boolean invert = colour == BoardI.VERTEX_WHITE;
-//
-// linear = new VertexLineariser(board, row, column, sym, invert);
-// if (!linear.hasNext())
-// throw new Error();
-// return getLeaf(linear, node);
-//
-// }
-// /**
-// * find a particular leaf in this tree
-// * @param linear the linearisation to use
-// * @param node the root node to use
-// * @return the leaf node
-// */
-//
-// static public Node getLeaf(VertexLineariser linear, Node node) {
-// if (!linear.hasNext())
-// throw new Error();
-//
-// while (linear.hasNext()) {
-// Node child = null;
-// Short colour = linear.next();
-// switch (colour) {
-// case BoardI.VERTEX_BLACK:
-// child = node.black;
-// break;
-// case BoardI.VERTEX_WHITE:
-// child = node.white;
-// break;
-// case BoardI.VERTEX_OFF_BOARD:
-// child = node.off;
-// break;
-// case BoardI.VERTEX_KO:
-// case BoardI.VERTEX_EMPTY:
-// child = node.empty;
-// break;
-// default:
-// throw new Error("Unknown vertex colour: " + colour);
-// }
-// if (child == null)
-// return node;
-// node = child;
-// }
-// return node;
-// }
+
+ // /**
+ // * find a particular leaf in this tree
+ // * @param board
+ // * @param colour
+ // * @param row
+ // * @param column
+ // * @param sym
+ // * @param node
+ // * @return the leaf node
+ // */
+ // static public Node getLeaf(BoardI board, short colour, short row,
short column, short sym, Node node) {
+ // if (board == null)
+ // throw new Error();
+ // VertexLineariser linear = null;
+ // boolean invert = colour == BoardI.VERTEX_WHITE;
+ //
+ // linear = new VertexLineariser(board, row, column, sym, invert);
+ // if (!linear.hasNext())
+ // throw new Error();
+ // return getLeaf(linear, node);
+ //
+ // }
+ // /**
+ // * find a particular leaf in this tree
+ // * @param linear the linearisation to use
+ // * @param node the root node to use
+ // * @return the leaf node
+ // */
+ //
+ // static public Node getLeaf(VertexLineariser linear, Node node) {
+ // if (!linear.hasNext())
+ // throw new Error();
+ //
+ // while (linear.hasNext()) {
+ // Node child = null;
+ // Short colour = linear.next();
+ // switch (colour) {
+ // case BoardI.VERTEX_BLACK:
+ // child = node.black;
+ // break;
+ // case BoardI.VERTEX_WHITE:
+ // child = node.white;
+ // break;
+ // case BoardI.VERTEX_OFF_BOARD:
+ // child = node.off;
+ // break;
+ // case BoardI.VERTEX_KO:
+ // case BoardI.VERTEX_EMPTY:
+ // child = node.empty;
+ // break;
+ // default:
+ // throw new Error("Unknown vertex colour: " + colour);
+ // }
+ // if (child == null)
+ // return node;
+ // node = child;
+ // }
+ // return node;
+ // }

/**
* how many times has this node not been played?
*
- * @return the number of times has this node not been played?
+ * @return the number of times has this node not been played?
*/
public final long getNotPlayed() {
return this.notPlayed;
@@ -164,7 +165,7 @@
/**
* how many times has this node been played?
*
- * @return the number of times has this node been played?
+ * @return the number of times has this node been played?
*/
public final long getPlayed() {
return this.played;

Modified: trunk/jgogears/jgogears/engine/NodeTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/NodeTest.java (original)
+++ trunk/jgogears/jgogears/engine/NodeTest.java Sun Mar 9 23:21:36 2008
@@ -25,6 +25,7 @@
parent.setBlack(null);
assertNull(parent.getBlack());
}
+
/**
*
*/
@@ -106,6 +107,7 @@
parent.setBlack(null);
assertNull(parent.getBlack());
}
+
/**
*
*/

Modified: trunk/jgogears/jgogears/engine/Scorer.java
==============================================================================
--- trunk/jgogears/jgogears/engine/Scorer.java (original)
+++ trunk/jgogears/jgogears/engine/Scorer.java Sun Mar 9 23:21:36 2008
@@ -7,8 +7,8 @@

/**
* Class to calculate scores using a model and a board.
+ *
* @author syeates
- *
*/
public class Scorer {
/** are we being verbose? */
@@ -51,7 +51,7 @@
* @param model
* @return the array of scores
*/
- public double[][] getScores(Model model,BoardI board, boolean white) {
+ public double[][] getScores(Model model, BoardI board, boolean white) {
short size = board.getSize();
double[][] result = new double[size][size];
for (short row = 0; row < size; row++) {

Modified: trunk/jgogears/jgogears/engine/Trainer.java
==============================================================================
--- trunk/jgogears/jgogears/engine/Trainer.java (original)
+++ trunk/jgogears/jgogears/engine/Trainer.java Sun Mar 9 23:21:36 2008
@@ -10,38 +10,39 @@

/**
* TODO
+ *
* @author syeates
- *
*/
public class Trainer {
- static final private boolean DEBUG = false;
- private int minBranchSize = 20;
- private int defaultNumberOfFiles = 100;
-
- /**
- * Train on files.
- *
- * @param model
- * the model
- * @return the model
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public Model trainFiles( Model model) throws IOException {
- return trainFiles(defaultNumberOfFiles, model);
- }
- /**
- * Train on files.
- *
- * @param count
- * the count
- * @param model
- * the model
- * @return the model
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public Model trainFiles(int count, Model model) throws IOException {
+ static final private boolean DEBUG = false;
+ private int minBranchSize = 20;
+ private int defaultNumberOfFiles = 100;
+
+ /**
+ * Train on files.
+ *
+ * @param model
+ * the model
+ * @return the model
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public Model trainFiles(Model model) throws IOException {
+ return trainFiles(defaultNumberOfFiles, model);
+ }
+
+ /**
+ * Train on files.
+ *
+ * @param count
+ * the count
+ * @param model
+ * the model
+ * @return the model
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public Model trainFiles(int count, Model model) throws IOException {
Stack<String> files = new Stack<String>();
files.push("sgf/2004-12");

@@ -70,7 +71,6 @@
System.err.println("Trainer::trainNFiles loaded " + filecount + " files ");
return model;
}
-

/**
* Train.
@@ -113,9 +113,9 @@

VertexLineariser linear = new VertexLineariser(board, i, j, sym, !isBlack);
if (!move.getPass() && move.getRow() != i &&
move.getColumn() != j)
- train(model.getRoot(),linear, true, true, 100);
+ train(model.getRoot(), linear, true, true, 100);
else
- train(model.getRoot(),linear, false, true, 30);
+ train(model.getRoot(), linear, false, true, 30);
}
}
}
@@ -142,9 +142,9 @@
expand = false;
depth--;
if (playeda)
- root.setPlayed(root.getPlayed() +1);
+ root.setPlayed(root.getPlayed() + 1);
else
- root.setNotPlayed(root.getNotPlayed() +1);
+ root.setNotPlayed(root.getNotPlayed() + 1);
if (!linear.hasNext())
return;
Short colour = linear.next();
@@ -154,42 +154,42 @@
if (root.getBlack() == null)
if (expand) {
root.setBlack(new Node());
- train(root.getBlack(),linear, playeda, false, depth);
+ train(root.getBlack(), linear, playeda, false, depth);
} else
return;
else
- train(root.getBlack(),linear, playeda, expand, depth);
+ train(root.getBlack(), linear, playeda, expand, depth);
break;
case BoardI.VERTEX_WHITE:
if (root.getWhite() == null)
if (expand) {
root.setWhite(new Node());
- train(root.getWhite(),linear, playeda, false, depth);
+ train(root.getWhite(), linear, playeda, false, depth);
} else
return;
else
- train(root.getWhite(),linear, playeda, expand, depth);
+ train(root.getWhite(), linear, playeda, expand, depth);
break;
case BoardI.VERTEX_KO:
case BoardI.VERTEX_EMPTY:
if (root.getEmpty() == null)
if (expand) {
root.setEmpty(new Node());
- train(root.getEmpty(),linear, playeda, false, depth);
+ train(root.getEmpty(), linear, playeda, false, depth);
} else
return;
else
- train(root.getEmpty(),linear, playeda, expand, depth);
+ train(root.getEmpty(), linear, playeda, expand, depth);
break;
case BoardI.VERTEX_OFF_BOARD:
if (root.getOff() == null)
if (expand) {
root.setOff(new Node());
- train(root.getOff(),linear, playeda, false, depth);
+ train(root.getOff(), linear, playeda, false, depth);
} else
return;
else
- train(root.getOff(),linear, playeda, expand, depth);
+ train(root.getOff(), linear, playeda, expand, depth);
break;
default:
throw new Error();

Modified: trunk/jgogears/jgogears/engine/VertexLineariserTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/VertexLineariserTest.java (original)
+++ trunk/jgogears/jgogears/engine/VertexLineariserTest.java Sun Mar 9
23:21:36 2008
@@ -479,7 +479,7 @@
assertTrue(lineara != null);
Short a = lineara.next();
assertTrue(a != null);
- if (a == null )
+ if (a == null)
throw new Error();
assertTrue(a + " " + BoardI.VERTEX_WHITE + "\n" + board,
a.equals(new Short(BoardI.VERTEX_WHITE)));
}

Reply all
Reply to author
Forward
0 new messages