-
Notifications
You must be signed in to change notification settings - Fork 5
/
oActions.py
60 lines (44 loc) · 1.6 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
from Tools import *
from Agent import *
import graphicDisplayGlobalVarAndFunctions as gvf
import commonVar as common
def do1b(address):
# to debug, having the map of the agent
agL = []
for ag in address.modelSwarm.agentList:
agL.append(ag.number)
agL.sort()
# print "\noActions before drawGraph agents", agL
# print "oActions before drawGraph nodes", common.g.nodes()
# basic action to visualize the networkX output
gvf.openClearNetworkXdisplay()
gvf.drawGraph()
def do2a(address, cycle):
self = address # if necessary
# ask each agent, without parameters
print("Time = ", cycle, "ask all agents to report position")
askEachAgentInCollection(
address.modelSwarm.getAgentList(),
Agent.reportPosition)
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):
if subStep == "pause":
input("Hit enter key to continue")
return True
elif subStep == "prune":
common.prune = True
newValue = input(("Prune links with weight < %d\n" +
"Enter to confirm " +
"or introduce a new level: ") %
common.pruneThreshold)
if newValue != "":
common.pruneThreshold = int(newValue)
return True
else:
return False