On 03/06/2013 10:38 AM, Ian Shaw wrote:
> Ah! I see what you mean now. Good spot Philippe; I hadn't noticed.
>
Yes, the downside to setting matchid is that it resets the game list. So
if you are trying to keep all the results in a single file then your
method would have to be used. If that is what you had in mind, I amended
my previous script (rather trivial change) to do what you were looking
for as well.
--
Michael Petch
GNU Backgammon Developer
OpenPGP FingerPrint=D81C 6A0D 987E 7DA5 3219 6715 466A 2ACE 5CAE 3304
import itertools, sys
# Setup the the initial board for 43Z
matchid = 'cAkAAAAAAAAA'
board = '4HPhASLgc/ABMA'
#important to use a full path to a writeable directory
outputpath = 'C:\Users\mpetch.CAPP-SYSWARE\Desktop'
fileprefix = '43Z-reply'
gnubg.command ('set player 1 gnubg')
gnubg.command ('set player 0 human')
gnubg.command ('set matchid %s' % (matchid))
# This loop generates a pair of dice for each of the 21 different rolls
# that are possible when throwing a pair of 6 sided dice.
for (die1, die2) in itertools.combinations_with_replacement (range(1,7), 2):
# Print some debug output
print '\n%s\n%s, Roll: %1d,%1d\n\n' % ('-'*80, gnubg.gnubgid(), die1,
die2)
sys.stdout.flush()
# Setup the position and get the computers choices.
gnubg.command ('set board %s' % (board))
gnubg.command ('set turn 1')
gnubg.command ('set dice %d %d' % (die1, die2))
# Hint is being used here to dump the top moves to standard output
# One must make sure the skill level for the gnubg player is the same
# as the eval/hint skill level for the play moved to be the same as
# the best play. If one doesn't care about standard output then this
# can be omitted.
gnubg.command ('hint')
# Play the best move
gnubg.command ('play')
sys.stdout.flush()
# Save all the results into an SGF file
filename = '%s\%s.sgf' % (outputpath,fileprefix)
gnubg.command('save match "%s"' % (filename))
_______________________________________________
Bug-gnubg mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-gnubg