/// <summary> /// Returns whether a segment on the board is a winning segment or not /// </summary> private static bool SegmentWon(IGameBoard gameBoard, WinningSegment winningSegment) { var firstValue = gameBoard.GetSpaceValue(winningSegment.Coordinates[0].X, winningSegment.Coordinates[0].Y); foreach (var coordinate in winningSegment.Coordinates) { var spaceValue = gameBoard.GetSpaceValue(coordinate.X, coordinate.Y); if (spaceValue == SpaceValue.Available || spaceValue != firstValue) { return(false); } } return(true); }
/// <summary> /// Returns whether an already taken space was taken by a different player /// </summary> private bool TakenSpaceReplaced(IGameBoard originalBoard, IGameBoard changedBoard) { for (var x = 0; x < _boardSize; ++x) { for (var y = 0; y < _boardSize; ++y) { if (originalBoard.GetSpaceValue(x, y) != changedBoard.GetSpaceValue(x, y) && originalBoard.GetSpaceValue(x, y) != SpaceValue.Available) { return(true); } } } return(false); }