From bfc46723e615bb9b65f7f9bba5f53877c4f079a7 Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 23 Jun 2026 22:58:09 +0200 Subject: [PATCH] fix(official-bots): derive tournament game color from game endpoint (#79) Tournament-server reports wrong color in pairings (everyone white), so auto-joined games could play with an inverted color and never move on their real turn. The game endpoint white/black ids are correct, so the poll loop now derives our color from it, falling back to the passed-in color. Both stream and auto-join entry paths are now immune to the bug. Co-Authored-By: Claude Opus 4.8 --------- Co-authored-by: Janis Eccarius Reviewed-on: https://git.janis-eccarius.de/NowChess/NowChessSystems/pulls/79 --- .../nowchess/bot/service/TournamentBotGamePlayer.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/official-bots/src/main/scala/de/nowchess/bot/service/TournamentBotGamePlayer.scala b/modules/official-bots/src/main/scala/de/nowchess/bot/service/TournamentBotGamePlayer.scala index 1430f6d..c6c55a1 100644 --- a/modules/official-bots/src/main/scala/de/nowchess/bot/service/TournamentBotGamePlayer.scala +++ b/modules/official-bots/src/main/scala/de/nowchess/bot/service/TournamentBotGamePlayer.scala @@ -414,9 +414,17 @@ class TournamentBotGamePlayer: if gameTerminalStatuses.contains(status) then log.infof("Game %s ended — status=%s", gameId, status); done = true else + // TEMP: tournament-server reports wrong color in pairings (everyone white). + // The game endpoint white/black ids are correct, so derive our color from it. + val whiteId = node.path("white").path("id").asText() + val blackId = node.path("black").path("id").asText() + val myColor = + if whiteId == cfg.botId then "white" + else if blackId == cfg.botId then "black" + else color val turn = node.path("turn").asText() val fen = node.path("fen").asText() - if turn == color && status == "ongoing" && fen.nonEmpty && fen != lastFen then + if turn == myColor && status == "ongoing" && fen.nonEmpty && fen != lastFen then lastFen = fen log.infof("Our turn in game %s — computing move (fen=%s)", gameId, fen) computeUci(cfg, fen) match