Skip to content

Commit de3c224

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f1b2f7f commit de3c224

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

examples/virus_antibody/agents.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class AntibodyAgent(ContinuousSpaceAgent):
1616
"""An Antibody agent. They move randomly until they see a virus, go fight it.
1717
If they lose, stay KO for a bit, lose health and back to random moving.
1818
"""
19+
1920
speed = 1.5
2021
sight_range = 10
2122
ko_timeout = 15
@@ -46,9 +47,15 @@ def __init__(
4647
self.ko_steps_left = 0
4748

4849
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+
)
5053
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+
]
5259

5360
# Acquire a virus target if we don't already have one
5461
if self.target is None and nearby_viruses:
@@ -89,7 +96,6 @@ def duplicate(self):
8996
clone.ko_steps_left = 0
9097

9198
def move(self):
92-
9399
# Dereference weakref if needed
94100
target = (
95101
self.target()
@@ -136,7 +142,6 @@ def move(self):
136142
self.position = new_pos
137143

138144
def engage_virus(self, virus) -> str:
139-
140145
dna = copy.deepcopy(virus.dna)
141146
if dna in self.st_memory or dna in self.lt_memory:
142147
virus.remove()
@@ -158,6 +163,7 @@ def engage_virus(self, virus) -> str:
158163

159164
class VirusAgent(ContinuousSpaceAgent):
160165
"""A virus agent: random movement, mutation, duplication, passive to antibodies."""
166+
161167
speed = 1
162168

163169
def __init__(

examples/virus_antibody/model.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ def __init__(
3131
initial_viruses=20,
3232
width=100,
3333
height=100,
34-
3534
# Antibody parameters
3635
antibody_duplication_rate=0.01,
37-
3836
# Virus parameters
3937
virus_duplication_rate=0.01,
4038
virus_mutation_rate=0.01,

0 commit comments

Comments
 (0)