Skip to content

Model AI game sides as GamePlayerAi, unioned in GamePlayers - #659

Merged
fitztrev merged 3 commits into
lichess-org:masterfrom
aslanyerdelen:fix/game-player-ai-union
Sep 2, 2026
Merged

Model AI game sides as GamePlayerAi, unioned in GamePlayers#659
fitztrev merged 3 commits into
lichess-org:masterfrom
aslanyerdelen:fix/game-player-ai-union

Conversation

@aslanyerdelen

Copy link
Copy Markdown
Contributor

Follow-up to #658, implementing the shape @gameroman suggested there: a separate schema for AI sides plus a union, instead of loosening GamePlayerUser.

Changes

  • New GamePlayerAi: aiLevel required, optional per-side analysis. Matches what the API returns for games against the computer:

    curl -s -H 'Accept: application/json' https://lichess.org/game/export/p66Eii3m | jq .players.white
    # => { "aiLevel": 1 }
  • GamePlayers.white/black become oneOf: [GamePlayerUser, GamePlayerAi]

  • GamePlayerUser stays exactly as strict as today for registered players (user/rating required); only aiLevel moves out, since a registered player side never carries it

  • GamePlayerAi registered in _index.yaml

redocly lint passes with no new warnings.

Open question

Fully anonymous players may also appear as a side with neither user nor aiLevel. I have no verified sample of that payload, so this PR deliberately doesn't model it — happy to add a third variant to the union if you can confirm the shape.

aslanyerdelen and others added 3 commits July 24, 2026 16:53
Follow-up to lichess-org#658 implementing the suggested shape: GamePlayerUser keeps
user/rating required and is only for registered players; AI sides
(players.<color> == {"aiLevel": n}, e.g. game p66Eii3m) get their own
schema, and GamePlayers unions the two per color. aiLevel moves out of
GamePlayerUser since a registered player side never carries it.
@fitztrev

fitztrev commented Sep 2, 2026

Copy link
Copy Markdown
Member

Looks good, thanks. It would probably be good to move analysis to a separate ref too then, if you want to do that.

@fitztrev
fitztrev merged commit 3eefa35 into lichess-org:master Sep 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants