/// <summary> /// Returns the set of points to reverse in a given direction. /// </summary> /// <remarks> /// Returns the consecutive set of discs from the current point /// to the next same colored point in the given direction. /// </remarks> /// <param name="board">The game board</param> /// <param name="point">The point of the new disc</param> /// <param name="direction">The direction to scan in</param> /// <param name="currentPlayer">The current player's color</param> /// <returns></returns> public static ISet<Point> ReversedToNext(Disc[,] board, Point point, Point direction, Disc currentPlayer) { HashSet<Point> points = new HashSet<Point>(); point += direction; if (!board.OnBoard(point)) return points; Disc currentDisc; for (currentDisc = board.At(point); currentDisc == currentPlayer.Reversed() && board.OnBoard(point + direction); point += direction, currentDisc = board.At(point)) points.Add(point); if (currentDisc.IsEmpty() || !board.OnBoard(point + direction) && currentDisc != currentPlayer) points.Clear(); return points; }