Beispiel #1
0
        public bool IsPlayable(int column, int line, bool isWhite)
        {
            Point movePos = new Point(column, line);

            currentPossibleMoves = LogicalB.GetPossibleMoves(logicalBoard.BoardArray, isWhite, BOARD_DIMENSIONS);
            return(currentPossibleMoves.Any(move => move.position.Equals(movePos)));
        }
Beispiel #2
0
        public bool PlayMove(int column, int line, bool isWhite)
        {
            Point movePos = new Point(column, line);

            currentPossibleMoves = LogicalB.GetPossibleMoves(logicalBoard.BoardArray, isWhite, BOARD_DIMENSIONS);
            Move targetMove = currentPossibleMoves.Where(move => move.position.Equals(movePos)).FirstOrDefault();

            if (targetMove != null)
            {
                PlayMove(targetMove);
                return(true);
            }

            return(false);
        }
Beispiel #3
0
 public Tuple <int, int> GetNextMove(int[,] game, int level, bool whiteTurn)
 {
     logicalBoard.BoardArray = game;
     try
     {
         currentPossibleMoves = LogicalB.GetPossibleMoves(game, whiteTurn, BOARD_DIMENSIONS);
         Move move = OthelloMiniMax.GetMove(game, level, whiteTurn);
         if (move == null)
         {
             move = new Move(new Point(-1, -1), whiteTurn);
         }
         return(new Tuple <int, int>(move.position.X, move.position.Y));
     }
     catch
     {
         return(new Tuple <int, int>(-1, -1));
     }
 }
 /// <summary>
 /// Get the possible moves for this board
 /// </summary>
 /// <returns>A list of move objects returned</returns>
 public List <Move> GetMoves()
 {
     return(LogicalB.GetPossibleMoves(Data, whitePlayer, new Size(Data.GetLength(0), Data.GetLength(1))));
 }
 /// <summary>
 /// Apply and returns a new board state with the given move.
 /// </summary>
 /// <param name="move">Move object to apply</param>
 /// <returns>A new node with the board calculated</returns>
 public MiniMaxTreeNode ApplyMove(Move move)
 {
     int[,] dataCopy = (int[, ])Data.Clone();
     LogicalB.ApplyMove(dataCopy, move);
     return(new MiniMaxTreeNode(dataCopy, !whitePlayer));
 }
Beispiel #6
0
 /// <summary>
 /// This constructor is the base to init different values called when the program is first started and when it loads a saved game
 /// It should be private since it's only used as a helper but the tournament needs a default constructor
 /// </summary>
 public Board()
 {
     currentPossibleMoves = new List <Move>();
     logicalBoard         = new LogicalB(BOARD_DIMENSIONS.Width, BOARD_DIMENSIONS.Height);
 }