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