-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPayoffMatrices.py
More file actions
20 lines (16 loc) · 1010 Bytes
/
PayoffMatrices.py
File metadata and controls
20 lines (16 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Class for the Payoff Matrices
import numpy as np
class PayoffMatrices():
def __init__(self,player_one_payoffs, player_two_payoffs):
self.player_one_payoffs = player_one_payoffs
self.player_two_payoffs = player_two_payoffs
self.number_player_one_actions = len(player_one_payoffs)
self.number_player_two_actions = len(player_one_payoffs[0])
def transition_matrix(self):
transitions = np.zeros((self.number_player_one_actions + self.number_player_two_actions, self.number_player_one_actions + self.number_player_two_actions))
for index, payoff_row in enumerate(self.player_one_payoffs):
transitions[index][self.number_player_one_actions:] = payoff_row
player_two_payoffs = np.transpose(self.player_two_payoffs)
for index, payoff_row in enumerate(player_two_payoffs):
transitions[self.number_player_one_actions + index][:self.number_player_one_actions] = payoff_row
return transitions