gambit icon indicating copy to clipboard operation
gambit copied to clipboard

ENH: Implementation of `__repr__` for mixed profiles

Open tturocy opened this issue 2 years ago • 0 comments

Overview

Currently pygambit has a simple implementation of __repr__ for MixedStrategyProfile and MixedBehaviorProfile (and the related classes that represent player or information set slices), which displays probabilities as a nested list.

This is not ideal, because these classes are dict-like and not list-like; those __repr__ implementations are therefore misleading. Further, they are of perhaps not that much utility for games with more than a few strategies or actions.

Proposal

We propose a new implementation of __repr__ which is more like that of a pandas.Series with hierarchical indexing.

Issues to consider:

  • When players, strategies, information sets, and/or actions are labeled, it is nature to use their labels in this representation. However, how should we handle the case of un-labeled elements?
  • The default for a pandas.Series is to truncate the representation of long objects by having an ellipsis in the middle. Should we also do this?
  • Note that the command-line tools already implement something like this in C++. Although it would be quite quick to implement this in pure Python, it might be worth considering refactoring the existing C++ so we have a commonality of implementation, even if doing the C++ string formatting will be slightly more tedious.

tturocy avatar Jan 14 '24 12:01 tturocy