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

Position command while pondering #696

Closed fabriciodosanjossilva closed 1 year ago

fabriciodosanjossilva commented 1 year ago

It seems that lichess-bot issues a fixed series os commands whenever a match finishes for any reason (checkmate, checkmate against, draw, resignation based on resign_score config, etc).

The series of commands seems to be: position startpos moves [the complete move list] stop isready quit

Except for the obviously expected "quit" command, I don't undestand why these commands are issued. There might be a reason I don't fully undestand. Well, that's not a big issue. They don't hurt.

Except that the first command (position) seems to be illegal if just previously lichess-bot issued a "go ponder" command. While pondering, I expected either a "stop" or a "ponderhit" commands. Nothing else. Am I wrong?

MarkZH commented 1 year ago

The idea was to inform bots of the final move in a game before telling them to quit, especially in cases where the opponent's move causes the end of the game like for checkmate or draws. I originally put this in because my bot saves a PGN record of the game after completion, and the UCI protocol does not have the functionality to tell the engine of the result of a game, so my PGN files were incomplete with the last move missing. Then again, lichess-bot now has the feature of saving a PGN file after a game completes, so this is less relevant.

However, I do know that these commands are not implemented correctly. These commands will be removed once PR #690 is merged. I'm working on a better version, but it may take some time.

Do you think sending the final position to UCI engines is a good or bad idea in general (assuming it's implemented correctly by first sending stop)?

fabriciodosanjossilva commented 1 year ago

For me, the final "position" command is a bit awkward, unexpected. Since the reason for it to exist no longer exists, it seems that it should be removed. I personnaly find confusing seeing in the log a position command after a draw statement. But again, it does no harm.

I've implemented a work-around on my bot to deal for awhile with the lack of the "stop" command.