lichess-org / api

Lichess API documentation and examples
https://lichess.org/api
GNU Affero General Public License v3.0
442 stars 147 forks source link

`api/stream/game/` for Horde and Racing Kings has inconsistent behavior from other game types #187

Closed mcognetta closed 2 years ago

mcognetta commented 2 years ago

In api/stream/game/, the first message is a game description, then all subsequent messages are game state updates, starting from the the initial fen. However, in Horde and Racing Kings, the game updates actually start from the position that was current when the request was made. For example, the following is a Horde game.

"{\"id\":\"sF36YEEu\",\"variant\":{\"key\":\"horde\",\"name\":\"Horde\",\"short\":\"Horde\"},\"speed\":\"rapid\",\"perf\":\"horde\",\"rated\":true,\"fen\":\"5bnr/3Q2p1/1q2PkP1/p4P1P/2P2PPP/4PPPP/5PP1/P5P1 w - - 2 60\",\"player\":\"white\",\"turns\":118,\"startedAtTurn\":0,\"source\":\"lobby\",\"status\":{\"id\":20,\"name\":\"started\"},\"createdAt\":1653712406280,\"lastMove\":\"e7f6\"}"

"{\"fen\":\"5bnr/3Q2p1/1q2PkP1/p4P1P/2P1PPPP/5PPP/5PP1/P5P1 b\",\"lm\":\"e3e4\",\"wc\":389,\"bc\":486}"

"{\"fen\":\"6nr/3Q2p1/1q1bPkP1/p4P1P/2P1PPPP/5PPP/5PP1/P5P1 w\",\"lm\":\"f8d6\",\"wc\":389,\"bc\":475}"

I initially thought it was because these both have standardInitialPosition = false, but Chess960 does also and that variant works fine.

From https://github.com/lichess-org/api/pull/186#issuecomment-1140074447:

seems like a bug. It seems that gameRepo.initialFen returns None for horde and racing kings but Replays.situations interprets that as using the standard starting position which then leads to an invalid move and no moves transmitted. Those behaviors both seem kinda wrong but not sure if anything relies on them?

ornicar commented 2 years ago

https://github.com/lichess-org/scalachess/commit/a0799d80dc260e14722e4bb4687203527bde149b