public void TestDiagonale()
        {
            var state = new TicTacTocState(3);
            Assert.IsFalse(state.IsGameOver());

            IToken token = new Token(1, 'X');
            IToken tokenEnnemy = new Token(2, 'O');

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 0,
                Token = token
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 1,
                Y = 1,
                Token = token
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 2,
                Y = 2,
                Token = token
            });

            Assert.IsTrue(state.IsGameOver());
        }
        public void AccessibleStateTest()
        {
            var state = new TicTacTocState(2);
            Assert.IsFalse(state.IsGameOver());

            IToken token = new Token(1, 'X');
            ITeamIdentifier player = new HumanPlayer(token, 1);

            var list = state.GetPossibleStates(player);

            Assert.AreEqual(4, list.Count);

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 0,
                Token = token
            });

            list = state.GetPossibleStates(player);
            Assert.AreEqual(3, list.Count);
        }
        public void TestDiagonaleWithOponent()
        {
            var state = new TicTacTocState(3);
            Assert.IsFalse(state.IsGameOver());

            IToken tokenX = new Token(1, 'X');
            ITeamIdentifier opponent = new IAPlayer(tokenX, 1);

            IToken tokenO = new Token(2, 'O');
            ITeamIdentifier player = new IAPlayer(tokenO, 2);

            state.PlayMove(new TicTacToeMove()
            {
                X = 2,
                Y = 0,
                Token = tokenX
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 2,
                Token = tokenX
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 0,
                Token = tokenO
            });
            state.PlayMove(new TicTacToeMove()
            {
                X = 2,
                Y = 2,
                Token = tokenO
            });

            state.PlayMove(new TicTacToeMove()
            {
                X = 1,
                Y = 1,
                Token = tokenX
            });
            Assert.IsTrue(state.IsGameOver());
            Assert.AreEqual(1, state.GetValueFor(opponent));
            Assert.AreEqual(-1, state.GetValueFor(player));
        }
        public void TestVerticallWin()
        {
            var state = new TicTacTocState(3);
            Assert.IsFalse(state.IsGameOver());

            IToken token = new Token(1, 'X');

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 0,
                Token = token
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 1,
                Token = token
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 2,
                Token = token
            });

            Assert.IsTrue(state.IsGameOver());
        }
        public void NotLoosingTest()
        {
            var state = new TicTacTocState(3);

            IToken tokenY = new Token(2, 'Y');
            ITeamIdentifier player = new IAPlayer(tokenY, 2);

            IToken tokenX = new Token(1, 'X');
            ITeamIdentifier opponent = new IAPlayer(tokenX, 1);

            var solver = GetStrateger();

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 0,
                Token = tokenX
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 1,
                Y = 1,
                Token = tokenX
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 1,
                Token = tokenX
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 0,
                Y = 2,
                Token = tokenY
            });
            Assert.IsFalse(state.IsGameOver());

            state.PlayMove(new TicTacToeMove()
            {
                X = 2,
                Y = 1,
                Token = tokenY
            });
            Assert.IsFalse(state.IsGameOver());

            state.Display();
            var move = solver.FindBestMove(state, player, opponent) as TicTacToeMove;
            Assert.IsNotNull(move);
            Assert.IsFalse(state.IsGameOver());
            Assert.AreEqual(2, move.X);
            Assert.AreEqual(2, move.Y);
        }