bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] The match and game data structure


From: Jim Segrave
Subject: Re: [Bug-gnubg] The match and game data structure
Date: Fri, 30 Jun 2006 17:47:34 +0200
User-agent: Mutt/1.4.2.1i

On Fri 30 Jun 2006 (07:55 -0700), David Levy wrote:
> Earlier I had asked some questions about the python match() command (and how
> it relates to various set commands and the internal data structure) that:
> 
> (1) Probably exposed my ignorance about the data structure; and
> (2) Attracted no replies (perhaps because everyone was excited about the
> gnubg victory in the bot tourney).
> 
> A repost:
> 
> I have been exploring the python interface exposed by gnubg and found much
> help in scripts posted online.
> 
> For example, I am able to load a match, get the dictionary returned by
> m=gnubg.match() and navigate through games and actions. In particular, I am
> able to look at the analysis (rollout or evaluation) of cube decisions and
> checker play -- my major goal. 
> 
> [Aside: The only suggestion I would make would be to add a more detailed
> rollout context to the analysis records. The current rollout context shows
> number of trials, but not the full context including truncation points,
> plies, etc.] 

That's incorrect - there's enough data held to allow resuming a
rollout to extend the number of trials.

 
> I am, however, having difficulty using gnubg.match() when I create the match
> using various 'set' commands with gnubg.command('xxxxxx'). 
> 
> Example 1: Evaluation/Rollout of checker play
> 
> With the following commands I can get evaluations and rollouts of all
> candidate checker plays for a position and roll (some details omitted):
> 
> gnubg.command('set matchid cAkKAAAAAAAA')   #money play
> gnubg.command('set board jM/BATDYZvABMA')   #position of interest
> gnubg.command('set dice 64')                #roll of interest
> gnubg.command('set cube center')
> gnubg.command('set cube value 1')
> gnubg.command('hint')                       #displays evaluation results to
> stdout
> gnubg.command('rollout=1')                  #rollout first move
> ...                                         #more rollouts
> gnubg.command('hint')                       #display rollout results to
> stdout
> m=gnubg.match()                             #see "Problem" discussion below
> 
> Example 2: Evaluation of cube decision
> 
> I can give the following commands in python to see an evaluation of a cube
> decision (some details omitted):
> 
> gnubg.command('set matchid cAkKAAAAAAAA')   #money play
> gnubg.command('set board jM/BATDYZvABMA')   #position of interest
> gnubg.command('set cube value 1')
> gnubg.command('set cube center')
> gnubg.command('set turn playerX')           #player to act on cube
> gnubg.command('hint')                       #display evaluation results to
> stdout
> m=gnubg.match()                             #see "Problem" discussion below
> 
> Problem: 
> 
> I was hoping that I could issue the same sequence of commands and then read
> the dictionary returned by gnubg.match() to see the same evaluation or
> rollout results. I do see all of my set commands as actions. For example. I
> do see the position I have set. But gnubg does not seem to want to play the
> match from the indicated position. I've tried many permutations of setting
> the players to be human or gnubg, setting automatic roll on or off, adding
> the command 'analyze match,' asking the computer to 'play,' etc. But if what
> I'm trying to do is possible, I haven't found the right sequence of
> commands. 
> 
> So:
> 
> Is there some sequence of set commands I can issue so that I can see what I
> want in the dictionary returned by gnubg.match()?
> 
> Or must I continue to redirect stdout to a file and (ugh) parse the output
> of 'hint'?

The problem is that you need a move record to attach the analysis or
rollout results to. Then you could use the gnubg.command("analyse move") 
to get the results back in the match dictionary.
I tried the following in a cli version of gnubg (I've deleted most of the
output from gnubg for clarity):

Script started on Fri Jun 30 17:35:41 2006
address@hidden:/home/address@hidden:/home/jes$ gnubg -t
GNU Backgammon 0.14.3-develCopyright 1999, 2000, 2001, 2002, 2003, 2004 by Gary\
 Wong.
GNU Backgammon is free software, covered by the GNU General Public License
version 2, and you are welcome to change it and/or distribute copies of it
under certain conditions.  Type "show copying" to see the conditions.
There is absolutely no warranty for GNU Backgammon.  Type "show warranty" for 
details.

*** get gnubg ready to have a position set up
*** then enter python
(No game) new match 5
(Brendon) >>>
Python 2.4 (#2, Mar 29 2005, 12:22:14)
>>> gnubg.command('set matchid cAkKAAAAAAAA')
>>> gnubg.command('set board jM/BATDYZvABMA')
>>> gnubg.command('set cube value 1')
>>> gnubg.command('set cube center')

Make an arbitrary (and not well chosen) move:
>>> gnubg.command('24/20 13/11')

*** gnubg then responds with it's move, returning back to python for
*** playerX (or in this case player 'Brendon') to make his next move
***
*** step back to Brendon's previous move
>>> gnubg.command(prev 2')

*** ask gnubg to analyse the move
>>> gnubg.command('analyse move')

*** as a check, I'll save the match with it's one analysed move as an
*** .sgf file
>>> gnubg.command('save mat /tmp/thingy.sgf')
>>> print gnubg.match()

*** I won't post this, suffice it to say that there is a full analysis of
*** the match, or in this case the move in question here

Script done on Fri Jun 30 17:39:12 2006

And yes, the sgf file has the analysis of the move as well.

-- 
Jim Segrave           address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]