pygambit.gambit.Game.relabel_actions#
- Game.relabel_actions(infoset: Selector, labels: Mapping[str, str], strict: bool = True) None#
Simultaneously reassign the labels of actions at the information set or event that the node identified by infoset belongs to.
labels maps current action labels to their replacements. The reassignment is simultaneous, so labels can be swapped directly, e.g.
{"a": "b", "b": "a"}. Actions are not re-ordered: each relabelled action keeps its position and, at an event, its probability. After the operation, the labels must be nonempty and unique.infoset is a Selector (an H-built expression, evaluated against this game) that must resolve to exactly one node.
Added in version 17.0.0.
- Parameters:
infoset (Selector) – A Selector resolving to a single node belonging to the information set or event at which to relabel actions.
labels (Mapping[str, str]) – A mapping from current action labels to replacement labels. Entries whose key equals their value are ignored.
strict (bool, default True) – If True, every key of labels must be the label of an action at infoset, and unknown keys raise
KeyError. If False, unknown keys are ignored.
- Raises:
TypeError – If infoset is not a Selector; or if labels is not a mapping, or any key or value is not a string.
KeyError – If, when strict is True, a key of labels matches no action at infoset.
ValueError – If infoset does not resolve to exactly one node; if a key of labels matches more than one action at infoset (possible in games read from files predating unique-label enforcement); or if any replacement label is empty, is not a valid label, or would result in a duplicate label at the information set.
