Compare commits

..
4 Commits
Author SHA1 Message Date
dodox c6abf8e98d Made path_decay configurable 2023-03-12 18:47:50 +01:00
dodox 6095ca6fec Ignore this commit, ugly hack for rlProject 2023-01-19 12:42:59 +01:00
dodox db6cdeed21 Still had issues with _rand 2023-01-06 17:27:08 +01:00
dodox e0f4aa3c13 Randomization not working reliably for floats 2023-01-06 17:23:58 +01:00
+8 -4
View File
@@ -16,7 +16,7 @@ class ColumbusEnv(gym.Env):
metadata = {'render.modes': ['human'], 'render_modes': [ metadata = {'render.modes': ['human'], 'render_modes': [
'human', 'non-human'], 'render_fps': 60} 'human', 'non-human'], 'render_fps': 60}
def __init__(self, observable=observables.Observable(), fps=60, env_seed=3.1, master_seed=None, start_pos=(0.5, 0.5), start_score=0, speed_fac=0.01, acc_fac=0.04, die_on_zero=False, return_on_score=-1, reward_mult=1, agent_drag=0, controll_type='SPEED', aux_reward_max=1, aux_penalty_max=0, aux_reward_discretize=0, void_is_type_barrier=True, void_damage=1, torus_topology=False, default_collision_elasticity=1, terminate_on_reward=False, agent_draw_path=False, clear_path_on_reset=True, max_steps=-1, value_color_mapper='tanh', width=720, height=720, agent_attrs={}, agent_cls=entities.Agent, exception_for_unsupported_collision=True): def __init__(self, observable=observables.Observable(), fps=60, env_seed=3.1, master_seed=None, start_pos=(0.5, 0.5), start_score=0, speed_fac=0.01, acc_fac=0.04, die_on_zero=False, return_on_score=-1, reward_mult=1, agent_drag=0, controll_type='SPEED', aux_reward_max=1, aux_penalty_max=0, aux_reward_discretize=0, void_is_type_barrier=True, void_damage=1, torus_topology=False, default_collision_elasticity=1, terminate_on_reward=False, agent_draw_path=False, clear_path_on_reset=True, max_steps=-1, value_color_mapper='tanh', width=720, height=720, agent_attrs={}, agent_cls=entities.Agent, exception_for_unsupported_collision=True, path_decay=0.1):
super(ColumbusEnv, self).__init__() super(ColumbusEnv, self).__init__()
self.action_space = spaces.Box( self.action_space = spaces.Box(
low=-1, high=1, shape=(2,), dtype=np.float32) low=-1, high=1, shape=(2,), dtype=np.float32)
@@ -62,7 +62,7 @@ class ColumbusEnv(gym.Env):
self.terminate_on_reward = terminate_on_reward self.terminate_on_reward = terminate_on_reward
self.agent_draw_path = agent_draw_path self.agent_draw_path = agent_draw_path
self.clear_path_on_reset = clear_path_on_reset self.clear_path_on_reset = clear_path_on_reset
self.path_decay = 0.1 self.path_decay = path_decay
if isinstance(agent_cls, str): if isinstance(agent_cls, str):
agent_cls = getattr(entities, agent_cls) agent_cls = getattr(entities, agent_cls)
@@ -95,6 +95,8 @@ class ColumbusEnv(gym.Env):
self._init = False self._init = False
self.is_columbus_env = True
@property @property
def observation_space(self): def observation_space(self):
if not self._init: if not self._init:
@@ -564,6 +566,8 @@ class ColumbusConfigDefined(ColumbusEnv):
else: else:
v = v_raw v = v_raw
if k.endswith('_rand'): if k.endswith('_rand'):
v = self.conv_unit(
v_raw, target='px', axis='y' if k == 'height_rand' else 'x')
if isinstance(v, int): if isinstance(v, int):
n = k.replace('_rand', '') n = k.replace('_rand', '')
cur = getattr( cur = getattr(
@@ -571,7 +575,7 @@ class ColumbusConfigDefined(ColumbusEnv):
inc = int((v+0.99)*self.random()) inc = int((v+0.99)*self.random())
setattr(entity, n, cur + inc) setattr(entity, n, cur + inc)
elif isinstance(v, float): elif isinstance(v, float):
n = k.replace('_randf', '') n = k.replace('_rand', '')
cur = getattr( cur = getattr(
entity, n) entity, n)
inc = v*self.random() inc = v*self.random()
@@ -585,7 +589,7 @@ class ColumbusConfigDefined(ColumbusEnv):
cur[vi] = int((v+0.99)*self.random()) cur[vi] = int((v+0.99)*self.random())
setattr(entity, n, cur) setattr(entity, n, cur)
elif isinstance(v, float): elif isinstance(v, float):
n = k.replace('_randf', '') n = k.replace('_rand', '')
cur = getattr( cur = getattr(
entity, n) entity, n)
cur[vi] = v*self.random() cur[vi] = v*self.random()