refactor(wa-tor): Use double for loop

This commit is contained in:
CaedenPH 2023-07-30 20:07:17 +01:00
parent 5ba7243e12
commit e6f3995219

View File

@ -15,7 +15,7 @@ to result in one of the three possible results.
from collections.abc import Callable from collections.abc import Callable
from random import randint, shuffle from random import randint, shuffle
from time import sleep from time import sleep
from typing import Any, Literal from typing import Literal
WIDTH = 50 # Width of the Wa-Tor planet WIDTH = 50 # Width of the Wa-Tor planet
HEIGHT = 50 # Height of the Wa-Tor planet HEIGHT = 50 # Height of the Wa-Tor planet
@ -178,11 +178,11 @@ class WaTor:
>>> len(wt.get_entities()) == PREDATOR_INITIAL_COUNT + PREY_INITIAL_COUNT >>> len(wt.get_entities()) == PREDATOR_INITIAL_COUNT + PREY_INITIAL_COUNT
True True
""" """
start: Any = [] return [entity
return sum( for column in self.planet
[[entity for entity in column if entity] for column in self.planet], for entity in column
start=start, if entity
) ]
def balance_predators_and_prey(self) -> None: def balance_predators_and_prey(self) -> None:
""" """