Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Player:
- # ....
- def regret(self, my_action, opp_action):
- """
- We here define the regret of not having chosen an action as the difference between the utility of that action and the utility of the action we actually chose, with respect to the fixed choices of the other player. Compute the regret and add it to regret sum.
- """
- result = RPS.utilities.loc[my_action, opp_action]
- facts = RPS.utilities.loc[:, opp_action].values
- regret = facts - result
- self.regret_sum += regret
- def action(self, use_avg=False):
- """
- select an action according to strategy probabilities
- """
- strategy = self.avg_strategy if use_avg else self.strategy
- return np.random.choice(RPS.actions, p=strategy) # p refers to 'probability'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement