// Return the bot chosen movement with the calculated expected outcome.
 public (int result, (int, int) pos) GetBotMove()
 {
     WriteLine("Bot deciding next movement..");
     var(res, pos) = b.GetNextMove(this.Game.board, this.Game.NumberOfMovementsDone, Game.SearchDepth, Game.Bot_Token
                                   , Game.Opponent_Token);
     this.Game.NumberOfMovementsDone++;
     this.Game.board[pos.row, pos.column] = Game.Bot_Token;
     Game.MovementsDone.Add(pos);
     return(res, pos);
 }
Exemple #2
0
        public void TestForAnEasyWin()
        {
            int[,] board =
            {
                { 0, 1, -1, -1 },
                { 0, 1,  0, -1 },
                { 1, 1,  0,  0 },
                { 0, 0,  1,  1 },
                { 0, 1,  1,  1 }
            };
            var rules = new NInARowBoardGameRules();

            TestContext.Out.Write($"TestForAEasyWin.\nInitial Board\n{board.ConvertToStringImproved()}");
            MatrixBoardGameMiniMax b = new MatrixBoardGameMiniMax(rules);

            var(result, pos)           = b.GetNextMove(board, 17, 8, 0, 1);
            board[pos.row, pos.column] = 0;
            TestContext.Out.Write($"Board After move\n{board.ConvertToStringImproved()}");
            Assert.AreEqual(result, int.MaxValue);
        }
Exemple #3
0
        public void TestAvoidLossing()
        {
            var testName = TestContext.CurrentContext.Test.Name;

            int[,] board =
            {
                { 0, -1, 1, -1 },
                { 0,  1, 0, -1 },
                { 1,  1, 0,  0 },
                { 0,  1, 0,  1 },
                { 0,  0, 1,  1 }
            };
            var rules = new NInARowBoardGameRules();

            TestContext.Out.Write($"{testName}.\nInitial Board\n{board.ConvertToStringImproved()}");
            MatrixBoardGameMiniMax b = new MatrixBoardGameMiniMax(rules);

            var(result, pos)            = b.GetNextMove(board, 17, 8, 0, 1);
            board[pos.Item1, pos.Item2] = 0;
            TestContext.Out.Write($"Board After move\n{board.ConvertToStringImproved()}");
            Assert.AreEqual(0, result);
        }