#16466: Add gambit as an optional package
-------------------------------------+-------------------------------------
Reporter: jcampbell | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.4
Component: packages: | Resolution:
optional | Merged in:
Keywords: | Reviewers: Thierry Monteil,
Authors: James Campbell, | Karl-Dieter Crisman
Vince Knight | Work issues:
Report Upstream: N/A | Commit:
Branch: | 1005e9d1079dbe7567b2870c8147fa6b9bfd1f6c
u/vinceknight/gambit | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by vinceknight):
Replying to [comment:40 kcrisman]:
> You already have #16333 for the purposes of actually writing the gambit
interface, as long as a few examples we test here work out properly this
time I think this ticket should be ''just'' for adding gambit. Maybe you
could put in a couple absolutely minimal gambit-optional doctests to
verify that it imports and creates a game, I guess. This could be in a
file gambit.py that just serves as a way for people to test and use it
independently of Sage (though see below because of the preparser):
>
> For instance, I still get the following (it does compile now):
> {{{
> sage: sage: import gambit
> sage: sage: gambit.Game.new_tree()
> EFG 2 R "" { }
> ""
>
> t "" 0
> sage: g.players[0].label="A" # turns out not to work in Sage because of
preparer, that's okay
>
---------------------------------------------------------------------------
> TypeError: collection indexes must be int or str, not Integer
> sage: g.players[int(0)].label="A"
> }}}
> I can't find the previously non-working version in the documentation
now, maybe that was changed. For posterity, it doesn't work now.
> {{{
> sage: sage: gambit.new_tree()
>
---------------------------------------------------------------------------
> AttributeError Traceback (most recent call
last)
> <ipython-input-3-46627785e350> in <module>()
> ----> 1 gambit.new_tree()
>
> AttributeError: 'module' object has no attribute 'new_tree'
> }}}
>
> Travis, did you try any actual gambit examples? If these work I guess
that would be enough.
>
> Vincent, I think that the gambit documentation still leaves something to
be desired. For instance,
> {{{
> In [1]: g = gambit.Game.read_game("e02.nfg")
> }}}
> doesn't work right, because the file is not there (I guess). In R and
similar things there is a standard way to access such built-in examples.
Not necessary per se, but it would be nice if examples worked right.
Not too sure where the gambit.py would go but like the idea of writing
tests for it: would I put it in the game_theory folder and just make sure
it doesn't come up in the docs etc...?
For simplicity here is some code you can just paste in to a Sage session
to test gambit:
A prisoner's dilemma:
{{{
sage: import gambit
sage: g = gambit.Game.new_table([2,2])
sage: g[int(0), int(0)][int(0)] = int(8)
sage: g[int(0), int(0)][int(1)] = int(8)
sage: g[int(0), int(1)][int(0)] = int(2)
sage: g[int(0), int(1)][int(1)] = int(10)
sage: g[int(1), int(0)][int(0)] = int(10)
sage: g[int(1), int(0)][int(1)] = int(2)
sage: g[int(1), int(1)][int(0)] = int(5)
sage: g[int(1), int(1)][int(1)] = int(5)
sage: solver = gambit.nash.ExternalLCPSolver()
sage: solver.solve(g)
[<NashProfile for '': [0.0, 1.0, 0.0, 1.0]>]
}}}
A battle of the sexes:
{{{
e: import gambit
sage: g = gambit.Game.new_table([2,2])
sage: g[int(0), int(0)][int(0)] = int(2)
sage: g[int(0), int(0)][int(1)] = int(1)
sage: g[int(0), int(1)][int(0)] = int(0)
sage: g[int(0), int(1)][int(1)] = int(0)
sage: g[int(1), int(0)][int(0)] = int(0)
sage: g[int(1), int(0)][int(1)] = int(0)
sage: g[int(1), int(1)][int(0)] = int(1)
sage: g[int(1), int(1)][int(1)] = int(2)
sage: solver = gambit.nash.ExternalLCPSolver()
sage: solver.solve(g)
[<NashProfile for '': [1.0, 0.0, 1.0, 0.0]>,
<NashProfile for '': [0.6666666667, 0.3333333333, 0.3333333333,
0.6666666667]>,
<NashProfile for '': [0.0, 1.0, 0.0, 1.0]>]
}}}
I assume this is the sort of stuff (with more documentation) that would go
in to the gambit.py file.
For info, these are examples we had checked ourselves and is what is
required for us to get the LCP solver working in `NormalFormGame`.
--
Ticket URL: <http://trac.sagemath.org/ticket/16466#comment:41>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.