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; }
private int GetFirstEmptyCellCoordinatesInASide(Board board) { foreach ( var side in board.Sides) { if (board.IsCellOfType(' ', side)) return side; } return INVALID_COORDINATES; }
private int GetFirstEmptyCellCoordinatesInACorner(Board board) { foreach (var corner in board.Corners) { if (board.IsCellOfType(' ', corner)) return corner; } return INVALID_COORDINATES; }
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); }