From 4ba1d6d46aea56b193fb5adeff59de0d5c8c4b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Ng=E1=BB=8Dc=20=C4=90=E1=BB=A9c=20Huy?= Date: Fri, 20 May 2022 20:19:05 +0700 Subject: [PATCH] fix precision to first decimal place fix precision to first decimal place to avoid floating-point error --- botany.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/botany.py b/botany.py index 46e6538..966570b 100755 --- a/botany.py +++ b/botany.py @@ -354,7 +354,7 @@ class Plant(object): # Do something else pass # TODO: event check - generation_bonus = 0.2 * (self.generation - 1) + generation_bonus = round(0.2 * (self.generation - 1), 1) adjusted_sleep_time = 1 / (1 + generation_bonus) time.sleep(adjusted_sleep_time) @@ -455,7 +455,7 @@ class DataManager(object): self.last_water_gain = time.time() else: ticks_to_add = 0 - this_plant.ticks += ticks_to_add * (0.2 * (this_plant.generation - 1) + 1) + this_plant.ticks += ticks_to_add * round(0.2 * (this_plant.generation - 1) + 1, 1) return this_plant def plant_age_convert(self,this_plant):