Skip to content

Commit

Permalink
Fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ygreif committed Oct 2, 2016
1 parent ca086d4 commit eb77250
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions gym_el_farol/envs/equilibria.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def step(self, action):

def in_equilibria(self):
for action_counts in self.action_counts_by_agent.values():
print action_counts
if max(action_counts.values()) / float(sum(action_counts.values())) < self.threshold:
return False
return True
9 changes: 5 additions & 4 deletions scripts/erev_roth_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ def act(self):
def learn(self, reward):
self.q[self.prev_action] += reward * self.config["learning_rate"]
for key in self.q:
self.q[key] *= .9
self.q[key] *= .99

def iterate(agents, env):
actions = [a.act() for a in agents]
obs, reward, _, _ = env.step(actions)
print actions, sum(actions)
for agent, reward in zip(agents, reward):
agent.learn(reward)
return actions

def iterations_to_equilbira(agents, env):
nash = FuzzyPureNash()
for iter in range(0, 5000000):
if iter % 100 == 0 and iter > 0:
if iter % 50 == 0 and iter > 0:
print iter
if nash.in_equilibria():
return iter
Expand All @@ -57,8 +58,8 @@ def iterations_to_equilbira(agents, env):
for agent in agents:
print agent.q[0] / (agent.q[0] + agent.q[1])
return False
n_agents = 20

n_agents = 100
env = ElFarolEnv(n_agents=n_agents, threshold=5)
agents = []
for i in range(0, n_agents):
Expand Down

0 comments on commit eb77250

Please sign in to comment.