MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

cellular_automata/wa_tor.py:118–130  ·  view source on GitHub ↗
(self, width: int, height: int)

Source from the content-addressed store, hash-verified

116 time_passed: Callable[["WaTor", int], None] | None
117
118 def __init__(self, width: int, height: int) -> None:
119 self.width = width
120 self.height = height
121 self.time_passed = None
122
123 self.planet: list[list[Entity | None]] = [[None] * width for _ in range(height)]
124
125 # Populate planet with predators and prey randomly
126 for _ in range(PREY_INITIAL_COUNT):
127 self.add_entity(prey=True)
128 for _ in range(PREDATOR_INITIAL_COUNT):
129 self.add_entity(prey=False)
130 self.set_planet(self.planet)
131
132 def set_planet(self, planet: list[list[Entity | None]]) -> None:
133 """

Callers

nothing calls this directly

Calls 2

add_entityMethod · 0.95
set_planetMethod · 0.95

Tested by

no test coverage detected