Skip to content

Commit 5e4f97b

Browse files
rhttpike3
authored andcommitted
benchmark WolfSheep: Change import structure
1 parent f1fcdc6 commit 5e4f97b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

benchmarks/WolfSheep/wolf_sheep.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
Northwestern University, Evanston, IL.
1010
"""
1111

12-
from mesa import Agent, Model
13-
from mesa.space import MultiGrid
14-
from mesa.time import RandomActivationByType
12+
import mesa
1513

1614

17-
class Animal(Agent):
15+
class Animal(mesa.Agent):
1816
def __init__(self, unique_id, model, moore, energy, p_reproduce, energy_from_food):
1917
super().__init__(unique_id, model)
2018
self.energy = energy
@@ -92,7 +90,7 @@ def feed(self):
9290
sheep_to_eat.die()
9391

9492

95-
class GrassPatch(Agent):
93+
class GrassPatch(mesa.Agent):
9694
"""
9795
A patch of grass that grows at a fixed rate and it is eaten by sheep
9896
"""
@@ -119,7 +117,7 @@ def step(self):
119117
self.countdown -= 1
120118

121119

122-
class WolfSheep(Model):
120+
class WolfSheep(mesa.Model):
123121
"""
124122
Wolf-Sheep Predation Model
125123
@@ -163,8 +161,8 @@ def __init__(
163161
self.initial_wolves = initial_wolves
164162
self.grass_regrowth_time = grass_regrowth_time
165163

166-
self.schedule = RandomActivationByType(self)
167-
self.grid = MultiGrid(self.height, self.width, torus=False)
164+
self.schedule = mesa.time.RandomActivationByType(self)
165+
self.grid = mesa.space.MultiGrid(self.height, self.width, torus=False)
168166

169167
for _ in range(self.initial_sheep):
170168
pos = (

0 commit comments

Comments
 (0)