[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need a little help with Python script error
From: |
MK |
Subject: |
Need a little help with Python script error |
Date: |
Sat, 20 Jan 2024 22:44:15 -0700 |
User-agent: |
Mozilla Thunderbird |
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.
MK
==============================================================
Exception Traceback (most recent call last)
<ipython-input-7-ff647b75da95> in <cell line: 2>()
51 continue
52 gnubg.command('roll') # had access to cube with no action, now make
move
---> 53 bestmove = gnubg.findbestmove()
54 board = gnubg.board()
55 move = gnubg.movetupletostring(bestmove, board)
Exception: What? No dice?
Exception Traceback (most recent call last)
<ipython-input-5-ff647b75da95> in <cell line: 2>()
20 if cubeowner == 0 and doubled ==0: # don't have access to cube,
just move
21 gnubg.command('roll')
---> 22 bestmove = gnubg.findbestmove()
23 board = gnubg.board()
24 move = gnubg.movetupletostring(bestmove, board)
Exception: What? No dice?
==============================================================
session = 1
while session < 2: # set to number games wanted
session = session + 1
gnubg.command('new game')
movecount = 0 # will be used later to determine game stages
gamestate = 1
while gamestate == 1:
posinfo = gnubg.posinfo()
turn = posinfo['turn']
resigned = posinfo['resigned']
doubled = posinfo['doubled']
gamestate = posinfo['gamestate'] # 0=no game 1=playing 2=over 3=resigned
4=dropped
movecount = movecount + 1
if resigned == 1:
gnubg.command('agree')
break
cubeinfo = gnubg.cubeinfo()
cubeowner = cubeinfo['cubeowner'] # bot=0 human=1 center=-1
beaver = cubeinfo['beavers']
if cubeowner == 0 and doubled ==0: # don't have access to cube, just move
gnubg.command('roll')
bestmove = gnubg.findbestmove()
board = gnubg.board()
move = gnubg.movetupletostring(bestmove, board)
gnubg.command(move)
continue
cubeless = gnubg.evaluate()
win = cubeless[0] # cubeless win%
if turn == 1 and doubled == 1: # respond to bot's double
if win > 0.50 and beaver < 2:
gnubg.command('beaver')
continue
elif win > 0:
gnubg.command('take')
continue
else:
gnubg.command('drop')
break
if turn == 1 and beaver == 1: # respond to bot's beaver
if win > 0:
gnubg.command('take')
continue
else:
gnubg.command('drop')
break
if cubeowner == 1 or cubeowner == -1: # double
if win > 0.50 and movecount > 1:
gnubg.command('double')
continue
gnubg.command('roll') # had access to cube with no action, now make move
bestmove = gnubg.findbestmove()
board = gnubg.board()
move = gnubg.movetupletostring(bestmove, board)
gnubg.command(move)
filename = 'D:\mk' + str(session) # will use better file names later
gnubg.command("'save game' filename")
gnubg.command('exit')
==============================================================
- Need a little help with Python script error,
MK <=