Notify engines of draw offers - #783
Merged
Merged
Conversation
Only works for XBoard engines since the UCI protocol has no facility for offering or accepting draws.
Owner
|
Thanks! |
MarkZH
added a commit
to MarkZH/lichess-bot
that referenced
this pull request
May 16, 2021
niklasf
added a commit
that referenced
this pull request
May 17, 2021
Make sure engines support draw offers (followup to #783)
ShailChoksi
pushed a commit
to lichess-bot-devs/lichess-bot
that referenced
this pull request
Sep 23, 2021
* Allow XBoard bots of offer/accept draws and resign
These changes allow XBoard engines to resign games (by printing "resign"
to stdout) and to offer/accept draws (by printing "offer draw" to
stdout). There are no similar functions for UCI engines.
Two problems so far:
1. The python-chess library will only pick up on "offer draw" if the bot
prints it while thinking about a move. Otherwise, it is ignored. So, if
the bot responds immediatlely to the "draw" command on line 262 before
one of the choose_move functions can be called, it will be ignored.
2. When accepting a draw, the lichess API returns with
https://lichess.org:443 "POST /api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1 HTTP/1.1" 400 43
Giving up api_post(...) after 1 tries (requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1)
The draw acceptance is properly accepted by lichess and the game
actually ends with a draw. I'm not sure if the error message is
important.
* Send force before offering draw
In my understanding, "force" causes XBoard engines to accept commands
and not take action until the next "go" command. This should prevent
engines from sending "offer draw" before the python-chess library is
ready to hear it. This should solve issue 1 from the last commit.
* Use "true" and "false" instead of "1" and "0"
* More idiomatic XBoard features probe
* Update for future python-chess update
See PR at niklasf/python-chess#783
* Change argument order
* Simplify check for draw offers
* Update python-chess to version that supports draws
This new version of python-chess will send the "draw" command to Xboard
engines before telling them to choose a move. If the engine responds
with "offer draw", the draw offer will be included in the Play_Result
returned from the search methods in the EngineWrapper class.
* Add draw_offered parameter to homemade search methods
Shah-in-alam
pushed a commit
to Shah-in-alam/AI-Project-
that referenced
this pull request
Nov 7, 2025
* Allow XBoard bots of offer/accept draws and resign
These changes allow XBoard engines to resign games (by printing "resign"
to stdout) and to offer/accept draws (by printing "offer draw" to
stdout). There are no similar functions for UCI engines.
Two problems so far:
1. The python-chess library will only pick up on "offer draw" if the bot
prints it while thinking about a move. Otherwise, it is ignored. So, if
the bot responds immediatlely to the "draw" command on line 262 before
one of the choose_move functions can be called, it will be ignored.
2. When accepting a draw, the lichess API returns with
https://lichess.org:443 "POST /api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1 HTTP/1.1" 400 43
Giving up api_post(...) after 1 tries (requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1)
The draw acceptance is properly accepted by lichess and the game
actually ends with a draw. I'm not sure if the error message is
important.
* Send force before offering draw
In my understanding, "force" causes XBoard engines to accept commands
and not take action until the next "go" command. This should prevent
engines from sending "offer draw" before the python-chess library is
ready to hear it. This should solve issue 1 from the last commit.
* Use "true" and "false" instead of "1" and "0"
* More idiomatic XBoard features probe
* Update for future python-chess update
See PR at niklasf/python-chess#783
* Change argument order
* Simplify check for draw offers
* Update python-chess to version that supports draws
This new version of python-chess will send the "draw" command to Xboard
engines before telling them to choose a move. If the engine responds
with "offer draw", the draw offer will be included in the Play_Result
returned from the search methods in the EngineWrapper class.
* Add draw_offered parameter to homemade search methods
Sneha-neupane
pushed a commit
to Sneha-neupane/aiBotChess
that referenced
this pull request
Dec 11, 2025
* Allow XBoard bots of offer/accept draws and resign
These changes allow XBoard engines to resign games (by printing "resign"
to stdout) and to offer/accept draws (by printing "offer draw" to
stdout). There are no similar functions for UCI engines.
Two problems so far:
1. The python-chess library will only pick up on "offer draw" if the bot
prints it while thinking about a move. Otherwise, it is ignored. So, if
the bot responds immediatlely to the "draw" command on line 262 before
one of the choose_move functions can be called, it will be ignored.
2. When accepting a draw, the lichess API returns with
https://lichess.org:443 "POST /api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1 HTTP/1.1" 400 43
Giving up api_post(...) after 1 tries (requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1)
The draw acceptance is properly accepted by lichess and the game
actually ends with a draw. I'm not sure if the error message is
important.
* Send force before offering draw
In my understanding, "force" causes XBoard engines to accept commands
and not take action until the next "go" command. This should prevent
engines from sending "offer draw" before the python-chess library is
ready to hear it. This should solve issue 1 from the last commit.
* Use "true" and "false" instead of "1" and "0"
* More idiomatic XBoard features probe
* Update for future python-chess update
See PR at niklasf/python-chess#783
* Change argument order
* Simplify check for draw offers
* Update python-chess to version that supports draws
This new version of python-chess will send the "draw" command to Xboard
engines before telling them to choose a move. If the engine responds
with "offer draw", the draw offer will be included in the Play_Result
returned from the search methods in the EngineWrapper class.
* Add draw_offered parameter to homemade search methods
MustafaMoiz53
pushed a commit
to MustafaMoiz53/AI-Project-Exam
that referenced
this pull request
Dec 31, 2025
* Allow XBoard bots of offer/accept draws and resign
These changes allow XBoard engines to resign games (by printing "resign"
to stdout) and to offer/accept draws (by printing "offer draw" to
stdout). There are no similar functions for UCI engines.
Two problems so far:
1. The python-chess library will only pick up on "offer draw" if the bot
prints it while thinking about a move. Otherwise, it is ignored. So, if
the bot responds immediatlely to the "draw" command on line 262 before
one of the choose_move functions can be called, it will be ignored.
2. When accepting a draw, the lichess API returns with
https://lichess.org:443 "POST /api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1 HTTP/1.1" 400 43
Giving up api_post(...) after 1 tries (requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/bot/game/za8D4j9z/move/c1f4?offeringDraw=1)
The draw acceptance is properly accepted by lichess and the game
actually ends with a draw. I'm not sure if the error message is
important.
* Send force before offering draw
In my understanding, "force" causes XBoard engines to accept commands
and not take action until the next "go" command. This should prevent
engines from sending "offer draw" before the python-chess library is
ready to hear it. This should solve issue 1 from the last commit.
* Use "true" and "false" instead of "1" and "0"
* More idiomatic XBoard features probe
* Update for future python-chess update
See PR at niklasf/python-chess#783
* Change argument order
* Simplify check for draw offers
* Update python-chess to version that supports draws
This new version of python-chess will send the "draw" command to Xboard
engines before telling them to choose a move. If the engine responds
with "offer draw", the draw offer will be included in the Play_Result
returned from the search methods in the EngineWrapper class.
* Add draw_offered parameter to homemade search methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only works for XBoard engines since the UCI protocol has no facility for
offering or accepting draws.
Closes #781