-
Notifications
You must be signed in to change notification settings - Fork 5
/
mActions.py
executable file
·51 lines (39 loc) · 1.52 KB
/
mActions.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
40
41
42
43
44
45
46
47
48
49
50
51
from Tools import *
from Agent import *
import os
import random
import commonVar as common
def do0(address):
self = address # if necessary
askEachAgentInCollection(address.agentList, Agent.setNewCycleValues)
def do1(address):
self = address # if necessary
# keep safe the original list
address.agentListCopy = address.agentList[:]
# never in the same order (please comment if you want to keep
# always the same sequence
random.shuffle(address.agentListCopy)
def createTheAgent(self, line, num, agType):
# explicitly pass self, here we use a function
# check for a least an agent with numner==1
if num == 1:
common.agent1existing = True
# workers
if agType == "workers":
anAgent = Agent(num, self.worldState,
float(line.split()[1]) + random.gauss(0, common.sigma),
float(line.split()[2]) + random.gauss(0, common.sigma),
agType=agType)
self.agentList.append(anAgent)
anAgent.setAgentList(self.agentList)
# entrepreneurs
elif agType == "entrepreneurs":
anAgent = Agent(num, self.worldState,
float(line.split()[1]) + random.gauss(0, common.sigma),
float(line.split()[2]) + random.gauss(0, common.sigma),
agType=agType)
self.agentList.append(anAgent)
# anAgent.setAgentList(self.agentList) #in ModelSwarm.py
else:
print("Error in file " + agType + ".txt")
os.sys.exit(1)