Initial commit.
This commit is contained in:
96
test/cs6601/p1/StateEvaluatorTest.java
Normal file
96
test/cs6601/p1/StateEvaluatorTest.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package cs6601.p1;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import cs6601.p1.generator.AlphaBetaMoveGenerator;
|
||||
import cs6601.p1.generator.MoveGenerator;
|
||||
|
||||
public class StateEvaluatorTest {
|
||||
GameConfig gameConfig = new GameConfig();
|
||||
|
||||
@Test
|
||||
public void testScoreEmptyBoard() {
|
||||
GameState gameState = new GameState(5);
|
||||
GameScore gameScore = new StateEvaluator(gameConfig).scoreGame(gameState);
|
||||
|
||||
assertEquals(0.0,gameScore.getWhiteScore(),0.5);
|
||||
assertEquals(0.0,gameScore.getBlackScore(),0.5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScoreFirstMove() {
|
||||
GameState gameState = new GameState(5);
|
||||
gameState.playStone('B',3,GameBoard.BLACK_STONE);
|
||||
|
||||
GameScore gameScore = new StateEvaluator(gameConfig).scoreGame(gameState);
|
||||
|
||||
System.out.println(gameScore.getScoreReport());
|
||||
|
||||
assertEquals(0.0,gameScore.getWhiteScore(),0.5);
|
||||
assertEquals(25.0,gameScore.getBlackScore(),0.5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScoreTiedAtMove2() {
|
||||
GameState gameState = new GameState(5);
|
||||
|
||||
gameState.playStone('B',3,GameBoard.BLACK_STONE);
|
||||
gameState.playStone('A',1,GameBoard.WHITE_STONE);
|
||||
GameScore gameScore = new StateEvaluator(gameConfig).scoreGame(gameState);
|
||||
|
||||
System.out.println(gameScore.getScoreReport());
|
||||
|
||||
assertEquals(1.0,gameScore.getWhiteScore(),0.5);
|
||||
assertEquals(1.0,gameScore.getBlackScore(),0.5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScoreTerritory() {
|
||||
GameState gameState = new GameState(5);
|
||||
|
||||
gameState.playStone('A',2,GameBoard.BLACK_STONE);
|
||||
gameState.playStone('B',3,GameBoard.BLACK_STONE);
|
||||
gameState.playStone('C',2,GameBoard.BLACK_STONE);
|
||||
gameState.playStone('B',1,GameBoard.BLACK_STONE);
|
||||
gameState.playStone('E',5,GameBoard.WHITE_STONE);
|
||||
|
||||
System.out.println(gameState);
|
||||
GameScore gameScore = new StateEvaluator(gameConfig).scoreGame(gameState);
|
||||
|
||||
System.out.println(gameScore.getScoreReport());
|
||||
|
||||
assertEquals(1.0,gameScore.getWhiteScore(),0.5);
|
||||
assertEquals(6.0,gameScore.getBlackScore(),0.5);
|
||||
//Black should be up by 5 if Black's territory at A1 & B2 is scored correctly.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCaptureAggScore() {
|
||||
GameState gameState = new GameState(9);
|
||||
gameState.playStone('A', 2, GameBoard.WHITE_STONE);
|
||||
gameState.playStone('B', 1, GameBoard.WHITE_STONE);
|
||||
gameState.playStone('C', 2, GameBoard.WHITE_STONE);
|
||||
gameState.playStone('B', 2, GameBoard.BLACK_STONE);
|
||||
|
||||
GameState moveToA1 = new GameState(gameState);
|
||||
GameState capAtB3 = new GameState(gameState);
|
||||
|
||||
moveToA1.playStone("w","A1");
|
||||
capAtB3.playStone("w", "B3");
|
||||
|
||||
System.out.println(moveToA1);
|
||||
System.out.println(capAtB3);
|
||||
|
||||
StateEvaluator eval = new StateEvaluator(new GameConfig());
|
||||
int scoreA1 = eval.scoreGame(moveToA1).getAggregateScore();
|
||||
int scoreB3 = eval.scoreGame(capAtB3).getAggregateScore();
|
||||
|
||||
System.out.println("Score at A1: " + scoreA1);
|
||||
System.out.println("Score at B3: " + scoreB3);
|
||||
//moving as white, lower is better
|
||||
assertTrue(scoreA1 > scoreB3);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user