Updated RandomMoveGenerator to support MonteCarloUCT.

Now possible to prohibit a Collection of Actions from being included in the List of returned actions (or as a single returned value).
All unit tests now pass with the exception of MonteCarloUCT.

TODO: playerToMove and previousPlayerPassed should be made part of the GameState.
This would remove the superfluous Player parameter from many methods and make it possible
to check for the "I'm ahead and my opponent is offering to end the game" killer move.
This commit is contained in:
cs6601
2012-08-31 09:17:43 -04:00
parent 4a1c64843d
commit d3c03f2c51
17 changed files with 453 additions and 257 deletions

View File

@@ -23,7 +23,9 @@ public class AlphaBetaTest {
System.out.println(gameState);
System.out.println("Generated move: " + move);
assertEquals("Expected B3 but was: " + move, Action.getInstance("B3"), move);
System.out.println("NumStateEvaluations: " + treeSearch.getNumStateEvaluations());
assertEquals(Action.getInstance("B3"), move);
gameState.playStone(Player.WHITE, move);
System.out.println("Final board state:");
System.out.println(gameState);
@@ -43,6 +45,8 @@ public class AlphaBetaTest {
System.out.println(gameState);
System.out.println("Generated move: " + move);
System.out.println("NumStateEvaluations: " + treeSearch.getNumStateEvaluations());
assertEquals("Expected B3 but was: " + move, Action.getInstance("B3"), move);
gameState.playStone(Player.BLACK, move);

View File

@@ -24,7 +24,9 @@ public class MinimaxTest {
System.out.println(gameState);
System.out.println("Generated move: " + move);
assertEquals("Expected B3 but was: " + move, Action.getInstance("B3"), move);
System.out.println("NumStateEvaluations: " + treeSearch.getNumStateEvaluations());
assertEquals(Action.getInstance("B3"), move);
gameState.playStone(Player.WHITE, move);
System.out.println(gameState);
@@ -45,6 +47,8 @@ public class MinimaxTest {
System.out.println(gameState);
System.out.println("Generated move: " + move);
System.out.println("NumStateEvaluations: " + treeSearch.getNumStateEvaluations());
assertEquals("Expected B3 but was: " + move, Action.getInstance("B3"), move);
gameState.playStone(Player.BLACK, move);

View File

@@ -25,6 +25,8 @@ public class MonteCarloUCTTest {
System.out.println(gameState);
System.out.println("Generated move: " + move);
System.out.println("NumStateEvaluations: " + treeSearch.getNumStateEvaluations());
assertEquals("Expected B3 but was: " + move, "B3", move);
gameState.playStone(Player.WHITE, move);
@@ -45,6 +47,8 @@ public class MonteCarloUCTTest {
System.out.println(gameState);
System.out.println("Generated move: " + move);
System.out.println("NumStateEvaluations: " + treeSearch.getNumStateEvaluations());
assertEquals("Expected B3 but was: " + move, "B3", move);
gameState.playStone(Player.BLACK, move);

View File

@@ -1,6 +1,10 @@
package net.woodyfolsom.msproj.policy;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import net.woodyfolsom.msproj.Action;
import net.woodyfolsom.msproj.GameConfig;
import net.woodyfolsom.msproj.GameState;
@@ -49,7 +53,11 @@ public class RandomTest {
System.out.println("State before random WHITE move selection:");
System.out.println(gameState);
//This is correct - checked vs. MFOG
assertEquals(Action.getInstance("B3"), new RandomMovePolicy().getAction(new GameConfig(), gameState, Player.WHITE));
//PASS would otherwise be a valid move
List<Action> prohibitedMoves = new ArrayList<Action>();
prohibitedMoves.add(Action.PASS);
assertEquals(Action.getInstance("B3"), new RandomMovePolicy().getAction(new GameConfig(), gameState, prohibitedMoves, Player.WHITE));
System.out.println(gameState);
}