-
Notifications
You must be signed in to change notification settings - Fork 165
Description
This feature request is for...
PyGambit
Requested enahancement or feature
When working on #542 I noticed there doesn't seem to be a way to display the Game trees for extensive form games with Python.
For normal form games, after you have set up a game with Game.new_table and then added payoffs, there is a nice feature in a Jupyter notebook where running a cell with the pygambit.gambit.Game object displays the payout matrix pandas-style:
It would be very useful for the tutorials and in general to be able to quickly view the shape of your extensive form Game object set up with Game.new_tree with a display function, which could similarly get triggered when just running a cell with the game object. You could see the tree grow as you add nodes.
Relatedly, in the current user guide, calling g.root.children doesn't show anything different when you append a move see user guide where code output doesn't change. But if doing so called the display function, it would be clearer what has changed.
Implementation
It might make sense to use an existing library, perhaps we could convert a Gambit game to NetworkX to make use of that plotting functionality.
Drawbacks
I guess this may end up being quite a big task as it could entail re-implementing a lot of the visualisation features already present in the GUI. That being said, I can imagine this would be very handy especially for viewing large extensive form games with modern Python plotting libraries.
@tturocy @rahulsavani @d-kad Is this something you have already discussed, or did I miss a way to do this that already exists? For me, when learning the PyGambit API in a notebook context exploring setting up a game, it feels difficult not being able to see the tree I'm building as I go