mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
Update cellular_automata/wa_tor.py
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
parent
adcc4ff659
commit
7dc67884d1
@ -208,14 +208,13 @@ class WaTor:
|
||||
|
||||
prey_count, predator_count = len(prey), len(predators)
|
||||
|
||||
if prey_count > predator_count:
|
||||
for entity in prey[:DELETE_UNBALANCED_ENTITIES]:
|
||||
# Purge the first n entities of the prey
|
||||
self.planet[entity.coords[0]][entity.coords[1]] = None
|
||||
else:
|
||||
for entity in predators[:DELETE_UNBALANCED_ENTITIES]:
|
||||
# Purge the first n entities of the predators
|
||||
self.planet[entity.coords[0]][entity.coords[1]] = None
|
||||
entities_to_purge = (
|
||||
prey[:DELETE_UNBALANCED_ENTITIES]
|
||||
if prey_count > predator_count
|
||||
else predators[:DELETE_UNBALANCED_ENTITIES]
|
||||
)
|
||||
for entity in entities_to_purge:
|
||||
self.planet[entity.coords[0]][entity.coords[1]] = None
|
||||
|
||||
def get_surrounding_prey(self, entity: Entity) -> list[Entity]:
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user