[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need a little help with Python script error
From: |
Philippe Michel |
Subject: |
Re: Need a little help with Python script error |
Date: |
Sun, 28 Jan 2024 18:12:37 +0100 |
On Sat, Jan 20, 2024 at 10:43:48PM -0700, MK wrote:
> With whatever bits of documentation I could find, I was able to
> write my first simple script to play a money game against the bot.
>
> It tries to duplicate a experiment done a couple of years ago in
> RGB by Axel, doubling at >50% and taking at >0%.
>
> It seems to be working except for "What? No dice?" errors at
> different times but invariably in every game, mostly towards the
> end but sometimes even after the game finishes.
>
> All auto roll/play settings are off. I wonder if the script gets
> ahead of or lags behind the bot or such..? Below are the errors
> followed by the script itself. Thanks for any help.
Hello Murat,
I have to agree that the error message is silly. But what it means is
that you tried to find the best checkers move without having rolled the
dice.
There may be some bugs in gnubg's code, but in your script as well. I
tried it and found one simple example of the latter (and its fix) and
could reproduce the dancing-related failure you mention in a recent post
to rec.games.backammon, but in this case this looks more complicated ; I
think I understand what happens but didn't found exactly how it does and
have no correction to offer.
Simple failure:
GNU Backgammon Position ID: 9wAAAODz4IEEAA
Match ID : BEkAAAAAAAAA
+12-11-10--9--8--7-------6--5--4--3--2--1-+ O: GNUbg (Cube: 16)
| O | | O | 0 points
| O | | O | On roll, resigns gammon
| O | | O |
| O | | O |
| | | O |
^| |BAR| |
| | | | X
| O | | X | X
| O | | X X | XX
| O | | X X | XX
| O | | O O X X | XX 0 points
+13-14-15-16-17-18------19-20-21-22-23-24-+ X: You
Please resolve the resignation first.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "mk.py", line 22, in <module>
bestmove = gnubg.findbestmove()
Exception: What? No dice?
Note the "resigns gammon". You do this:
if resigned == 1:
gnubg.command('agree')
break
but resigned, that is posinfo['resigned'], is not a 0/1 false/true flag,
it is the number of points resigned. Here its value is 2. You should use
if resigned >= 1:
In the dance cases, I see something like:
GNU Backgammon Position ID: m22MEgB68xwAQA
Match ID : VwkAAAAAAAAA
+13-14-15-16-17-18------19-20-21-22-23-24-+ O: GNUbg
| O O | | O O O O O | 0 points
| O | | O O O O O |
| | | |
| | | |
| | | |
v| |BAR| |
| | | |
| | | X X |
| X | | X X |
| X | | X X X | On roll
| O O X | X | X X X X | 0 points
+12-11-10--9--8--7-------6--5--4--3--2--1-+ X: You (Cube: 128)
GNU Backgammon Position ID: m22MEgB68xwAQA
Match ID : VwkGAAAAAAAA
+13-14-15-16-17-18------19-20-21-22-23-24-+ O: GNUbg
| O O | | O O O O O | 0 points
| O | | O O O O O |
| | | |
| | | |
| | | |
v| |BAR| |
| | | |
| | | X X |
| X | | X X |
| X | | X X X | Rolled 41
| O O X | X | X X X X | 0 points
+12-11-10--9--8--7-------6--5--4--3--2--1-+ X: You (Cube: 128)
You cannot move.
GNU Backgammon Position ID: evMcAECbbYwSAA
Match ID : FwEAAAAAAAAA
+12-11-10--9--8--7-------6--5--4--3--2--1-+ O: GNUbg
| O O | | O O O O O | 0 points
| O | | O O O O O | On roll
| | | |
| | | |
| | | |
^| |BAR| |
| | | |
| | | X X |
| X | | X X |
| X | | X X X |
| O O X | X | X X X X | 0 points
+13-14-15-16-17-18------19-20-21-22-23-24-+ X: You (Cube: 128)
GNU Backgammon Position ID: evMcAECbbYwSAA
Match ID : FwEOAAAAAAAA
+12-11-10--9--8--7-------6--5--4--3--2--1-+ O: GNUbg
| O O | | O O O O O | 0 points
| O | | O O O O O | Rolled 43
| | | |
| | | |
| | | |
^| |BAR| |
| | | |
| | | X X |
| X | | X X |
| X | | X X X |
| O O X | X | X X X X | 0 points
+13-14-15-16-17-18------19-20-21-22-23-24-+ X: You (Cube: 128)
GNUbg moves 13/6.
GNU Backgammon Position ID: m+0YEQB68xwAQA
Match ID : VwkAAAAAAAAA
+13-14-15-16-17-18------19-20-21-22-23-24-+ O: GNUbg
| O O | | O O O O O | 0 points
| O | | O O O O O |
| | | O |
| | | |
| | | |
v| |BAR| |
| | | |
| | | X X |
| X | | X X |
| X | | X X X | On roll
| O X | X | X X X X | 0 points
+12-11-10--9--8--7-------6--5--4--3--2--1-+ X: You (Cube: 128)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "mk.py", line 53, in <module>
bestmove = gnubg.findbestmove()
Exception: What? No dice?
What seems to happen is:
diagram 1:
it's your turn, you don't double
diagram 2:
you roll a 4-1 dancing number, gnubg detects this, prints "You cannot
move." and carries on without letting you interact since you have
nothing to do.
diagrams 3 and 4:
gnubg rolls and plays something
diagram 5:
it's your turn, you are expected to double or roll but you try to find a
best move, presumably for the previous 4-1, because you didn't realize
what happend since then.