Repository: sagemath/sage

Issue:
Remove broken experimental package gambit
<div id="comment:0"></div>

It is not compatible with python 3.

https://github.com/mkoeppe/sage/runs/876312037

```
  [gambit-15.1.1.p0]   make[2]: Leaving directory '/sage/local/var/tmp/sage/build/gambit-15.1.1.p0/src'
  [gambit-15.1.1.p0]   Traceback (most recent call last):
  [gambit-15.1.1.p0]     File "setup.py", line 32, in <module>
  [gambit-15.1.1.p0]       m.Extension.__dict__ = m._Extension.__dict__
  [gambit-15.1.1.p0]   AttributeError: attribute '__dict__' of 'type' objects is not writable
  [gambit-15.1.1.p0]   Error installing Python API
  [gambit-15.1.1.p0]   
```

Another failure report: `cygwin` linking trouble - https://groups.google.com/g/sage-devel/c/HisDSCo7zlk/m/dAs5K5OrBwAJ

Upstream looks unattended. The last releases are from 2017.

https://github.com/gambitproject/gambit/issues

http://www.gambit-project.org/


https://github.com/gambitproject/gambit/pull/242

https://repology.org/project/gambit-game-theory/versions

Previous tickets: #24840, #24012

CC:  @dimpase @theref @kcrisman @nathanncohen @drvinceknight @tscrim @jhpalmieri

Component: **packages: experimental**

_Issue created by migration from https://trac.sagemath.org/ticket/30156_




Discussion:
Description changed:
``````diff
--- 
+++ 
@@ -1,6 +1,11 @@
 It is not compatible with python 3.
 
-Upstream looks unattended. https://github.com/gambitproject/gambit/issues
+Upstream looks unattended. The last releases are from 2017.
+
+https://github.com/gambitproject/gambit/issues
+
+http://www.gambit-project.org/
+
 
 https://github.com/gambitproject/gambit/pull/242
 
``````

Description changed:
``````diff
--- 
+++ 
@@ -1,4 +1,17 @@
 It is not compatible with python 3.
+
+https://github.com/mkoeppe/sage/runs/876312037
+
+```
+  [gambit-15.1.1.p0]   make[2]: Leaving directory '/sage/local/var/tmp/sage/build/gambit-15.1.1.p0/src'
+  [gambit-15.1.1.p0]   Traceback (most recent call last):
+  [gambit-15.1.1.p0]     File "setup.py", line 32, in <module>
+  [gambit-15.1.1.p0]       m.Extension.__dict__ = m._Extension.__dict__
+  [gambit-15.1.1.p0]   AttributeError: attribute '__dict__' of 'type' objects is not writable
+  [gambit-15.1.1.p0]   Error installing Python API
+  [gambit-15.1.1.p0]   
+```
+
 
 Upstream looks unattended. The last releases are from 2017.
 
``````

<div id="comment:3" align="right">comment:3</div>

I've also emailed Vince Knight, who might know more about Gambit status.
<div id="comment:4" align="right">comment:4</div>

no reply - so let's just remove it.
<div id="comment:5" align="right">comment:5</div>

however there is a lot of stuff in src/sage/games/ that needs it.
<div id="comment:6" align="right">comment:6</div>

Let's give people a bit of time to react. This is not urgent. When we have collected a bit more information on Meta-ticket #29900 (Fix optional and experimental packages for Sage 9.2), we can perhaps also send a message to sage-users
<div id="comment:7" align="right">comment:7</div>

This is our one current use of game theory in Sage. I think a better solution is to extract PR242 as a patch to Sage. (I forget why this was downgraded to experimental in the first place.) We might also consider forking this to include some of the updates, something I would consider doing, but I probably wouldn't be able to do anything with it long-term.
<div id="comment:8" align="right">comment:8</div>

I agree we should wait on this - perhaps contacting the maintainer of Gambit itself.
<div id="comment:9" align="right">comment:9</div>

The primary author got back to me saying that's fine, he'll want to do a better Python API anyway (he considers the current one to be unstable), but not before finishing his term as a dean... That is yes, we ought to remove it.
<div id="comment:10" align="right">comment:10</div>

remvove "it" = the python interface, or the whole package?
<div id="comment:11" align="right">comment:11</div>

the whole package, I suppose
<div id="comment:12" align="right">comment:12</div>

What about the current doctests etc that rely on it?  It would be unfortunate to remove them completely - but perhaps need to have some warnings on those files that the Gambit tests are currently broken and to use a previous version of Sage if you need that functionality for now.
<div id="comment:13" align="right">comment:13</div>

If no one can install the package, they won't easily be able to run the doctests, so they can stay. If you want to add some warnings where it says "Run `sage -i gambit` ...", that would probably be a good idea.
<div id="comment:14" align="right">comment:14</div>

Are there parts of the Sage game theory code depend on the Gambit executables, or does everything depend on the broken Gambit Python library?
<div id="comment:16" align="right">comment:16</div>

Gambit 16 does not support Python 3. The current master branch does.
<div id="comment:17" align="right">comment:17</div>

> Gambit 16 does not support Python 3. The current master branch does.

Interesting.  Maybe it would be worth simply packaging as such?  Unfortunately it wouldn't appear to currently be pip-installable.
<div id="comment:18" align="right">comment:18</div>

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.
Description changed:
``````diff
--- 
+++ 
@@ -12,6 +12,7 @@
   [gambit-15.1.1.p0]   
 ```
 
+Another failure report: `cygwin` linking trouble - https://groups.google.com/g/sage-devel/c/HisDSCo7zlk/m/dAs5K5OrBwAJ
 
 Upstream looks unattended. The last releases are from 2017.
 
``````

It's 2024 and gambit is back: http://www.gambit-project.org/, including `pygambit`, supporting Python >= 3.8 - https://pypi.org/project/pygambit/#history

Closing in favor of:
- #37809

Resolving patch:
diff --git a/src/sage/game_theory/gambit_docs.py b/src/sage/game_theory/gambit_docs.py
deleted file mode 100644
--- a/src/sage/game_theory/gambit_docs.py
+++ /dev/null
@@ -1,139 +0,0 @@
-"""
-Using Gambit as a standalone package
-
-This file contains some information and tests for the use of
-`Gambit <http://www.gambit-project.org/>`_ as a stand alone package.
-
-To install gambit as an optional package run (from root of Sage)::
-
-    $ sage -i gambit
-
-The `python API documentation for gambit
-<http://www.gambit-project.org/gambit14/pyapi.html>`_ shows various examples
-that can be run easily in IPython. To run the IPython packaged with Sage run
-(from root of Sage)::
-
-    $ ./sage --ipython
-
-Here is an example that constructs the Prisoner's Dilemma::
-
-    In [1]: import gambit
-    In [2]: g = gambit.Game.new_table([2,2])
-    In [3]: g.title = "A prisoner's dilemma game"
-    In [4]: g.players[0].label = "Alphonse"
-    In [5]: g.players[1].label = "Gaston"
-    In [6]: g
-    Out[6]:
-    NFG 1 R "A prisoner's dilemma game" { "Alphonse" "Gaston" }
-
-    { { "1" "2" }
-    { "1" "2" }
-    }
-    ""
-
-    {
-    { "" 0, 0 }
-    { "" 0, 0 }
-    { "" 0, 0 }
-    { "" 0, 0 }
-    }
-    1 2 3 4
-
-    In [7]: g.players[0].strategies
-    Out[7]: [<Strategy [0] '1' for player 'Alphonse' in game 'A
-    prisoner's dilemma game'>,
-             <Strategy [1] '2' for player 'Alphonse' in game 'A prisoner's dilemma game'>]
-    In [8]: len(g.players[0].strategies)
-    Out[8]: 2
-
-    In [9]: g.players[0].strategies[0].label = "Cooperate"
-    In [10]: g.players[0].strategies[1].label = "Defect"
-    In [11]: g.players[0].strategies
-    Out[11]: [<Strategy [0] 'Cooperate' for player 'Alphonse' in game 'A
-    prisoner's dilemma game'>,
-       <Strategy [1] 'Defect' for player 'Alphonse' in game 'A prisoner's dilemma game'>]
-
-    In [12]: g[0,0][0] = 8
-    In [13]: g[0,0][1] = 8
-    In [14]: g[0,1][0] = 2
-    In [15]: g[0,1][1] = 10
-    In [16]: g[1,0][0] = 10
-    In [17]: g[1,1][1] = 2
-    In [18]: g[1,0][1] = 2
-    In [19]: g[1,1][0] = 5
-    In [20]: g[1,1][1] = 5
-
-Here is a list of the various solvers available in gambit:
-
-- ExternalEnumPureSolver
-- ExternalEnumMixedSolver
-- ExternalLPSolver
-- ExternalLCPSolver
-- ExternalSimpdivSolver
-- ExternalGlobalNewtonSolver
-- ExternalEnumPolySolver
-- ExternalLyapunovSolver
-- ExternalIteratedPolymatrixSolver
-- ExternalLogitSolver
-
-Here is how to use the ``ExternalEnumPureSolver``::
-
-    In [21]: solver = gambit.nash.ExternalEnumPureSolver()
-    In [22]: solver.solve(g)
-    Out[22]: [<NashProfile for 'A prisoner's dilemma game': [Fraction(0, 1), Fraction(1, 1), Fraction(0, 1), Fraction(1, 1)]>]
-
-Note that the above finds the equilibria by investigating all potential pure
-pure strategy pairs. This will fail to find all Nash equilibria in certain
-games.  For example here is an implementation of Matching Pennies::
-
-    In [1]: import gambit
-    In [2]: g = gambit.Game.new_table([2,2])
-    In [3]: g[0, 0][0] = 1
-    In [4]: g[0, 0][1] = -1
-    In [5]: g[0, 1][0] = -1
-    In [6]: g[0, 1][1] = 1
-    In [7]: g[1, 0][0] = -1
-    In [8]: g[1, 0][1] = 1
-    In [9]: g[1, 1][0] = 1
-    In [10]: g[1, 1][1] = -1
-    In [11]: solver = gambit.nash.ExternalEnumPureSolver()
-    In [12]: solver.solve(g)
-    Out[12]: []
-
-If we solve this with the ``LCP`` solver we get the expected Nash equilibrium::
-
-    In [13]: solver = gambit.nash.ExternalLCPSolver()
-    In [14]: solver.solve(g)
-    Out[14]: [<NashProfile for '': [0.5, 0.5, 0.5, 0.5]>]
-
-Note that the above examples only show how to build and find equilibria for
-two player strategic form games. Gambit supports multiple player games as well
-as extensive form games: for more details see http://www.gambit-project.org/.
-
-If one really wants to use gambit directly in Sage (without using the
-``NormalFormGame`` class as a wrapper) then integers must first be
-converted to Python integers (due to the preparser). Here is an example
-showing the Battle of the Sexes::
-
-    sage: # optional - gambit
-    sage: 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]]>]
-
-AUTHOR:
-
-- Vince Knight (11-2014): Original version
-
-"""
diff --git a/src/sage/game_theory/normal_form_game.py b/src/sage/game_theory/normal_form_game.py
--- a/src/sage/game_theory/normal_form_game.py
+++ b/src/sage/game_theory/normal_form_game.py
@@ -236,8 +236,7 @@
   `Gambit <http://gambit.sourceforge.net/>`_ [Gambit]_. At present this is
   the only gambit algorithm available in sage but further development will
   hope to implement more algorithms
-  (in particular for games with more than 2 players). To install it,
-  type ``sage -i gambit`` in the shell.
+  (in particular for games with more than 2 players).
 
 * ``'enumeration'``: Support enumeration for 2 player games. This
   algorithm is hard coded in Sage and checks through all potential


Test patch: