-
Notifications
You must be signed in to change notification settings - Fork 5
/
mActions.py
60 lines (49 loc) · 1.62 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
52
53
54
55
56
57
58
59
60
from Tools import *
from Agent import *
import os
def do0(address):
self = address # if necessary
askEachAgentInCollection(address.agentList, Agent.setNewCycleValues)
def do1(address):
self = address # if necessary
# set in each call to the group
self.actionGroup1.setName("move")
# set in each call to the group
# 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)
# move with a jump, to have to transfer a parameter
# the format is: collection, method, parameters by name
# ask each agent, without parameters
# the potential jump is the same for all the agents
askEachAgentInCollectionAndExecLocalCode(
address.agentListCopy,
Agent.randomMovement,
jump=random.uniform(
0,
5))
def createTheAgent(self, line, num, agType):
# explictly pass self, here we use a function
if len(line.split()) == 1: # weak control, can be improved
anAgent = Agent(
num,
self.worldState,
random.randint(
self.leftX,
self.rightX),
random.randint(
self.bottomY,
self.topY),
self.leftX,
self.rightX,
self.bottomY,
self.topY,
agType=agType)
self.agentList.append(anAgent)
else:
print("Error in file " + agType + ".txt")
os.sys.exit(1)
def otherSubSteps(subStep, address):
return False