Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR:backoff:Giving up play_game(...) after 12 tries #128

Closed
drbeco opened this issue Jun 25, 2018 · 7 comments
Closed

ERROR:backoff:Giving up play_game(...) after 12 tries #128

drbeco opened this issue Jun 25, 2018 · 7 comments

Comments

@drbeco
Copy link

drbeco commented Jun 25, 2018

Hi guys,

I'm getting this error:

   5528 # scanf: go
   5529 # xboard: go. Xadreco is now black.
   5530 # xadreco : N.51. Brancas. Tempo 1529923422.000000s. Acumulado: 1529923422.000000s. Hora: 2018-06-25 07:43:42
   5531 ERROR:backoff:Giving up play_game(...) after 12 tries (chess.engine.EngineTerminatedException)
   5532 Traceback (most recent call last):
   5533   File "/home/beco/Documents/fontes/python/lichess-bot/logging_pool.py", line 16, in __call__
   5534     result = self.__callable(*args, **kwargs)
   5535   File "/home/beco/Documents/fontes/python/lichess-bot/.venv/lib/python3.5/site-packages/backoff/_sync.py", line 99, in retry
   5536     ret = target(*args, **kwargs)
   5537   File "lichess-bot.py", line 126, in play_game
   5538     play_first_move(game, engine, board, li)
   5539   File "lichess-bot.py", line 172, in play_first_move
   5540     best_move = engine.first_search(board, 10000)
   5541   File "/home/beco/Documents/fontes/python/lichess-bot/engine_wrapper.py", line 183, in first_search
   5542     bestmove = self.engine.go()
   5543   File "/home/beco/Documents/fontes/python/lichess-bot/.venv/lib/python3.5/site-packages/chess/xboard.py", line 1265, in go
   5544     return self._queue_command(command, async_callback)
   5545   File "/home/beco/Documents/fontes/python/lichess-bot/.venv/lib/python3.5/site-packages/chess/xboard.py", line 582, in _queue_command
   5546     return future.result(timeout=FUTURE_POLL_TIMEOUT)
   5547   File "/usr/lib/python3.5/concurrent/futures/_base.py", line 405, in result
   5548     return self.__get_result()
   5549   File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
   5550     raise self._exception
   5551   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
   5552     result = self.fn(*self.args, **self.kwargs)
   5553   File "/home/beco/Documents/fontes/python/lichess-bot/.venv/lib/python3.5/site-packages/chess/xboard.py", line 1253, in command
   5554     raise EngineTerminatedException()
   5555 chess.engine.EngineTerminatedException

I'm not sure what is this about. At first I thought that it has something to do with the command issued by the engine to lichess "offer draw".

Xboard protocol says you can offer anytime, but it looks like lichess-bot implementation wants it just after the move. So I changed it, but I guess that didn't solve the problem yet.

Maybe I'm missing something. This bug can be anywhere. I know Xadreco plays without problem at FICS since 2007, so it is just a matter of the Xboard protocol interpretation.

Thanks any guidance.

@drbeco
Copy link
Author

drbeco commented Jun 26, 2018

So, after reading some issues that may be related with this problem, I see that maybe an older version, not sure, lichess support for XBOARD protocol is lacking the option to resign and offer draw.

I'm still trying to figure out what is happening on this issue, but I would like an update if this is still the case.

Thanks!


Also I need to note that the current usage of Xboard protocol is not natural. It looks like someone is trying to speak russian with french accent, if that analogy makes any sense.

  • UCI protocol do set the position for each move. Yes, that is the way it is invented.

  • Xboard protocol does not, or should not, do that. setboard is to be used to analise a position, not to play. Xboard issues a new command and a sequence of moves. Not even go is strictly necessary during a normal game.

  • Basically: after a first go to tell it to play (and the header mumbo-jumbo), just send a move or draw, get back another move or resign or offer draw. That is it. If one don't want to implement anything else, send a SIGINT or SIGQUIT to the engine after the game. It is really not that complicated.

By setting the board all over again and again, old engines using Xboard protocol loses the history of the game. I mean, of course you can tell an engine author to deal with it, but to be fair, the protocol should be precise.

I also noted that lichess-bot doesn't respect "time=0" and many other features. For example, what if the engine says "feature setboard=0" or "analyze=0"? The use of the "UCI Logic" under Xboard protocol should not be possible. Other important features: draw=1|0, ping=1|0, reuse=1|0


Refs:

@drbeco
Copy link
Author

drbeco commented Jun 26, 2018

Not sure if this is the same problem, but here a different error message:

# scanf: setboard 2k1R3/7p/1pPB4/5p2/5Pn1/3N3p/P6P/1K6 b - - 5 37
# xboard: setboard. Xadreco will set a board position.
# scanf: time 12000.0 otim 12000.0
# xadreco time: meu: 168.0s opo:168.0s, para 24 lances: ajustado para st 7.000000 s por lance
# scanf: go
# xboard: go. Xadreco is now black.
# xadreco : I really don't know what to play... resigning!
# resign
# 1-0 {Black resigns}
# scanf: result 1-0
ERROR:backoff:Giving up api_post(...) after 1 tries (requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/bot/game/dmSjdbdh/move/-1)
# scanf: quit
# xadreco : # Thanks for playing Xadreco.
# xadreco : exit with status ( 0 )

The position given as setboard followed by a go command is actually already mate.

The loop for Xboard is different of that for UCI engines. This position would come to the engine by a human playing (in this case move e7e8) and the engine would return the result. By setting a position and asking "go", it misuses those commands. It makes no sense to Xboard protocol to set a mate position and say "go".

I have a fall back for error cases, and it tried to find a move and returned empty-handed (of course) and the it resigned as a default workaround (if you can't find a move in a given chess position, well, you better resign and go play checkers instead - kind of).

But, ok, nothing that I couldn't figure out. So, the engine is working under these strange circumstances of the Xboard protocol.

Still, the question is: what is that ERROR message above? About a bad request ?

If you guys want to address anything here, it is ok by me. Otherwise, we can just close this issue, because I guess I already solved the problem as stated above (workarounds...)

Thanks!

@gbtami
Copy link
Contributor

gbtami commented Jun 26, 2018

@drbeco you can read about this in #125

@drbeco
Copy link
Author

drbeco commented Jun 26, 2018

Exact!! Thank you @gbtami

@ShailChoksi
Copy link
Collaborator

@drbeco This might be solved from the recent code changes. Can you test?

@drbeco
Copy link
Author

drbeco commented Dec 17, 2018

@drbeco This might be solved from the recent code changes. Can you test?

@careless25 I'll be able to test after the hollidays, on january, as I'm on a trip. Thanks for bringing it up!

@MarkZH
Copy link
Collaborator

MarkZH commented Jan 15, 2022

The Xboard protocol, including offer draw and resign commands should be naturally handled with all the work done since this issue was opened. Please reopen if there are still problems.

@MarkZH MarkZH closed this as completed Jan 15, 2022
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

No branches or pull requests

4 participants