Skip to content

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

Open
aslanyerdelen wants to merge 1 commit into
lichess-org:masterfrom
aslanyerdelen:fix/game-player-ai-union
Open

Model AI game sides as GamePlayerAi, unioned in GamePlayers#659
aslanyerdelen wants to merge 1 commit into
lichess-org:masterfrom
aslanyerdelen:fix/game-player-ai-union

Conversation

@aslanyerdelen

Copy link
Copy Markdown

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.

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.
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.

1 participant