コード例 #1
0
        public async Task ApplyMove(BoardPosition position)
        {
            var possMoves = mBoard.GetPossibleMoves() as IEnumerable <TicTacToeMove>;

            foreach (var move in possMoves)
            {
                if (move.Position.Equals(position))
                {
                    mBoard.ApplyMove(move);
                    break;
                }
            }

            RebindState();

            if (Players == NumberOfPlayers.One && !mBoard.IsFinished)
            {
                var bestMoveTask = Task.Run(() => mGameAi.FindBestMove(mBoard));

                var bestMove = await bestMoveTask;
                if (bestMove != null)
                {
                    mBoard.ApplyMove(bestMove as TicTacToeMove);
                }
                RebindState();
            }


            if (mBoard.IsFinished)
            {
                GameFinished?.Invoke(this, new EventArgs());
            }
        }
コード例 #2
0
        public void ApplyMove(BoardPosition position)
        {
            var possMoves = mBoard.GetPossibleMoves() as IEnumerable <TicTacToeMove>;

            foreach (var move in possMoves)
            {
                if (move.Position.Equals(position))
                {
                    mBoard.ApplyMove(move);
                    break;
                }
            }

            PossibleMoves = new HashSet <BoardPosition>(
                from TicTacToeMove m in mBoard.GetPossibleMoves()
                select m.Position
                );
            var newSquares =
                from r in Enumerable.Range(0, 3)
                from c in Enumerable.Range(0, 3)
                select new BoardPosition(r, c);
            int i = 0;

            foreach (var pos in newSquares)
            {
                mSquares[i].Player = mBoard.GetPieceAtPosition(pos);
                i++;
            }
            OnPropertyChanged(nameof(BoardAdvantage));
        }
コード例 #3
0
        public void ApplyMove(BoardPosition position)
        {
            var possMoves = mBoard.GetPossibleMoves() as IEnumerable <TicTacToeMove>;

            foreach (var move in possMoves)
            {
                if (move.Position.Equals(position))
                {
                    mBoard.ApplyMove(move);
                    break;
                }
            }

            if (Players == NumberOfPlayers.One && !mBoard.IsFinished)
            {
                var bestMove = mGameAi.FindBestMove(mBoard);
                if (bestMove != null)
                {
                    mBoard.ApplyMove(bestMove);
                }
            }

            RebindState();
        }
コード例 #4
0
        public void ApplyMove(BoardPosition position)
        {
            var possMoves = mBoard.GetPossibleMoves() as IEnumerable <TicTacToeMove>;

            foreach (var move in possMoves)
            {
                if (move.Position.Equals(position))
                {
                    mBoard.ApplyMove(move);
                    break;
                }
            }

            RebindState();
        }
コード例 #5
0
        public void ApplyMove(BoardPosition position)
        {
            var possMoves = mBoard.GetPossibleMoves() as IEnumerable <TicTacToeMove>;

            foreach (var move in possMoves)
            {
                if (move.Position.Equals(position))
                {
                    mBoard.ApplyMove(move);
                    break;
                }
            }

            RebindState();
            if (mBoard.IsFinished)
            {
                GameFinished?.Invoke(this, new EventArgs());
            }
        }