예제 #1
0
        /// <summary>
        /// Makes a move on this Othello board at the specified move position
        /// </summary>
        /// <param name="move">The move to make</param>
        /// <returns>A reference to this Othello board</returns>
        public override Board MakeMove(Move move)
        {
            OthelloMove m = (OthelloMove)move;

            //Change the cell being moved in belong to the current player
            boardContents[m.Position.X, m.Position.Y] = CurrentPlayer;

            //Change each capturable cell to belong to the current player
            foreach (Point p in m.CapturableCells)
            {
                boardContents[p.X, p.Y] = CurrentPlayer;
            }

            //Swap out the current player for the next player
            CurrentPlayer = NextPlayer;

            //Repopulate the possible moves list for the current player
            CalculatePossibleMoves();

            //If there are no possible moves left, then determine the winner of the game
            if (possibleMoves.Count == 0)
            {
                DetermineWinner();
            }

            //Call the MakeMove method on the Board base class, to save the last move made on this board
            return(base.MakeMove(move));
        }
예제 #2
0
        /// <summary>
        /// Equality override for a Othello move <para/>
        /// Two moves are equal if their x and y positions are equal
        /// </summary>
        /// <param name="obj">The other OthelloMove instance to compare this one too</param>
        /// <returns>True if the objects are equal, false otherwise</returns>
        public override bool Equals(object obj)
        {
            if (obj is OthelloMove)
            {
                OthelloMove other = (OthelloMove)obj;
                if (other.X == X && other.Y == Y)
                {
                    return(true);
                }
            }

            return(false);
        }