Root_par beats GoFree!
This commit is contained in:
@@ -3,38 +3,15 @@ package net.woodyfolsom.msproj;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.woodyfolsom.msproj.GameResult;
|
||||
import net.woodyfolsom.msproj.policy.MonteCarloUCT;
|
||||
import net.woodyfolsom.msproj.policy.RandomMovePolicy;
|
||||
import net.woodyfolsom.msproj.policy.RootParallelization;
|
||||
import net.woodyfolsom.msproj.sgf.SGFLexer;
|
||||
import net.woodyfolsom.msproj.sgf.SGFNodeCollection;
|
||||
import net.woodyfolsom.msproj.sgf.SGFParser;
|
||||
|
||||
import org.antlr.runtime.ANTLRInputStream;
|
||||
import org.antlr.runtime.ANTLRStringStream;
|
||||
import org.antlr.runtime.CommonTokenStream;
|
||||
import org.antlr.runtime.RecognitionException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GameScoreTest {
|
||||
|
||||
// public static final String endGameSGF =
|
||||
// "(;FF[4]GM[1]SZ[9]KM[5.5];B[ef];W[ff];B[dg];W[aa];B[fc];W[da];B[cg];W[ei];B[gf]"
|
||||
// +
|
||||
// ";W[fi];B[ag];W[ii];B[bi];W[if];B[db];W[ci];B[cf];W[ih];B[bc];W[hb];B[eb];W[fh];B[ig];W[hc];B[be];W[he];B[gc];"
|
||||
// +
|
||||
// "W[id];B[cd];W[df];B[hf];W[ah];B[bh];W[fa];B[bg];W[fe];B[ec];W[eh];B[ee];W[bd];B[hg];W[ie];B[fg];W[ca];B[eg];"
|
||||
// +
|
||||
// "W[cb];B[ad];W[ba];B[ch];W[dh];B[gd];W[ic];B[ha];W[ab];B[gh];W[gb];B[ed];W[];B[])";
|
||||
|
||||
//public static final String endGameSGF = "(;FF[4]GM[1]SZ[9]KM[5.5]RE[W+0.5];B[ef];W[cb];B[fe];W[da];B[cd];W[hh];B[ed];W[cc];B[ci];W[bc];B[cg];W[fi];B[be];W[ea];B[hi];W[df];B[fd];W[bg];B[cf];W[aa];B[gd];W[ch];B[ad];W[dg];B[de];W[ge];B[bh];W[fa];B[ag];W[hd];B[if];W[bi];B[gf];W[bd];B[ah];W[gc];B[ff];W[ca];B[hf];W[dd];B[ce];W[ae];B[ga];W[hc];B[ac];W[gg];B[fg];W[fb];B[ie];W[dh];B[af];W[ec];B[dc];W[id];B[dd];W[eh];B[eb];W[gb];B[ae];W[ic];B[di];W[fh];B[ig];W[ab];B[ha];W[hg];B[hb];W[gi];B[ii];W[ia];B[fc];W[ba];B[eg];W[];B[db];W[];B[])";
|
||||
|
||||
public static final String endGameSGF = "(;FF[4]GM[1]SZ[6]KM[1.5]RE[B+0.5];B[bb];W[];B[ec];W[ef];B[ac];W[ed];B[ba];W[dc];B[cf];W[];B[])";
|
||||
@Test
|
||||
public void testGetAggregateScoreZero() {
|
||||
GameResult gameScore = new GameResult(0, 0, 19, 0, true);
|
||||
@@ -56,21 +33,23 @@ public class GameScoreTest {
|
||||
|
||||
@Test
|
||||
public void testScoreEndGame() throws IOException, RecognitionException {
|
||||
InputStream is = new ByteArrayInputStream(endGameSGF.getBytes());
|
||||
GameRecord gameRecord = Referee.replay(is);
|
||||
assertEquals(11, gameRecord.getNumTurns());
|
||||
|
||||
GameState gameState9 = gameRecord.getGameState(9);
|
||||
//test case from:
|
||||
//http://www.online-go.com/faq.php?name=rules
|
||||
GameRecord gameRecord = Referee.replay(new FileInputStream(new File("data/test/ScoreTest.sgf")));
|
||||
GameState gameState = gameRecord.getGameState(gameRecord.getNumTurns());
|
||||
GameConfig gameConfig = gameState.getGameConfig();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
//Action action = new RootParallelization(4, 1000L).getAction(gameRecord.getGameConfig(), gameState9, Player.WHITE);
|
||||
Action action = new MonteCarloUCT(new RandomMovePolicy(),1000L).getAction(gameRecord.getGameConfig(), gameState9, Player.WHITE);
|
||||
System.out.println("Suggested action for "+Player.WHITE+": " + action);
|
||||
}
|
||||
System.out.println(gameState);
|
||||
System.out.println(gameState.getResult());
|
||||
|
||||
gameState9.playStone(Player.WHITE, Action.PASS);
|
||||
gameState9.playStone(Player.BLACK, Action.PASS);
|
||||
assertTrue(gameState9.isTerminal());
|
||||
System.out.println(gameState9.getResult());
|
||||
GameState gameStateCopy = new GameState(gameState);
|
||||
TerritoryMarker.markTerritory(gameStateCopy.getGameBoard());
|
||||
System.out.println(gameStateCopy);
|
||||
|
||||
assertEquals(9,gameConfig.getSize());
|
||||
assertEquals(6.0,gameConfig.getKomi(),0.1);
|
||||
|
||||
assertTrue(gameState.isTerminal());
|
||||
assertTrue(gameState.getResult().isWinner(Player.WHITE));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user