示例#1
0
        private bool IsLineSuitableForAFork(Board board, int[] line)
        {
            int aiCells = 0;

            foreach(var coordinate in line )
            {
                if(board.IsCellOfType(opponentsMark, coordinate))
                    return false;

                if (board.IsCellOfType(myMark, coordinate))
                    aiCells++;
            }

            return aiCells == AI_CELLS_IN_A_FORK_LINE;
        }
示例#2
0
        private int GetFirstEmptyCellCoordinatesInASide(Board board)
        {
            foreach ( var side in board.Sides)
            {
                if (board.IsCellOfType(' ', side))
                    return side;
            }

            return INVALID_COORDINATES;
        }
示例#3
0
        private int GetFirstEmptyCellCoordinatesInACorner(Board board)
        {
            foreach (var corner in board.Corners)
            {
                if (board.IsCellOfType(' ', corner))
                    return corner;
            }

            return INVALID_COORDINATES;
        }
示例#4
0
 public override void Update(Board board, char mark)
 {
     for (var column = 0; column < board.Size; column++)
     {
         if (board.IsCellOfType(' ', new CellCoordinates(FIRST_ROW, column)))
         {
             board.FillCell(new CellCoordinates(FIRST_ROW, column), mark);
             break;
         }
     }
 }
 private bool IsThereAndOpponentInTheCorner(int markCoordinate, Board board)
 {
     return board.IsCellOfType(opponentsMark, markCoordinate);
 }
 private bool IsOppositeCornerFree(int markCoordinate, Board board)
 {
     return board.IsCellOfType(' ', markCoordinate);
 }