@@ -686,10 +686,13 @@ class MixedBehaviorProfile:
686686 raise ValueError("infoset_value() is not defined for the chance player")
687687 return self._infoset_value(resolved_infoset )
688688
689- def action_value(self , action: ActionReference ) -> ProfileDType:
689+ def action_value(self , action: ActionReference ) -> ProfileDType | None :
690690 """Returns the expected payoff to the player of playing an action conditional on reaching
691691 its information set , if all players play according to the profile.
692692
693+ If the information set is not reachable , the expected payoff is not well-defined.
694+ In this case , the function returns `None`.
695+
693696 Parameters
694697 ----------
695698 action : Action or str
@@ -704,6 +707,10 @@ class MixedBehaviorProfile:
704707 If `action` is a string and no action in the game has that label.
705708 ValueError
706709 If `action` resolves to an action that belongs to the chance player
710+
711+ See also
712+ --------
713+ MixedBehaviorProfile.infoset_prob
707714 """
708715 self._check_validity()
709716 resolved_action = self .game._resolve_action(action, " action_value" )
@@ -959,8 +966,11 @@ class MixedBehaviorProfileDouble(MixedBehaviorProfile):
959966 def _node_value(self , player: Player , node: Node ) -> float:
960967 return deref(self.profile ).GetPayoff(player.player , node.node )
961968
962- def _action_value(self , action: Action ) -> float:
963- return deref(self.profile ).GetPayoff(action.action )
969+ def _action_value(self , action: Action ) -> float | None:
970+ cdef optional[float] value = deref(self .profile).GetPayoff(action.action)
971+ if value.has_value():
972+ return value.value()
973+ return None
964974
965975 def _action_regret (self , action: Action ) -> float:
966976 return deref(self.profile ).GetRegret(action.action )
@@ -1061,8 +1071,11 @@ class MixedBehaviorProfileRational(MixedBehaviorProfile):
10611071 def _node_value(self , player: Player , node: Node ) -> Rational:
10621072 return rat_to_py(deref(self.profile ).GetPayoff(player.player , node.node ))
10631073
1064- def _action_value(self , action: Action ) -> Rational:
1065- return rat_to_py(deref(self.profile ).GetPayoff(action.action ))
1074+ def _action_value(self , action: Action ) -> Rational | None:
1075+ cdef optional[c_Rational] value = deref(self .profile).GetPayoff(action.action)
1076+ if value.has_value():
1077+ return rat_to_py(value.value())
1078+ return None
10661079
10671080 def _action_regret (self , action: Action ) -> Rational:
10681081 return rat_to_py(deref(self.profile ).GetRegret(action.action ))
0 commit comments