Force Units in px to be integers (rounding down)

This commit is contained in:
Dominik Moritz Roth 2022-12-06 12:09:19 +01:00
parent bde7869f97
commit 8132bb9321
2 changed files with 8 additions and 1 deletions

View File

@ -855,6 +855,8 @@ class ColumbusConfigDefined(ColumbusEnv):
if type(s) in [int, float]: if type(s) in [int, float]:
return s return s
if s.replace('.', '', 1).isdigit(): if s.replace('.', '', 1).isdigit():
if target == 'px':
return int(s)
return float(s) return float(s)
num, unit = s[:-2], s[-2:] num, unit = s[:-2], s[-2:]
num = float(num) num = float(num)
@ -876,7 +878,7 @@ class ColumbusConfigDefined(ColumbusEnv):
if target == 'em': if target == 'em':
return em return em
elif target == 'px': elif target == 'px':
return em * ({'x': self.width, 'y': self.height}[axis]) return int(em * ({'x': self.width, 'y': self.height}[axis]))
def setup(self): def setup(self):
self.agent.pos = self.start_pos self.agent.pos = self.start_pos

View File

@ -63,6 +63,11 @@ params:
width: 25ry width: 25ry
height: 25rx height: 25rx
pos: [0.75em, 60px] pos: [0.75em, 60px]
- type: RectBarrier
num: 1
width: 2ct
height: 3ct
pos: [0.75em, 90px]
- type: OnceReward - type: OnceReward
reward: 100 reward: 100
radius: 3ct radius: 3ct