lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
745 stars 440 forks source link

"level" command is improperly used #703

Closed jdart1 closed 1 year ago

jdart1 commented 1 year ago

xboard engines expect to receive a "level" command to set the time control.

This command should be sent only once at the start of a new game (typically after "new") and subsequently if the time control changes (for example, at the expiration of an initial time control such as 40/2 and the beginning of a new one for the next n moves).

However, lichess-bot sends "level" after each move and apparently reduces the time control section of that command by the time used. For example I see: level 0 4:57 3.0 at the start of a 5+3 time control game and then after each next move I see different quantities in the time control field, for example: level 0 4:32 3.0 after a few moves. This is incorrect behavior. The level command is for setting the time control for a game or a portion of a game. The "time" and "otim" commands inform the engine after each move of its own and its opponent's time remaining.

MarkZH commented 1 year ago

I had a discussion about this issue with the python-chess developer in this issue. We concluded that while sending level for every move is non-standard, it should be harmless. Are the extra level commands causing problems for your engine?

jdart1 commented 1 year ago

My program can record games played, and when it does, it outputs the time control used. So the way I found this issue was that all the games had random, usually low, time controls in the game output that were not the real game time control. That is not maybe a big issue. But note also the CECP specification is quite clear about the semantics of "level:" in the case where the first number is zero, the next number is not the minutes left in the game. The spec says:

The command to set an incremental time control looks like this:

level 0 2 12 Here the 0 means "play the whole game in this time control period", the 2 means "base=2 minutes", and the 12 means "inc=12 seconds". As in conventional clock mode, the second argument to level can be in minutes and seconds.

jdart1 commented 1 year ago

Winboard, which is really the reference implementation of the protocol, has never sent multiple level commands per game, except when the game is divided into multiple different time control periods.