Randomization not working reliably for floats

This commit is contained in:
Dominik Moritz Roth 2023-01-06 17:23:58 +01:00
parent d8e7c4c80f
commit e0f4aa3c13

View File

@ -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()