From a8be025870c412edeabffbd69f9008fcf8235607 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Fri, 19 Jul 2024 04:40:54 -0600 Subject: [PATCH] Mods --- cromulant/ants.py | 2 +- cromulant/utils.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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,