private bool IsSetReachableInSingleMove(UnbeatableSet set) { BoardPosition left = _currentBoard[set.A.XIndex - 1, set.A.YIndex]; BoardPosition right = _currentBoard[set.C.XIndex + 1, set.C.YIndex]; int totalMoves = left.MovesRequiredToReachPosition(_currentBoard) + right.MovesRequiredToReachPosition(_currentBoard); return(totalMoves == 2); }
private bool IsValidSet(UnbeatableSet set) { int yIndex = set.A.YIndex; if (_currentBoard[set.A.XIndex - 1, yIndex].IsOccupied) { return(false); } if (_currentBoard[set.C.XIndex + 1, yIndex].IsOccupied) { return(false); } else { return(IsSetReachableInSingleMove(set)); } }
private int CheckForUnBeatableWin(TeamName team) { for (int i = 1; i < 4; i++) { for (int j = 0; j < 6; j++) { if (_currentBoard[i, j].Owner == team && _currentBoard[i + 1, j].Owner == team && _currentBoard[i + 2, j].Owner == team) { UnbeatableSet set = new UnbeatableSet { A = _currentBoard[i, j], B = _currentBoard[i + 1, j], C = _currentBoard[i + 2, j] }; if (IsValidSet(set)) { return(95); } } } } return(0); }