Files
cs6601p1/test/net/woodyfolsom/msproj/policy/MinimaxTest.java
cs6601 4a1c64843d Fixed Minimax search to use the new GameTreeNode, MinimaxProperty classes.
The previous implementation was overly complicated and may have been buggy except when searching only 2 plies ahead.
2012-08-30 10:51:04 -04:00

53 lines
1.7 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 org.junit.Test;
public class MinimaxTest {
@Test
public void testGenmoveAsW() {
Policy treeSearch = new Minimax();
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);
assertEquals("Expected B3 but was: " + move, Action.getInstance("B3"), move);
gameState.playStone(Player.WHITE, move);
System.out.println(gameState);
}
@Test
public void testGenmoveAsB() {
Policy treeSearch = new Minimax();
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);
assertEquals("Expected B3 but was: " + move, Action.getInstance("B3"), move);
gameState.playStone(Player.BLACK, move);
System.out.println(gameState);
}
}