From cdedd3ec305c78da12e53f25c67e756ee3b70064 Mon Sep 17 00:00:00 2001 From: GearsDatapacks Date: Wed, 3 Sep 2025 15:49:03 +0100 Subject: [PATCH] Allow comments and newlines in fen file --- silversuite.fen | 2 +- src/starfish_testing.gleam | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/silversuite.fen b/silversuite.fen index ce19540..e5d5c09 100644 --- a/silversuite.fen +++ b/silversuite.fen @@ -48,4 +48,4 @@ rnbq1rk1/pppp1ppp/4pn2/8/2PP4/P1Q5/1P2PPPP/R1B1KBNR b KQ - 0 6 rnbq1rk1/pp3ppp/4pn2/2pp4/1bPP4/2NBPN2/PP3PPP/R1BQ1RK1 b - - 1 7 r1bq1rk1/pppn1pbp/3p1np1/4p3/2PPP3/2N2NP1/PP3PBP/R1BQ1RK1 b - e3 0 8 rnbq1rk1/pp3pbp/2pp1np1/4p3/2PPP3/2N1BP2/PP2N1PP/R2QKB1R w KQ - 0 8 -r1bq1rk1/pppnn1bp/3p4/3Pp1p1/2P1Pp2/2N2P2/PP2BBPP/R2QNRK1 w - - 0 13 \ No newline at end of file +r1bq1rk1/pppnn1bp/3p4/3Pp1p1/2P1Pp2/2N2P2/PP2BBPP/R2QNRK1 w - - 0 13 diff --git a/src/starfish_testing.gleam b/src/starfish_testing.gleam index e0bbaa6..c8e34b5 100644 --- a/src/starfish_testing.gleam +++ b/src/starfish_testing.gleam @@ -4,7 +4,6 @@ import gleam/httpc import gleam/int import gleam/io import gleam/list -import gleam/result import gleam/string import simplifile as file import starfish @@ -19,9 +18,14 @@ pub fn main() -> Nil { let assert Ok(games) = fen_file |> file.read - |> result.map(string.split(_, "\n")) as "Failed to read game file" + let games = + games + |> string.split("\n") + // Use `#` for comments in the file + |> list.filter(fn(game) { game != "" && !string.starts_with(game, "#") }) + io.println("Loaded games.") let outcomes = list.index_map(games, run_game) |> list.flatten -- 2.51.2