-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace_payoffs.py
39 lines (27 loc) · 904 Bytes
/
trace_payoffs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import simulate
import pymongo
import sys
import datetime
AGENT = 'Reference'
if __name__ == '__main__':
simulate.agent = __import__('agents.fitness.'+AGENT, fromlist=['*'])
connection = pymongo.Connection()
db = connection.SocialLearning
collection = db.trace_payoffs
print "Simulating",
sys.stdout.flush()
# We'll log traces to the database until this program is terminated
while True:
simulation = simulate.Simulate(N_rounds = 10000)
trace = []
for round in xrange(0,10000):
simulation.step()
trace.append(1. * simulation.total_payoff / (round+1.))
record = {'agent_name': AGENT+'.py',
'timestamp': datetime.datetime.now(),
'trace': trace
}
collection.insert(record)
connection.fsync()
print ".",
sys.stdout.flush()