[jgogears commit] r51 - in trunk/jgogears: doc jgogears jgogears/engine

1 view
Skip to first unread message

codesite...@google.com

unread,
Mar 6, 2008, 3:13:15 AM3/6/08
to jgog...@googlegroups.com
Author: syeates
Date: Thu Mar 6 00:12:29 2008
New Revision: 51

Modified:
trunk/jgogears/doc/TODO
trunk/jgogears/jgogears/BoardI.java
trunk/jgogears/jgogears/CorpusBuilder.java
trunk/jgogears/jgogears/FasterBoard.java
trunk/jgogears/jgogears/GTPState.java
trunk/jgogears/jgogears/GnuGoEngine.java
trunk/jgogears/jgogears/GnuGoEngineTest2.java
trunk/jgogears/jgogears/Move.java
trunk/jgogears/jgogears/RandomEngine.java
trunk/jgogears/jgogears/RuleSet.java
trunk/jgogears/jgogears/TwoGTP.java
trunk/jgogears/jgogears/engine/Engine.java
trunk/jgogears/jgogears/engine/Model.java
trunk/jgogears/jgogears/engine/ModelTest.java
trunk/jgogears/jgogears/engine/Node.java
trunk/jgogears/jgogears/engine/NodeTest.java
trunk/jgogears/jgogears/engine/VertexLineariser.java
trunk/jgogears/jgogears/engine/VertexLineariserTest.java

Log:
added TODOs, changes to remove compiler warnings

Modified: trunk/jgogears/doc/TODO
==============================================================================
--- trunk/jgogears/doc/TODO (original)
+++ trunk/jgogears/doc/TODO Thu Mar 6 00:12:29 2008
@@ -6,6 +6,9 @@
* 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)
+* commandline program to play jgogears against gnugo
+* commandline program to guess moves from real games
+* separate the model data structures from the algorithms

SGF Support
* parse tt in SGF files

Modified: trunk/jgogears/jgogears/BoardI.java
==============================================================================
--- trunk/jgogears/jgogears/BoardI.java (original)
+++ trunk/jgogears/jgogears/BoardI.java Thu Mar 6 00:12:29 2008
@@ -105,8 +105,6 @@
*
* @param size
* the size of the board
- * @param rule
- * the ruleset to use
* @param zobrist
* are we using a zobrist hash?
* @return the new empty board
@@ -189,6 +187,7 @@
* the zobrist
*/
public BoardI(boolean zobrist) {
+ if (zobrist)
this.zobrist = new Zobrist();
}

@@ -197,6 +196,7 @@
*
* @param move
* the move
+ * @param old the old board we're coping data from
*/
protected void copydata(BoardI old, Move move) {
this.size = old.getSize();
@@ -281,7 +281,7 @@
* the ruleset in use
* @param colour
* the colour of the move we want to play
- * @return
+ * @return a collection of the moves
*/
public Collection<Move> getAllLegalMoves(RuleSet rules, short colour) {
return rules.getAllLegalMoves(null, this, colour);
@@ -294,7 +294,7 @@
* the ruleset in use
* @param colour
* the colour of the move we want to play
- * @return
+ * @return the moves
*/

public Collection<Vertex> getAllLegalVertexes(RuleSet rules, short
colour) {
@@ -315,14 +315,11 @@
/**
* get the colour of a vertex.
*
- * @param row
- * the row
- * @param column
- * the column
+ * @param vertex the vertex we're getting the colour of
* @return the colour
*/
- public short getColour(Vertex v) {
- return this.getColour(v.getRow(), v.getColumn());
+ public short getColour(Vertex vertex) {
+ return this.getColour(vertex.getRow(), vertex.getColumn());
}

/**

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

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


Modified: trunk/jgogears/jgogears/FasterBoard.java
==============================================================================
--- trunk/jgogears/jgogears/FasterBoard.java (original)
+++ trunk/jgogears/jgogears/FasterBoard.java Thu Mar 6 00:12:29 2008
@@ -99,10 +99,8 @@
/**
* Create a new board.
*
- * @param size
- * the size of the board
- * @param rule
- * the ruleset to use
+ * @param zobrist are we using zobrist hashes?
+ * @param size the board size
*/
public FasterBoard(short size, boolean zobrist) {
super(zobrist);
@@ -127,8 +125,8 @@
*
* @param size
* the size of the board
- * @param rule
- * the ruleset to 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/GTPState.java
==============================================================================
--- trunk/jgogears/jgogears/GTPState.java (original)
+++ trunk/jgogears/jgogears/GTPState.java Thu Mar 6 00:12:29 2008
@@ -249,8 +249,8 @@
* @param komi
* the new komi
*/
- public void setKomi(double komia) {
- this.komi = komia;
+ public void setKomi(double komi) {
+ this.komi = komi;
}

/**
@@ -259,8 +259,8 @@
* @param mainTime
* the new main time
*/
- public void setMainTime(double mainTimea) {
- this.mainTime = mainTimea;
+ public void setMainTime(double mainTime) {
+ this.mainTime = mainTime;
}

/**

Modified: trunk/jgogears/jgogears/GnuGoEngine.java
==============================================================================
--- trunk/jgogears/jgogears/GnuGoEngine.java (original)
+++ trunk/jgogears/jgogears/GnuGoEngine.java Thu Mar 6 00:12:29 2008
@@ -59,6 +59,7 @@
/**
* Instantiates a new gnu go engine.
*
+ * @param size the board size we're playing on
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@@ -70,6 +71,7 @@
/**
* Instantiates a new gnu go engine.
*
+ * @param size the board size we're playing on
* @throws IOException
* Signals that an I/O exception has occurred.
*/

Modified: trunk/jgogears/jgogears/GnuGoEngineTest2.java
==============================================================================
--- trunk/jgogears/jgogears/GnuGoEngineTest2.java (original)
+++ trunk/jgogears/jgogears/GnuGoEngineTest2.java Thu Mar 6 00:12:29 2008
@@ -67,7 +67,7 @@

Iterator<Move> moves = game.getMoves();
assertNotNull(moves);
- GnuGoEngine engine = new GnuGoEngine();
+ engine = new GnuGoEngine();
while (moves.hasNext()) {
Move move = moves.next();
// System.err.println(move);

Modified: trunk/jgogears/jgogears/Move.java
==============================================================================
--- trunk/jgogears/jgogears/Move.java (original)
+++ trunk/jgogears/jgogears/Move.java Thu Mar 6 00:12:29 2008
@@ -228,7 +228,7 @@
*/
protected String numberToCharacter(short s) {
String rowS = null;
- switch (this.row) {
+ switch (s) {
case 0:
rowS = "a";
break;

Modified: trunk/jgogears/jgogears/RandomEngine.java
==============================================================================
--- trunk/jgogears/jgogears/RandomEngine.java (original)
+++ trunk/jgogears/jgogears/RandomEngine.java Thu Mar 6 00:12:29 2008
@@ -74,6 +74,8 @@
* @return the gTP score
*/
public GTPScore score(GTPState state) {
+ if (state == null)
+ throw new Error();
// TODO Auto-generated method stub
return new GTPScore("?");
}

Modified: trunk/jgogears/jgogears/RuleSet.java
==============================================================================
--- trunk/jgogears/jgogears/RuleSet.java (original)
+++ trunk/jgogears/jgogears/RuleSet.java Thu Mar 6 00:12:29 2008
@@ -72,7 +72,7 @@
for (int i = 0; i < board.getSize(); i++)
for (int j = 0; j < board.getSize(); j++) {
Move move = new Move(i, j, colour);
- if (this.moveIsLegal(null, board, move))
+ if (this.moveIsLegal(game, board, move))
moves.push(move);
}
return moves;
@@ -88,7 +88,7 @@
Stack<Vertex> moves = new Stack<Vertex>();
for (int i = 0; i < board.getSize(); i++)
for (int j = 0; j < board.getSize(); j++)
- if (this.moveIsLegal(null, board, new Move(i, j, colour)))
+ if (this.moveIsLegal(game, board, new Move(i, j, colour)))
moves.push(new Vertex(i, j));
return moves;
}

Modified: trunk/jgogears/jgogears/TwoGTP.java
==============================================================================
--- trunk/jgogears/jgogears/TwoGTP.java (original)
+++ trunk/jgogears/jgogears/TwoGTP.java Thu Mar 6 00:12:29 2008
@@ -9,7 +9,7 @@
*/

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

/** The black player. */

Modified: trunk/jgogears/jgogears/engine/Engine.java
==============================================================================
--- trunk/jgogears/jgogears/engine/Engine.java (original)
+++ trunk/jgogears/jgogears/engine/Engine.java Thu Mar 6 00:12:29 2008
@@ -18,6 +18,7 @@
* TODO
*
* @param args
+ * @throws IOException
*/
public static void main(String[] args) throws IOException {


Modified: trunk/jgogears/jgogears/engine/Model.java
==============================================================================
--- trunk/jgogears/jgogears/engine/Model.java (original)
+++ trunk/jgogears/jgogears/engine/Model.java Thu Mar 6 00:12:29 2008
@@ -128,7 +128,7 @@
*
* @param board
* @param white
- * @return
+ * @return the array of scores
*/
public double[][] getScores(BoardI board, boolean white) {
short size = board.getSize();
@@ -138,7 +138,6 @@
for (short sym = 0; sym < 8; sym++) {
result[row][column] = 0.0;
Node node = this.getRoot();
- Node previous = this.getRoot();
int maxdepth = 0;
VertexLineariser linear = new VertexLineariser(board, row,
column, sym, white);
double estimate = 1.0;
@@ -172,7 +171,6 @@
if (child != null) {
childP = child.getPlayed();
childNP = child.getNotPlayed();
- previous = node;
node = child;
estimate = estimate * 0.5 + childP / (childP + childNP) * 0.5;
}
@@ -214,8 +212,8 @@
throw new Error();
int movecounter = 1;

- double strengthB = game.getBlackRank().getRating();
- double strengthW = game.getWhiteRank().getRating();
+ //double strengthB = game.getBlackRank().getRating();
+ //double strengthW = game.getWhiteRank().getRating();

while (boards.hasNext() && moves.hasNext()) {
movecounter++;
@@ -233,7 +231,7 @@
boolean isBlack = colour == BoardI.VERTEX_BLACK;
// float str = (float) (isBlack ? strengthB : strengthW);

- if (game != null || move != null || move.getPass()) {
+ if (game != null || move.getPass()) {
movecounter++;
for (short i = 0; i < size; i++)
for (short j = 0; j < size; j++)

Modified: trunk/jgogears/jgogears/engine/ModelTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/ModelTest.java (original)
+++ trunk/jgogears/jgogears/engine/ModelTest.java Thu Mar 6 00:12:29 2008
@@ -35,7 +35,6 @@
assertNotNull(files);

int filecount = 0;
- int movecount = 0;
assertNotNull(model);
Date start = new Date();
assertNotNull(start);
@@ -258,6 +257,7 @@
*/
public void testShowTree() throws IOException {
Node root = model.getRoot();
+ assertNotNull(root);
if (DEBUG)
System.err.println("ModelTest tree:");
// this.showTreeHelper(0, root);
@@ -382,20 +382,19 @@
if (node != null) {
assertFalse(nodeSet.contains(node));
nodeSet.add(node);
+ if (node.getBlack() != null) {
+ nodes.push(node.getBlack());
+ }
+ if (node.getWhite() != null) {
+ nodes.push(node.getWhite());
+ }
+ if (node.getEmpty() != null) {
+ nodes.push(node.getEmpty());
+ }
+ if (node.getOff() != null) {
+ nodes.push(node.getOff());
+ }
}
- if (node.getBlack() != null) {
- nodes.push(node.getBlack());
- }
- if (node.getWhite() != null) {
- nodes.push(node.getWhite());
- }
- if (node.getEmpty() != null) {
- nodes.push(node.getEmpty());
- }
- if (node.getOff() != null) {
- nodes.push(node.getOff());
- }
-
}
}

@@ -403,7 +402,7 @@
* Test trivial.
*/
public void testTrivial() {
- Model model = new Model();
+ model = new Model();
assertNotNull(model);
}


Modified: trunk/jgogears/jgogears/engine/Node.java
==============================================================================
--- trunk/jgogears/jgogears/engine/Node.java (original)
+++ trunk/jgogears/jgogears/engine/Node.java Thu Mar 6 00:12:29 2008
@@ -83,8 +83,17 @@
public final Node getEmpty() {
return this.empty;
}
-
- public Node getLeaf(BoardI board, short colour, short row, short
column, short sym, Node 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;
@@ -93,11 +102,17 @@
linear = new VertexLineariser(board, row, column, sym, invert);
if (!linear.hasNext())
throw new Error();
- return this.getLeaf(linear, node);
+ 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
+ */

- public Node getLeaf(VertexLineariser linear, Node node) {
+ static public Node getLeaf(VertexLineariser linear, Node node) {
if (!linear.hasNext())
throw new Error();

@@ -129,9 +144,9 @@
}

/**
- * get the notplayed
+ * how many times has this node not been played?
*
- * @return the notplayed
+ * @return the number of times has this node not been played?
*/
public final long getNotPlayed() {
return this.notPlayed;
@@ -147,9 +162,9 @@
}

/**
- * get the played
+ * how many times has this node been played?
*
- * @return the 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 Thu Mar 6 00:12:29 2008
@@ -25,7 +25,9 @@
parent.setBlack(null);
assertNull(parent.getBlack());
}
-
+ /**
+ *
+ */
public void testGetCount() {
Node node = new Node();
Node node2 = new Node();
@@ -104,7 +106,9 @@
parent.setBlack(null);
assertNull(parent.getBlack());
}
-
+ /**
+ *
+ */
public void testSetCount() {
Node node = new Node();
Node node2 = new Node();

Modified: trunk/jgogears/jgogears/engine/VertexLineariser.java
==============================================================================
--- trunk/jgogears/jgogears/engine/VertexLineariser.java (original)
+++ trunk/jgogears/jgogears/engine/VertexLineariser.java Thu Mar 6
00:12:29 2008
@@ -55,6 +55,8 @@
* the column
* @param sym
* the sym
+ * @param invert
+ * are we inverting the colour?
*/
public VertexLineariser(BoardI board, short row, short column, short
sym, boolean invert) {
this.board = board;
@@ -66,7 +68,7 @@
if (this.board.getSize() != BOARD_SIZE)
throw new IllegalArgumentException("only boards of BOARD_SIZE " +
BOARD_SIZE + " please");
if (cache == null)
- this.init();
+ init();
this.check();
}

@@ -102,7 +104,7 @@
*
* @return true, if successful
*/
- boolean init() {
+ static boolean init() {
if (cache == null) {
cache = new short[2][8][SIZE][SIZE][SIZE * SIZE];
for (int n = 0; n < 2; n++)

Modified: trunk/jgogears/jgogears/engine/VertexLineariserTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/VertexLineariserTest.java (original)
+++ trunk/jgogears/jgogears/engine/VertexLineariserTest.java Thu Mar 6
00:12:29 2008
@@ -95,6 +95,8 @@
Short b = linearb.next();
assertTrue(a != null);
assertTrue(b != null);
+ if (a == null || b == null)
+ throw new Error();
if (!a.equals(b))
differenceFound = true;
}
@@ -128,6 +130,8 @@
Short b = linearb.next();
assertTrue(a != null);
assertTrue(b != null);
+ if (a == null || b == null)
+ throw new Error();
if (!a.equals(b))
differenceFound = true;
}
@@ -403,6 +407,8 @@
assertTrue(parser.toString().length() > 0);

assertTrue(tree != null);
+ if (tree == null)
+ throw new Error();
assertTrue(tree.toString() != null);
assertTrue(tree.toString().length() > 0);

@@ -411,7 +417,8 @@

Iterator<BoardI> iterator = game.getBoards();
assertTrue(iterator != null);
-
+ if (iterator == null)
+ throw new Error();
BoardI board = null;
while (iterator.hasNext()) {
board = iterator.next();
@@ -472,6 +479,8 @@
assertTrue(lineara != null);
Short a = lineara.next();
assertTrue(a != null);
+ if (a == null )
+ throw new Error();
assertTrue(a + " " + BoardI.VERTEX_WHITE + "\n" + board,
a.equals(new Short(BoardI.VERTEX_WHITE)));
}
}
@@ -505,6 +514,8 @@
assertTrue(lineara != null);
Short a = lineara.next();
assertTrue(a != null);
+ if (a == null)
+ throw new Error();
assertTrue(a + " " + board.getColour(row, column) + "\n" + board,
a.equals(new Short(board
.getColour(row, column))));
}

Reply all
Reply to author
Forward
0 new messages