oyamad / game_theory_models

Python code for game theory modeling
BSD 3-Clause "New" or "Revised" License
31 stars 9 forks source link

best_response_transition in BRD-type processes #16

Closed oyamad closed 9 years ago

oyamad commented 9 years ago
def best_response_transition(self, current_action_dist):
    actions = np.nonzero(current_action_dist)[0]
    out = dict()
    for action in actions:
        current_action_dist[action] -= 1
        brs = self.player.best_response(current_action_dist,
                                        tie_breaking=False)
        num_brs = len(brs)
        out[action] = np.empty((num_brs, self.num_actions), dtype=int)
        out[action][:] = current_action_dist
        out[action][np.arange(num_brs), brs] += 1
        current_action_dist[action] += 1
    return out