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

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 10, 2008, 6:30:04 PM3/10/08
to jgog...@googlegroups.com
Author: syeates
Date: Mon Mar 10 15:30:00 2008
New Revision: 61

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

Log:
add comparison function to double comparisions

Modified: trunk/jgogears/jgogears/engine/ModelTest.java
==============================================================================
--- trunk/jgogears/jgogears/engine/ModelTest.java (original)
+++ trunk/jgogears/jgogears/engine/ModelTest.java Mon Mar 10 15:30:00 2008
@@ -17,6 +17,10 @@

/** The model. */
static Model model = null;
+
+ boolean compare(double first,double second){
+ return ((float)first) == ((float)second);
+ }

/**
* Instantiates a new model test.
@@ -27,7 +31,7 @@
public ModelTest() throws IOException {
if (model == null) {
model = new Model();
- new Trainer().train(10, model);
+ new Trainer().train(2, model);
}
}

@@ -113,6 +117,7 @@
* Signals that an I/O exception has occurred.
*/
public void testEmptyModelEmptyBoard() throws IOException {
+ Model model = new Model(); // yes, this overrides an instance variable
assertNotNull(model);
BoardI board = BoardI.newBoard();
double[][] r = new Scorer().getScores(model, board, false);
@@ -129,11 +134,11 @@
for (int j = 0; j < r[i].length; j++) {
assertTrue(i + " " + j + " " + r[i][j] + " " + r[j][i], r[i][j] == r[j][i]);
assertTrue(i + " " + j + " " + r[i][j] + " " + r[r.length - i -
1][r.length - j - 1],
- r[i][j] == r[r.length - i - 1][r.length - j - 1]);
+ this.compare(r[i][j] , r[r.length - i - 1][r.length - j - 1]));
assertTrue(i + " " + j + " " + r[i][j] + " " + r[r.length - i - 1][j],
- r[i][j] == r[r.length - i - 1][j]);
+ this.compare(r[i][j] , r[r.length - i - 1][j]));
assertTrue(i + " " + j + " " + r[i][j] + " " + r[i][r.length - j - 1],
- r[i][j] == r[i][r.length - j - 1]);
+ this.compare(r[i][j] , r[i][r.length - j - 1]));
}
}

@@ -277,11 +282,11 @@
for (int j = 0; j < r[i].length; j++) {
assertTrue(i + " " + j + " " + r[i][j] + " " + r[j][i], r[i][j] == r[j][i]);
assertTrue(i + " " + j + " " + r[i][j] + " " + r[r.length - i -
1][r.length - j - 1],
- r[i][j] == r[r.length - i - 1][r.length - j - 1]);
+ this.compare(r[i][j], r[r.length - i - 1][r.length - j - 1]));
assertTrue(i + " " + j + " " + r[i][j] + " " + r[r.length - i - 1][j],
- r[i][j] == r[r.length - i - 1][j]);
+ this.compare(r[i][j] , r[r.length - i - 1][j]));
assertTrue(i + " " + j + " " + r[i][j] + " " + r[i][r.length - j - 1],
- r[i][j] == r[i][r.length - j - 1]);
+ this.compare(r[i][j] , r[i][r.length - j - 1]));
}
}

Reply all
Reply to author
Forward
0 new messages