Skip to content

Instantly share code, notes, and snippets.

@nikhil-RGB
Created July 18, 2025 02:00
Show Gist options
  • Select an option

  • Save nikhil-RGB/11cd723e9e541f0d9d7e8e95e813e12c to your computer and use it in GitHub Desktop.

Select an option

Save nikhil-RGB/11cd723e9e541f0d9d7e8e95e813e12c to your computer and use it in GitHub Desktop.
List<Checkers> continuedCapture(Point source, List<List<Point>> moves) {
Checkers refBoard = this;
List<Checkers> boards = [];
for (List<Point> capDiagonal in moves) {
Checkers childBoardCap = refBoard.cloneGame();
List<List<Point>> newCaps =
childBoardCap.executeCapture(source, capDiagonal);
newCaps = childBoardCap.kingAfterMove(capDiagonal[1])
? childBoardCap.captureSequences(capDiagonal[1])
: newCaps;
if (newCaps.isEmpty) {
boards.add(childBoardCap);
} else {
Point newSource = capDiagonal[1];
boards.addAll(childBoardCap.continuedCapture(newSource, newCaps));
}
}
return boards;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment