From 1c654fcf81abbf4cbf7429066f4db5858419cd5e Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sat, 27 Aug 2022 12:03:32 +0200 Subject: [PATCH] Collisions with void can now also be elastic --- columbus/entities.py | 4 ++-- columbus/env.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/columbus/entities.py b/columbus/entities.py index 38d953b..ea141eb 100644 --- a/columbus/entities.py +++ b/columbus/entities.py @@ -94,10 +94,10 @@ class Entity(object): def calc_void_collision(self, dir, x, y, vx, vy): if dir < 2: x = min(max(x, 0), 1) - vx = 0 + vx = -vx*self.collision_elasticity*0.5*self.collision_changes_speed else: y = min(max(y, 0), 1) - vy = 0 + vy = -vy*self.collision_elasticity*0.5*self.collision_changes_speed return x, y, vx, vy def kill(self): diff --git a/columbus/env.py b/columbus/env.py index bec6fbc..5dc9fef 100644 --- a/columbus/env.py +++ b/columbus/env.py @@ -651,7 +651,31 @@ class ColumbusConfigDefined(ColumbusEnv): self.entities.append(entity) +class ColumbusBlub(ColumbusEnv): + def __init__(self, observable=observables.Observable(), env_seed=None, entities=[], fps=30, **kw): + super().__init__( + observable=observable, fps=fps, env_seed=env_seed, default_collision_elasticity=0.9, speed_fac=0.01, acc_fac=0.1, agent_drag=0.05, controll_type='ACC') + + def setup(self): + self.agent.pos = self.start_pos + for i in range(10): + enemy = entities.CircleBarrier(self) + enemy.radius = self.random()*25+75 + self.entities.append(enemy) + for i in range(1): + reward = entities.TeleportingReward(self) + reward.radius = 100 + self.entities.append(reward) + + ### +register( + id='ColumbusBlub-v0', + entry_point=ColumbusBlub, + max_episode_steps=30*60*2, +) + + register( id='ColumbusTestCnn-v0', entry_point=ColumbusTest3_1,