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