-
Notifications
You must be signed in to change notification settings - Fork 5
/
mActions.py
50 lines (40 loc) · 1.67 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
from Tools import *
from Agent import *
import os
def do0(address):
self = address # if necessary
askEachAgentInCollection(address.agentList, Agent.setNewCycleValues)
askEachAgentInCollection(address.agentList, Agent.clear)
def do1(address):
self = address # if necessary
# keep safe the original list
address.agentListCopy = address.agentList[:]
# clear messages
askEachAgentInCollection(address.agentListCopy, Agent.clear)
# 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
if len(line.split()) == 5 and line.split()[1] != 'brown':
anAgent = Agent(num, self.worldState,
int(line.split()[2]),
int(line.split()[3]),
self.leftX, self.rightX, self.bottomY,
self.topY, agType=agType)
self.agentList.append(anAgent)
anAgent.setColorAndGender(line.split()[1], line.split()[4])
elif len(line.split()) == 4 and line.split()[1] == 'brown':
anAgent = Agent(num, self.worldState,
int(line.split()[2]),
int(line.split()[3]),
self.leftX, self.rightX, self.bottomY,
self.topY, agType=agType)
# not added to agentList
anAgent.setColorAndGender(line.split()[1], "") # brown, no gender,
# it is a desk
else:
print("Error in file " + agType + ".txt")
os.sys.exit(1)
def otherSubSteps(subStep, address):
return False