[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted
From: |
Joern Thyssen |
Subject: |
Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted! |
Date: |
Fri, 11 Jul 2003 14:50:50 +0000 |
User-agent: |
Mutt/1.4.1i |
On Fri, Jul 11, 2003 at 03:00:46PM +0200, Jim Segrave wrote
>
> > Python and perl are other candidates. It looks quite easy to to embed
> > python into gnubg. We would have to provide a wrapper function for each
> > important gnubg function. Does anyone have experience with embedding
> > python into C-programs?
> >
> > Both perl and python has gtk extensions, so it also possible to make
> > user functions that creates dialogs etc.
>
> As a heavy user of Perl, please if we go this route, use Python.
Yes, I'm a bit attracted to python as well. Possibly because I already
know the syntax, although I haven't used it for some years.
I've attached a patch against gnubg.c 1.430 that embeds python in gnubg.
There is also a new file gnubgmodule.c.
You need to add the following flags to the Makefile:
COMMON_INCS:
-I/path/to/python.h (e.g.,-I/usr/include/python1.5)
COMMON_LIBS:
/path/to/libpython.a (e.g, /usr/lib/python1.5/config/libpython1.5.a)
-Wl,--export-dynamic (for gcc, I don't know about other compilers)
The escape to python is >.
Here's an example:
address@hidden gnubg-head2 850]$ gnubg -t
(No game) >print 1+1
2
or another example:
(No game) >
>>> import sys
>>> print sys.platform
linux-i386
>>> [Ctrl+D]
or a third example:
(No game) >
>>> import gnubg
>>> print gnubg.setcubeinfo()
{'jacoby': 1, 'crawford': 0, 'move': 0, 'beavers': 1, 'cube': 1,
'matchto': 0, 'bgv': 0, 'cubeowner': -1, 'score': (0, 0), 'gammonprice':
((0.0, 0.0), (0.0, 0.0))}
>>> print gnubg.setcubeinfo(4,1,1,9,(0,4),0)
{'jacoby': 0, 'crawford': 0, 'move': 1, 'beavers': 0, 'cube': 4,
'matchto': 9, 'bgv': 0, 'cubeowner': 1, 'score': (0, 4), 'gammonprice':
((1.55229616165, 0.679036140442), (0.231332331896, 1.20560128547e-09))}
>>> [Ctrl+D]
Very fun and simple!
Of course, I just need to add interfaces to the remaining 200 internal
gnubg functions.
Joseph, is this something that could be useful for you?
Jørn
pythonpatch.tar.gz
Description: application/tar-gz
- [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Øystein Johansen, 2003/07/10
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joern Thyssen, 2003/07/10
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Holger, 2003/07/10
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joseph Heled, 2003/07/10
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joern Thyssen, 2003/07/11
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joern Thyssen, 2003/07/11
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Jim Segrave, 2003/07/11
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!,
Joern Thyssen <=
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joseph Heled, 2003/07/11
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joern Thyssen, 2003/07/11
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joseph Heled, 2003/07/11
- Re: [Bug-gnubg] New fuctionallity for batch operations, opinions wanted!, Joern Thyssen, 2003/07/11