[Top][All Lists]

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

Re: [Bug-gnubg] Python Support

From: Jim Segrave
Subject: Re: [Bug-gnubg] Python Support
Date: Thu, 5 Aug 2004 21:46:55 +0200
User-agent: Mutt/1.4.1i

On Thu 05 Aug 2004 (10:29 +0200), address@hidden wrote:
> Hi all
> I've installed the newest version of gnubg (i hope) on a windows xp.
> After removing Python 2.3.x and installing 2.2.x all works well:
> - python standalone
> - gnubg_no_gui python support works fine
> But I have still some problems, where I need some help.
> First: I'm currently try to build a new FIBS bot, fully written in Python.
> The problem is, that I can't get the output of the "hint" command from gnubg.
> And I don't find another command unter python (dir(gnubg) to get this 
> information.
> That's what I'm doing after starting gnubg-no-gui:

The trouble is that gnubg.command("hint") doesn't return anything. And
you also won't succeed in redirecting stdout, you can redirect the
Python interpreter's stdout, but that has no effect on gnubg itself
(when gnubg calls printf(), it uses the original file handle. 

What's needed is to add another interface function to gnubgmodule.c
which returns the results of a hint command. I had a qucik look - in
gnubg.c, CommandHint() looks at the current situation and calls one of
HintCube(), HintChequer(), or HintResign() as appropriate. Each of
these get an evaluation of the possible plays, generally into an
array of floats, then call either the GTK output formatting or print
output formatting. Changing these to separate out the getting of the
data and the selecting and calling of the output routines would
provide the core functionality to return the needed data to a Python
interface routine. I'd guess you't want gnubg.hint() in Python to
return a sequence of actions sorted into best equity order and a flag
indicating what sort of actions might are listed - say a tuple with
two items, perhaps something like (action, [data])

where action would be one of "Double" "Pass" "Beaver" "Take" "Resign" pr "Move"
and data would be list of analyses for the various options, 
  for Double, it would be [double_analysis, no-double-analysis],
  reversed for Take, etc.
  for "Move", it would be a list of moves and analyses for the various
  legal moves, in descending equity order

For your purposes (a FIBS bot), you technically don't need the
analaysis, you only need to know what action to take, but if anyone is
going to implement such an interface, it seems absurd to discard
useful data in the return. I've only started looking at how Python's
interface is embedded into gnubg, but from that first cursory look, it
doesn't seem like it should be an enormous effort to do this.

Jim Segrave           address@hidden

reply via email to

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