Skip to content
Snippets Groups Projects
Commit d36fb474 authored by Liyao Zhu's avatar Liyao Zhu
Browse files

game build2

parent c135d7aa
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import game ...@@ -5,7 +5,7 @@ import game
class Agent(): class Agent():
def __init__(self): def __init__(self, R, M, initialwealth):
'add variables to construct agent instance and define instance variables' 'add variables to construct agent instance and define instance variables'
......
...@@ -19,6 +19,18 @@ class game(): ...@@ -19,6 +19,18 @@ class game():
self.threshold = 0 # Threshold self.threshold = 0 # Threshold
def createPalyers(self):
players = []
IW = 100 # Initial Wealth
# for i in range(self.N):
# players.append(agent.Agent(self.R, self.N, IW))
#
#(strategy, wealth, fitness)
def updatePopulation(self):
pass
def lossfrac(self, alpha): def lossfrac(self, alpha):
"""the percentage of wealth that players are going to lose if collective-risk happens""" """the percentage of wealth that players are going to lose if collective-risk happens"""
...@@ -36,3 +48,19 @@ class game(): ...@@ -36,3 +48,19 @@ class game():
elif RF == 2: elif RF == 2:
return 1 return 1
return 0 return 0
def computePayoff(self):
pass
def selectPlayers(self):
"""
Randomly select M players from population of size N.
"""
return np.random.choice(self.N, self.M)
def play(self):
pass
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment