pygambit.gambit.MixedStrategyProfile.set_mixed_strategy#
- MixedStrategyProfile.set_mixed_strategy(player: str, distribution: Mapping, sparse: bool = False) None#
Sets the mixed strategy for the player with label player.
Equivalent to
profile[player] = distribution, except that by default every one of the player’s strategies must be given an explicit weight in distribution. Use this instead of __setitem__ when omitting a strategy should be an error rather than silently defaulting its weight to zero.Added in version 17.0.0.
- Parameters:
player (str) – The label of the player whose mixed strategy is to be set.
distribution (Mapping[str, Any]) – A non-negative weight for the player’s strategies, keyed by strategy label. A weight may be any value Gambit can interpret as a number (int, float, str, Decimal, or Rational). Weights need not sum to one, and at least one must be nonzero.
sparse (bool, default False) – If False (the default), distribution must specify a weight for every one of the player’s strategies. If True, strategies it omits are treated as having weight zero, the same as
profile[player] = distribution.
- Raises:
KeyError – If no player in the game has the label player.
TypeError – If player is not a str, or distribution is not a Mapping.
ValueError – If any key of distribution is not one of the player’s strategy labels, if sparse is False and distribution omits a strategy, if any weight cannot be interpreted as a number, if any weight is negative, or if the weights are all zero.
See also
