public void DynamicDeepeningSequentialTest_7() { // ARRANGE var sourceBoardStr = new[] { "_b_b_b", "______", "___w_b", "______", "______", "______" }; var sourceBoard = new BoardMock(sourceBoardStr, 6, false); sourceBoard.SwitchPlayers(); var root = new GameNode(); root.IsMaxPlayer = false; var practiceBoard = sourceBoard.ToMinified(); var(result, maxPly) = _wrapper.Run(practiceBoard, root, sbyte.MinValue, sbyte.MaxValue, 3, _cts.Token); var bestMove = result.Peek().Move; bestMove.From.Should().BeEquivalentTo(new Cell(1, 0)); bestMove.To.Should().BeEquivalentTo(new Cell(0, 1)); }
public void DynamicTreeSplittingSearchTest_7() { // ARRANGE var sourceBoardStr = new[] { "_b_b_b", "______", "___w_b", "______", "______", "______" }; var sourceBoard = new BoardMock(sourceBoardStr, 6, false); sourceBoard.SwitchPlayers(); var root = new GameNode(); root.IsMaxPlayer = false; var practiceBoard = sourceBoard.ToMinified(); _search.Search(root, 3, sbyte.MinValue, sbyte.MaxValue, practiceBoard, _cts.Token); var bestMove = root.GetBestMove(); root.Result.Should().Be(sbyte.MinValue); bestMove.Should().BeEquivalentTo(new Move(1, 0, 0, 1)); }
public void GlobalSetup() { _search1 = ServiceLocator.CreateSerialGameTreeSearch(); _search2 = ServiceLocator.CreateDynamicTreeSplittingGameTreeSearch(); _wrapper1 = ServiceLocator.CreateProgressiveDeepeningWrapper(_search1); _wrapper2 = ServiceLocator.CreateProgressiveDeepeningWrapper(_search2); var sourceBoardStr = new[] { "_b_b_b", "b_b_b_", "______", "______", "_w_w_w", "w_w_w_" }; var sourceBoard1 = new BoardMock(sourceBoardStr, 6, false); var sourceBoard2 = new BoardMock(sourceBoardStr, 6, false); _practiceBoard1 = sourceBoard1.ToMinified(); _practiceBoard2 = sourceBoard2.ToMinified(); _cts = new CancellationTokenSource(); _node1 = new GameNode(); _node2 = new GameNode(); }
public void StateTransitionsTest_1() { // ARRANGE var sourceBoardStr = new[] { "____", "____", "__b_", "_w__" }; var sourceBoard = new BoardMock(sourceBoardStr, 4, false); sourceBoard.SwitchPlayers(); var targetBoardStr = new[] { "____", "____", "__b_", "_w__" }; var targetBoard = new BoardMock(targetBoardStr, 4, false); var practiceBoardSource = sourceBoard.ToMinified(); practiceBoardSource.ActivePlayer = true; var practiceBoardTarget = targetBoard.ToMinified(); var gameNode = new GameNode(); gameNode.Move = new HistoryItemMinified(new Cell(1, 3), new Cell(3, 1), true); practiceBoardSource = _stateTransitions.GoDown(practiceBoardSource, gameNode); practiceBoardSource = _stateTransitions.GoUp(practiceBoardSource, gameNode); practiceBoardSource.ClearMoves(); var pieceSource = (PieceMinified)practiceBoardSource.Player1Pieces[0]; var pieceTarget = (PieceMinified)practiceBoardTarget.Player1Pieces[0]; pieceSource.Should().BeEquivalentTo(pieceTarget); pieceSource.Should().BeEquivalentTo(pieceTarget); }
public void DynamicTreeSplittingSearchTest_1() { var sourceBoardStr = new[] { "B___", "____", "__w_", "____" }; var sourceBoard = new BoardMock(sourceBoardStr, 4, false); var root = new GameNode(); var practiceBoard = sourceBoard.ToMinified(); _search.Search(root, 2, sbyte.MinValue, sbyte.MaxValue, practiceBoard, _cts.Token); var bestMove = root.GetBestMove(); bestMove.Should().BeEquivalentTo(new Move(2, 2, 3, 1)); }
public void DynamicDeepeningSequentialTest_1() { var sourceBoardStr = new[] { "B___", "____", "__w_", "____" }; var sourceBoard = new BoardMock(sourceBoardStr, 4, false); var root = new GameNode(); var practiceBoard = sourceBoard.ToMinified(); var(result, maxPly) = _wrapper.Run(practiceBoard, root, sbyte.MinValue, sbyte.MaxValue, 2, _cts.Token); var bestMove = result.Peek().Move; bestMove.From.Should().BeEquivalentTo(new Cell(2, 2)); bestMove.To.Should().BeEquivalentTo(new Cell(3, 1)); }
public void GameTreeSequentialSearch_3() { // ARRANGE var sourceBoardStr = new[] { "b_b_", "____", "____", "_w_w" }; var sourceBoard = new BoardMock(sourceBoardStr, 4, false); var root = new GameNode(); var practiceBoard = sourceBoard.ToMinified(); _search.Search(root, 12, sbyte.MinValue, sbyte.MaxValue, practiceBoard, _cts.Token); var bestMove = root.GetBestMove(); bestMove.Should().BeEquivalentTo(new Move(3, 3, 2, 2)); }
public void GameTreeSequentialSearch_6() { // ARRANGE var sourceBoardStr = new[] { "______", "______", "______", "w_b___", "______", "w_w_w_" }; var sourceBoard = new BoardMock(sourceBoardStr, 6, false); var root = new GameNode(); var practiceBoard = sourceBoard.ToMinified(); _search.Search(root, 3, sbyte.MinValue, sbyte.MaxValue, practiceBoard, _cts.Token); var bestMove = root.GetBestMove(); root.Result.Should().Be(sbyte.MaxValue); bestMove.Should().BeEquivalentTo(new Move(2, 5, 3, 4)); }