Esempio n. 1
0
        public void Minimax_Xwin()
        {
            var boardString = "X.X|XXX|.XX|OXX|O..|OOO|OXO|..O|.OO|OXX|OOO|XOO|XXX|OX.|.XX|.O.|O..|OO.|O..|OOO|.OX|XXX|...|...|..O|XXO|XXX";
            var macroboard  = "AXO|XOA|XOX";

            var bot   = new SmartBot();
            var state = new BotState();

            state.Field.MyId = 0;
            state.UltimateBoard.ParseFromString(boardString);
            state.UltimateBoard.ParseMacroboardFromString(macroboard);

            // X should be placed in top-left microboard so X wins macroboard on vert left
            Move move = bot.GetMove(state);

            // More moves available in center-right of microboard
            Assert.IsTrue(move.X == 1 && move.Y == 0, "Actual move is " + move);
        }
Esempio n. 2
0
        public void Minimax_Owin()
        {
            var boardString = "X.O|OO.|.XX|OXX|O..|OOO|OXO|..O|.OO|OXX|OOO|XOO|XXX|OX.|.XX|.O.|O..|OO.|O..|OOO|.OX|XXX|...|...|..O|XXO|XXX";
            var macroboard  = "AXO|XO.|XOX";

            var bot   = new SmartBot();
            var state = new BotState();

            state.Field.MyId = 0;
            state.UltimateBoard.ParseFromString(boardString);
            state.UltimateBoard.ParseMacroboardFromString(macroboard);

            // X should be placed in top-left microboard since it's the only spot
            // open, then O should win top-middle microboard to win macroboard vert middle
            Move move = bot.GetMove(state);

            // More moves available in center-right of microboard
            Assert.IsTrue(move.X == 1 && move.Y == 0, "Actual move is " + move);
        }
Esempio n. 3
0
        public void GetMove_FirstMoveBlankBoard()
        {
            var boardString = "...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...|...";
            var macroboard  = "AAA|AAA|AAA";

            var bot   = new SmartBot();
            var state = new BotState();

            state.Field.MyId = 1;
            state.UltimateBoard.ParseFromString(boardString);
            state.UltimateBoard.ParseMacroboardFromString(macroboard);

            Console.Write(state.UltimateBoard);

            Move move = bot.GetMove(state);

            // X moved to row 6 and col 7
            Assert.IsTrue(move.X == 1 && move.Y == 0 && move.Score == 0,
                          "Actual move is " + move + " and score = " + move.Score);
        }
Esempio n. 4
0
        public void Minimax_XWin()
        {
            var boardString = "OOO|OO.|.XX|OXX|O..|OOO|OXO|..O|.OO|OXX|OOO|.OO|XXX|OX.|OXX|.O.|O..|OXO|XOO|XXX|O.O|X.X|...|OXX|O.X|XXO|XXO";
            var macroboard  = "OOX|TOX|AXA";

            var bot   = new SmartBot();
            var state = new BotState();

            state.Field.MyId = 0;
            state.UltimateBoard.ParseFromString(boardString);
            state.UltimateBoard.ParseMacroboardFromString(macroboard);

            Console.Write(state.UltimateBoard);

            Move move = bot.GetMove(state);

            // X wins
            Assert.IsTrue(move.X == 7 && move.Y == 6 && move.Score == 100,
                          "Actual move is " + move + " and score = " + move.Score);
        }
Esempio n. 5
0
        public void Minimax_Xwin2()
        {
            var boardString = "OOO|OO.|.XX|OXX|O..|OOO|OXO|..O|.OO|OXX|OOO|.OO|XXX|OX.|OXX|.O.|O..|OXO|XOO|XXX|O.O|XX.|...|OX.|O.X|XXO|XXO";
            var macroboard  = "OOX|TO.|AX.";

            var bot   = new SmartBot();
            var state = new BotState();

            state.Field.MyId = 0;
            state.UltimateBoard.ParseFromString(boardString);
            state.UltimateBoard.ParseMacroboardFromString(macroboard);

            Console.Write(state.UltimateBoard);

            // X should be placed in [2,7] to win [0,2] microboard
            Move move = bot.GetMove(state);

            // More moves available in center-right of microboard
            Assert.IsTrue(move.X == 2 && move.Y == 7, "Actual move is " + move);
        }
Esempio n. 6
0
        public void Minimax_XLose2()
        {
            var boardString = "OOO|OO.|.XX|OXX|O..|OOO|OXO|..O|.OO|OXX|OOO|.OO|XXX|OX.|OXX|.O.|O..|OXO|XOO|XXX|O.O|X.X|...|OXX|O.X|XXO|XXO";
            var macroboard  = "OOX|TOA|.X.";

            var bot   = new SmartBot();
            var state = new BotState();

            state.Field.MyId = 0;
            state.UltimateBoard.ParseFromString(boardString);
            state.UltimateBoard.ParseMacroboardFromString(macroboard);

            Console.Write(state.UltimateBoard);

            // X can't win, so [1,7] is chosen first
            Move move = bot.GetMove(state);

            // X loses
            Assert.IsTrue(move.X == 6 && move.Y == 3 && move.Score == -100,
                          "Actual move is " + move + " and score = " + move.Score);
        }