Collisions with void can now also be elastic

This commit is contained in:
Dominik Moritz Roth 2022-08-27 12:03:32 +02:00
parent 581b733763
commit 1c654fcf81
2 changed files with 26 additions and 2 deletions

View File

@ -94,10 +94,10 @@ class Entity(object):
def calc_void_collision(self, dir, x, y, vx, vy): def calc_void_collision(self, dir, x, y, vx, vy):
if dir < 2: if dir < 2:
x = min(max(x, 0), 1) x = min(max(x, 0), 1)
vx = 0 vx = -vx*self.collision_elasticity*0.5*self.collision_changes_speed
else: else:
y = min(max(y, 0), 1) y = min(max(y, 0), 1)
vy = 0 vy = -vy*self.collision_elasticity*0.5*self.collision_changes_speed
return x, y, vx, vy return x, y, vx, vy
def kill(self): def kill(self):

View File

@ -651,7 +651,31 @@ class ColumbusConfigDefined(ColumbusEnv):
self.entities.append(entity) 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( register(
id='ColumbusTestCnn-v0', id='ColumbusTestCnn-v0',
entry_point=ColumbusTest3_1, entry_point=ColumbusTest3_1,