A simply python example of what you are doing could look something like
the attached file

Python is already embedded inside of GNUBG, so no need to install python
separately. From a command line you could do something like:

"C:\Program Files (x86)\gnubg\gnubg-cli.exe" -q -p
"C:\path\to\43Z-reply.py" >c:\path\to\outputfile.txt

This will run the python script with gnubg-cli with sound turned off.
All the output will be directed to a specified output file. It is
important to use full path names.

Inside the script file you can also specify the path to save all the SGF
file for each of the positions that get analyzed.

This was quick and dirty, but might give you an example of what can be
achieved with some python code.

-- 
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')

# 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):

        filename = '%s\%s_roll%1d%1d.sgf' % (outputpath,fileprefix, die1, die2)
        
        # Print some debug output
        print '\n%s\n%s\n' % ('-'*80, filename)
        sys.stdout.flush()

        # Setup the position and get the computers choices.
        gnubg.command ('set matchid %s' % (matchid))
        gnubg.command ('set board %s' % (board))
        gnubg.command ('set turn 1')
        gnubg.command ('set dice %d %d' % (die1, die2))
        gnubg.command ('hint')
        gnubg.command ('play')
        sys.stdout.flush()
        
        # Save each result into an SGF file
        gnubg.command('save match "%s"' % (filename))
_______________________________________________
Bug-gnubg mailing list
Bug-gnubg@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-gnubg

Reply via email to