From e0f4aa3c13f4b420f2fcf1c7501a5629fc6d7678 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Fri, 6 Jan 2023 17:23:58 +0100 Subject: [PATCH] Randomization not working reliably for floats --- columbus/env.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/columbus/env.py b/columbus/env.py index 72271ff..ea4bfc8 100644 --- a/columbus/env.py +++ b/columbus/env.py @@ -564,14 +564,16 @@ class ColumbusConfigDefined(ColumbusEnv): else: v = v_raw if k.endswith('_rand'): + print('_rand!') if isinstance(v, int): + print('int!') n = k.replace('_rand', '') cur = getattr( entity, n) inc = int((v+0.99)*self.random()) setattr(entity, n, cur + inc) elif isinstance(v, float): - n = k.replace('_randf', '') + n = k.replace('_rand', '') cur = getattr( entity, n) inc = v*self.random() @@ -585,7 +587,7 @@ class ColumbusConfigDefined(ColumbusEnv): cur[vi] = int((v+0.99)*self.random()) setattr(entity, n, cur) elif isinstance(v, float): - n = k.replace('_randf', '') + n = k.replace('_rand', '') cur = getattr( entity, n) cur[vi] = v*self.random()