Beispiel #1
0
        public void TestWinByNextMoveRowConditions()
        {
            var board = new StringBuilder("-XX------");
            var nextMoveSimulation = new GameNextMoveSimulator(board, 0, 'X');
            var winner             = nextMoveSimulation.GetWinner();

            Assert.AreEqual('X', winner);
        }
Beispiel #2
0
        public int Move(char player)
        {
            var defaultMove = -1;

            for (var i = 0; i < 9; i++)
            {
                if (_board[i] != '-')
                {
                    continue;
                }

                if (defaultMove == -1)
                {
                    defaultMove = i;
                }
                var nextMoveSimulation = new GameNextMoveSimulator(_board, i, player);
                if (nextMoveSimulation.GetWinner() == player)
                {
                    return(i);
                }
            }

            return(defaultMove);
        }