Update cellular_automata/wa_tor.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
Caeden Perelli-Harris 2023-07-30 19:38:09 +01:00 committed by GitHub
parent adcc4ff659
commit 7dc67884d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,13 +208,12 @@ class WaTor:
prey_count, predator_count = len(prey), len(predators) prey_count, predator_count = len(prey), len(predators)
if prey_count > predator_count: entities_to_purge = (
for entity in prey[:DELETE_UNBALANCED_ENTITIES]: prey[:DELETE_UNBALANCED_ENTITIES]
# Purge the first n entities of the prey if prey_count > predator_count
self.planet[entity.coords[0]][entity.coords[1]] = None else predators[:DELETE_UNBALANCED_ENTITIES]
else: )
for entity in predators[:DELETE_UNBALANCED_ENTITIES]: for entity in entities_to_purge:
# Purge the first n entities of the predators
self.planet[entity.coords[0]][entity.coords[1]] = None self.planet[entity.coords[0]][entity.coords[1]] = None
def get_surrounding_prey(self, entity: Entity) -> list[Entity]: def get_surrounding_prey(self, entity: Entity) -> list[Entity]: