Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. class Player:
  2. # ....
  3. def regret(self, my_action, opp_action):
  4. """
  5. 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.
  6. """
  7. result = RPS.utilities.loc[my_action, opp_action]
  8. facts = RPS.utilities.loc[:, opp_action].values
  9. regret = facts - result
  10. self.regret_sum += regret
  11.  
  12. def action(self, use_avg=False):
  13. """
  14. select an action according to strategy probabilities
  15. """
  16. strategy = self.avg_strategy if use_avg else self.strategy
  17. return np.random.choice(RPS.actions, p=strategy) # p refers to 'probability'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement