Skip to content

Commit 3fb4812

Browse files
derkweijersjackiekazil
authored andcommitted
fix: make the simulator argument non-required
1 parent 8ac25d3 commit 3fb4812

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

rl/wolf_sheep/model.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
from ray.rllib.env import MultiAgentEnv
99
from utility import create_intial_agents, grid_to_observation
1010

11+
# Don't create the ABMSimulator as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
12+
ABM_SIMULATOR = ABMSimulator()
13+
1114

1215
class WolfSheepRL(WolfSheep, MultiAgentEnv):
1316
def __init__(
1417
self,
15-
simulator: ABMSimulator | None,
1618
width=20,
1719
height=20,
1820
initial_sheep=100,
@@ -25,12 +27,8 @@ def __init__(
2527
sheep_gain_from_food=4,
2628
seed=42,
2729
vision=4,
30+
simulator: ABMSimulator = ABM_SIMULATOR,
2831
):
29-
"""Create a new WolfRL-Sheep model with the given parameters."""
30-
# Don't create the ABMSimulator as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
31-
if simulator is None:
32-
simulator = ABMSimulator()
33-
3432
super().__init__(
3533
width,
3634
height,

0 commit comments

Comments
 (0)