Files
msproj/test/net/woodyfolsom/msproj/policy/MonteCarloUCTTest.java
cs6601 d3c03f2c51 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.
2012-08-31 09:17:43 -04:00

57 lines
2.0 KiB
Java

package net.woodyfolsom.msproj.policy;
import static org.junit.Assert.assertEquals;
import net.woodyfolsom.msproj.Action;
import net.woodyfolsom.msproj.GameConfig;
import net.woodyfolsom.msproj.GameState;
import net.woodyfolsom.msproj.Player;
import net.woodyfolsom.msproj.policy.Policy;
import org.junit.Test;
public class MonteCarloUCTTest {
@Test
public void testGenmoveAsW() {
Policy treeSearch = new MonteCarloUCT(new RandomMovePolicy(),2000L);
GameState gameState = new GameState(6);
gameState.playStone(Player.WHITE, Action.getInstance("A2"));
gameState.playStone(Player.WHITE, Action.getInstance("B1"));
gameState.playStone(Player.WHITE, Action.getInstance("C2"));
gameState.playStone(Player.BLACK, Action.getInstance("B2"));
Action move = treeSearch.getAction(new GameConfig(), gameState, Player.WHITE);
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);
System.out.println(gameState);
}
@Test
public void testGenmoveAsB() {
Policy treeSearch = new MonteCarloUCT(new RandomMovePolicy(),2000L);
GameState gameState = new GameState(6);
gameState.playStone(Player.BLACK, Action.getInstance("A2"));
gameState.playStone(Player.BLACK, Action.getInstance("B1"));
gameState.playStone(Player.BLACK, Action.getInstance("C2"));
gameState.playStone(Player.WHITE, Action.getInstance("B2"));
Action move = treeSearch.getAction(new GameConfig(), gameState, Player.BLACK);
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);
System.out.println(gameState);
}
}