public void ScoreCacheTest() { var board = new Player[20, 20]; board[10, 10] = board[10, 11] = board[11, 10] = board[9, 11] = board[9, 6] = board[12, 9] = board[12, 11] = board[11, 11] = Player.Own; board[9, 10] = board[9, 9] = board[9, 8] = board[9, 7] = board[10, 8] = board[13, 8] = board[13, 11] = board[8, 11] = Player.Opponent; AlphaBetaEngine engine = new AlphaBetaEngine(new Board(board)); engine.HasNoTimeLimit(); engine.HasForbiddenPlayer = Player.Own; engine.InitializeSearch(); for (int i = 1; i <= 5; i++) { engine.AlphaBetaSearch(i); } engine.SelfMove((12, 10)); engine.OpponentMove((12, 8)); engine.InitializeSearch(); var score = engine.AlphaBetaSearch(3); // this will possibly use score cache from previous search Assert.Equal(-Evaluator.MaxScore, score); }
public void SearchToLoss() { var board = new Player[10, 10]; board[2, 2] = board[3, 2] = board[4, 2] = board[5, 2] = Player.Opponent; AlphaBetaEngine engine = new AlphaBetaEngine(new Board(board)); engine.HasNoTimeLimit(); engine.InitializeSearch(); var score = engine.AlphaBetaSearch(3); Assert.Equal(-Evaluator.MaxScore, score); }
public void SearchToScore() { PatternTable patternTable = new PatternTable(); patternTable["_ _ o o o * _ _ _ _".ToPatternPair()] = 100; var board = new Player[10, 10]; board[2, 2] = board[3, 2] = board[5, 2] = Player.Own; AlphaBetaEngine engine = new AlphaBetaEngine(new Board(board), patternTable); engine.HasNoTimeLimit(); engine.InitializeSearch(); var score = engine.AlphaBetaSearch(2); Assert.Equal(100, score); }