Substantial refactoring to implement correct Naive, UCT Monte Carlo tree search methods.
Removed unnecessary distinction between policy and tree search (tree search is a special kind of policy). Calculation of all valid moves / arbitrary sets of moves is now a seperate class, as it serves a different purpose than a policy. Introduced regression error in AlphaBeta test.
This commit is contained in:
34
test/net/woodyfolsom/msproj/policy/MinimaxTest.java
Normal file
34
test/net/woodyfolsom/msproj/policy/MinimaxTest.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package net.woodyfolsom.msproj.policy;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import net.woodyfolsom.msproj.GameBoard;
|
||||
import net.woodyfolsom.msproj.GameConfig;
|
||||
import net.woodyfolsom.msproj.GameState;
|
||||
import net.woodyfolsom.msproj.policy.Policy;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class MinimaxTest {
|
||||
|
||||
@Test
|
||||
public void testGenmove() {
|
||||
Policy moveGenerator = new Minimax();
|
||||
GameState gameState = new GameState(5);
|
||||
gameState.playStone('A', 2, GameBoard.BLACK_STONE);
|
||||
gameState.playStone('B', 1, GameBoard.BLACK_STONE);
|
||||
gameState.playStone('C', 2, GameBoard.BLACK_STONE);
|
||||
gameState.playStone('B', 4, GameBoard.BLACK_STONE);
|
||||
|
||||
String move = moveGenerator.getAction(new GameConfig(), gameState, "w");
|
||||
System.out.println("Generated move: " + move);
|
||||
gameState.playStone("w", move);
|
||||
|
||||
System.out.println(gameState);
|
||||
|
||||
assertEquals(Policy.PASS,moveGenerator.getAction(new GameConfig(), gameState, "?"));
|
||||
|
||||
System.out.println(gameState);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user