Created
July 21, 2017 05:04
-
-
Save alasdairham/81ceb2ae2deee18b6c948d6215a04690 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment