-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblueAgent.py
34 lines (30 loc) · 1.36 KB
/
blueAgent.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
import mesa
import communications as comms
import random
class blueAgent(mesa.Agent):
def __init__(self, unique_id, model, human, opinion, energy):
super().__init__(unique_id, model)
self.human = human
self.opinion = opinion # used for plotting
self.energy = energy # Energy level of the agent. potency is subtracted directly from here so use a low number
def humanStep(self, potency = False, grey = False):
# ask user for potency of message if not given
print("Your energy level is: " + str(self.energy))
# ask if user would like to release a grey agent
answer = input("Would you like to release a grey agent? (y/n): ")
if answer == "y":
greys = self.model.get_nodes_by_type("grey", True) # pass randomize then we can just activate the first one
greys[0].active = True
else:
potency = int(input("Enter potency of message: "))
self.updateEnergy(potency)
comms.pushBlueMessage(self.model, potency)
def updateEnergy(self, potency):
self.energy = self.energy - potency
def step(self):
if self.human == "human":
self.humanStep()
if self.human == "random":
potency = random.randint(1, 5)
self.updateEnergy(potency)
comms.pushBlueMessage(self.model, potency)