diff --git a/cromulant/ants.py b/cromulant/ants.py index 9772fe5..6f718e0 100644 --- a/cromulant/ants.py +++ b/cromulant/ants.py @@ -76,7 +76,7 @@ class Ants: ant.created = now ant.updated = now ant.name = Utils.random_name() - ant.color = Utils.random_color() + ant.color = Utils.random_color(ant.name) Ants.ants.append(ant) image_path = Config.hatched_image_path diff --git a/cromulant/utils.py b/cromulant/utils.py index 4b911d1..c433030 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -68,7 +68,10 @@ class Utils: print(text) # noqa: T201 @staticmethod - def random_color() -> tuple[int, int, int]: + def random_color(seed: str) -> tuple[int, int, int]: + seed_int = hash(seed) + random.seed(seed_int) + h, s, l = ( random.random(), 0.5 + random.random() / 2.0,