-
Notifications
You must be signed in to change notification settings - Fork 5
/
oActions.py
83 lines (64 loc) · 2.21 KB
/
oActions.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from Tools import *
from Agent import *
def do1b(address):
pass
def do2a(address, cycle):
self = address # if necessary
maxY = 15 # max on Y axis
# ask each agent, without parameters
# print "Time = ", cycle, "ask all agents to report position and attention"
# askEachAgentInCollection(address.modelSwarm.getAgentList(),Agent.reportPosition)
if self.v_ == []:
for a in address.modelSwarm.getAgentList():
self.n_.append(a.number)
i = 5
for a in address.modelSwarm.getAgentList():
self.p.penup()
self.p.black(-250 + i, 134)
self.p.pendown()
self.p.label(str(a.number))
i += 20
self.p.penup()
self.p.black(-250, 250)
self.p.pendown()
self.p.label(str(maxY))
self.p.black(-250, 150)
self.p.penup()
self.p.black(-250, 274)
self.p.pendown()
self.p.label(" Attention of each pupil")
self.p.penup()
self.p.black(-250, 150)
self.p.pendown()
vD = []
if self.v_ != []:
vD = self.v_[:] # D=delete
del self.v_[:]
for a in address.modelSwarm.getAgentList():
# print "agent", a.number, "attention = ",a.getAttention()
self.v_.append(a.getAttentionAndCleanStep())
print('attention index for each pupil =', end=' ')
for i in range(len(self.n_)):
print("[" + str(self.n_[i]) + "," + str(self.v_[i]) + "] ", end=' ')
print()
self.p.penup()
self.p.black(-250, 150)
self.p.pendown()
k = 100. / maxY
for i in range(len(self.v_)):
self.p.black(-240 + i * 20, 150)
if vD != []:
self.p.white(-240 + i * 20, 150 + vD[i] * k)
self.p.penup()
self.p.black(-240 + i * 20, 150 + self.v_[i] * k)
self.p.pendown()
self.p.black(-240 + i * 20, 150)
def do2b(address, cycle):
self = address # if necessary
# ask a single agent, without parameters
print("Time = ", cycle, "ask first agent to report position")
if address.modelSwarm.getAgentList() != []:
askAgent(address.modelSwarm.getAgentList()[0],
Agent.reportPosition)
def otherSubSteps(subStep, address):
return False