Skip to content

Notify engines of draw offers - #783

Merged
niklasf merged 1 commit into
niklasf:masterfrom
MarkZH:draw-offer
May 16, 2021
Merged

Notify engines of draw offers#783
niklasf merged 1 commit into
niklasf:masterfrom
MarkZH:draw-offer

Conversation

@MarkZH

@MarkZH MarkZH commented May 16, 2021

Copy link
Copy Markdown
Contributor

Only works for XBoard engines since the UCI protocol has no facility for
offering or accepting draws.

Closes #781

Only works for XBoard engines since the UCI protocol has no facility for
offering or accepting draws.
@niklasf

niklasf commented May 16, 2021

Copy link
Copy Markdown
Owner

Thanks!

@niklasf
niklasf merged commit c98605e into niklasf:master May 16, 2021
MarkZH added a commit to MarkZH/lichess-bot that referenced this pull request May 16, 2021
@MarkZH
MarkZH deleted the draw-offer branch May 17, 2021 05:47
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
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.

Engine communication outside play() and other methods

2 participants