예제 #1
0
        public bool MakeMove(TicTacToeMove move, TicTacToeBoardValue boardValue)
        {
            bool isValid = this.IsValidMove(move);

            if (isValid)
            {
                this.values[move.X, move.Y] = boardValue;
            }
            return(isValid);
        }
예제 #2
0
        public IEnumerable <TicTacToeMove> GetOpenMoves()
        {
            List <TicTacToeMove> openMoves = new List <TicTacToeMove>();

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    TicTacToeMove move = new TicTacToeMove(x, y);
                    if (this.IsValidMove(move))
                    {
                        openMoves.Add(move);
                    }
                }
            }

            return(openMoves);
        }
예제 #3
0
 public bool IsValidMove(TicTacToeMove move)
 {
     return(move != null && this.values[move.X, move.Y] == null);
 }