lichess-org / lichess-org/api

NDJSON game stream move updates are not synchronized with the moments the moves were made

Open
#615 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
597
Forks
176
Avg merge
1d 4h
Merged PRs (30d)
6

Description

I am trying to show the time for moves with the game stream API and the only time related information is bc and wc properties (clock times in seconds for each side). Only the time the moves are sent in the NDJSON stream seems unrelated to the time of the move itself. Two updates two seconds apart can decrease the time of one side by tens of seconds and updates tens of seconds apart can decrease the time of one side with just 2 seconds.

The documentation says "Ongoing games are delayed by 3 moves, as to prevent cheat bots from using this API", however I suspect the time the update is sent is related to the current player move, not the move in the NDJSON update. I may be wrong, but I think what happens is that when a player makes a move, an update is sent, but the update is that of the move three ply back. However, that makes the wc and bc values uncorrelated to the current time.

The updates should come in real time, but delayed with a constant time, not a number of ply. An alternate solution is to include a serverTime property that would tell when the data is from.

Here is an example of how the data is received. The first number is a relative timestamp in seconds, the second and third are white clock and black clock in seconds:
55: 100 | 151
59: 98 | 151
61: 98 | 149
65: 88 | 149
79: 88 | 146
81: 86 | 146
82: 86 | 142
84: 72 | 142
85: 72 | 140
88: 71 | 140
89: 71 | 139
89: 70 | 139
106: 70 | 136
108: 69 | 136

Note how between 82 and 84 two seconds have passed, but the update of White's clock is 14 seconds. That is offset by 89-106 (17 seconds) where Black's clock is updated with just 3 seconds.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the game stream API documentation and the NDJSON update behavior described in the examples. Determine whether the intended outcome is a constant delay or a serverTime field, then verify that the chosen approach makes clock values correlate with the represented move time.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.