public void CheckThirdSituationVertically(bool firstPlayer, Board board, ref int result) { for (int c = 0; c < board.NumberOfColumns; c++) { int r = board.GetFirstFreeRow(c); if (r >= board.NumberOfRows - 1 || r < 2 || (r - 3 >= 0 && board[c, r - 3] == firstPlayer)) { continue; } if (board[c, r - 1] == firstPlayer && board[c, r - 2] == firstPlayer) { result += GetValueFromThirdSituation(board.NumberOfRows - r); } } }
public bool CheckSecondSituationVertically(bool firstPlayer, Board currentBoard, ref int result) { //if found twice, res = inf bool found = false; for (int c = 0; c < currentBoard.NumberOfColumns; c++) { bool cont = false; int lastR = currentBoard.GetFirstFreeRow(c); if (lastR == currentBoard.NumberOfRows || lastR < 3) { continue; } for (int i = 1; i <= 3; i++) { if (currentBoard[c, lastR - i] != firstPlayer) { cont = true; break; } } if (cont) { continue; } //found twice! if (found) { result = int.MaxValue; return(true); } found = true; result = 900000; } return(false); }