Last active
May 1, 2024 09:51
-
-
Save tors42/41e449469c071a009f1b9490c05eab1e to your computer and use it in GitHub Desktop.
JShell script to get the FEN of a puzzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (! Files.exists(Path.of("chariot.jar"))) { | |
Files.write(Path.of("chariot.jar"), URI.create( | |
"https://repo1.maven.org/maven2/io/github/tors42/chariot/0.0.83/chariot-0.0.83.jar" | |
).toURL().openStream().readAllBytes()); | |
} | |
/env --class-path chariot.jar | |
import chariot.Client; | |
import chariot.util.Board; | |
String puzzleId = "EC8uc"; | |
String moves = Client.basic().puzzles().byId(puzzleId).map(puzzle -> puzzle.game().pgn()).orElse(""); | |
String fen = Board.fromStandardPosition().play(moves).toFEN(); | |
System.out.println("Moves: " + moves); | |
System.out.println("FEN: " + fen); | |
/exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example run (running jshell from https://jdk.java.net/21/)