pygambit.gambit.Game.make_event#

Game.make_event(nodes: Selector | GroupedSelector, probs: Mapping, label: str | None = None) None#

Form nodes into a single event with distribution probs.

nodes must all be nonterminal nodes of this game with the same actions, with the same labels in the same order. They need not be chance nodes; personal nodes are converted, and the move is thereafter resolved by chance. Nodes are removed from whatever information sets or events they currently belong to; any of those which retain members survive, keeping their labels, and those left with no members are deleted. The resulting event’s members, actions, and player are accessible via Node.members/Node.actions/Node.player for any node in nodes.

nodes is a Selector (an H-built expression, evaluated against this game and treated as a flat set of nodes) or a GroupedSelector (an H-built .by(…) expression, whose groups are pooled together into the one event).

Which resolved node is treated as “first”, determining the action order of the event and the frame against which keys of probs are resolved, follows nodes’ own resolution order.

Added in version 17.0.0.

Parameters:
  • nodes (Selector or GroupedSelector) – The nonempty set of nonterminal nodes to place in the event.

  • probs (Mapping) – The probability distribution over the actions of the event, as a mapping from action label to probability. May be sparse; omitted actions are assigned probability zero. Probabilities are non-negative and sum to exactly one.

  • label (str, optional) – The label of the new event. If specified, must be unique among the events of the game after the operation. A label currently held by another event may be reused only if all members of that event are among nodes.

Raises:
  • TypeError – If nodes is not a Selector or GroupedSelector, or probs is not a mapping.

  • KeyError – If a key of probs matches no action label of the event.

  • UndefinedOperationError – If any of nodes is a terminal node, or the game is not a tree.

  • ValueError – If nodes is empty or contains a repeated node; if the nodes do not all have the same actions in the same order; if probs are not non-negative numbers summing to exactly one; or if label is not unique among the game’s events after the operation.