@@ -16,6 +16,7 @@ class AntibodyAgent(ContinuousSpaceAgent):
16
16
"""An Antibody agent. They move randomly until they see a virus, go fight it.
17
17
If they lose, stay KO for a bit, lose health and back to random moving.
18
18
"""
19
+
19
20
speed = 1.5
20
21
sight_range = 10
21
22
ko_timeout = 15
@@ -46,9 +47,15 @@ def __init__(
46
47
self .ko_steps_left = 0
47
48
48
49
def step (self ):
49
- nearby_agents ,_ = self .space .get_agents_in_radius (self .position , self .sight_range )
50
+ nearby_agents , _ = self .space .get_agents_in_radius (
51
+ self .position , self .sight_range
52
+ )
50
53
nearby_viruses = [a for a in nearby_agents if isinstance (a , VirusAgent )]
51
- nearby_antibodies = [a for a in nearby_agents if isinstance (a , AntibodyAgent ) and a .unique_id != self .unique_id ]
54
+ nearby_antibodies = [
55
+ a
56
+ for a in nearby_agents
57
+ if isinstance (a , AntibodyAgent ) and a .unique_id != self .unique_id
58
+ ]
52
59
53
60
# Acquire a virus target if we don't already have one
54
61
if self .target is None and nearby_viruses :
@@ -89,7 +96,6 @@ def duplicate(self):
89
96
clone .ko_steps_left = 0
90
97
91
98
def move (self ):
92
-
93
99
# Dereference weakref if needed
94
100
target = (
95
101
self .target ()
@@ -136,7 +142,6 @@ def move(self):
136
142
self .position = new_pos
137
143
138
144
def engage_virus (self , virus ) -> str :
139
-
140
145
dna = copy .deepcopy (virus .dna )
141
146
if dna in self .st_memory or dna in self .lt_memory :
142
147
virus .remove ()
@@ -158,6 +163,7 @@ def engage_virus(self, virus) -> str:
158
163
159
164
class VirusAgent (ContinuousSpaceAgent ):
160
165
"""A virus agent: random movement, mutation, duplication, passive to antibodies."""
166
+
161
167
speed = 1
162
168
163
169
def __init__ (
0 commit comments