From 88fc8a8067f7ea16fd9491217df1ef7ef4e48a8a Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Wed, 29 Jun 2022 18:49:28 +0200 Subject: [PATCH] Implemented aux penalty (enemys can radiate damage) --- columbus/entities.py | 1 + columbus/env.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/columbus/entities.py b/columbus/entities.py index a44b383..4320656 100644 --- a/columbus/entities.py +++ b/columbus/entities.py @@ -91,6 +91,7 @@ class Enemy(Entity): super(Enemy, self).__init__(env) self.col = (255, 0, 0) self.damage = 100 + self.radiateDamage = True def on_collision(self, other, depth): super().on_collision(other, depth) diff --git a/columbus/env.py b/columbus/env.py index e2386ff..fe7356a 100644 --- a/columbus/env.py +++ b/columbus/env.py @@ -37,6 +37,7 @@ class ColumbusEnv(gym.Env): self.controll_type = 'SPEED' # one of SPEED, ACC self.limit_inp_to_unit_circle = True self.aux_reward_max = 0 # 0 = off + self.aux_penalty_max = 0 # 0 = off self.aux_reward_discretize = 0 # 0 = dont discretize self.draw_observable = True self.draw_joystick = True @@ -109,6 +110,16 @@ class ColumbusEnv(gym.Env): self.aux_reward_discretize / 2 aux_reward += reward + elif isinstance(entity, entities.Enemy): + if entity.radiateDamage: + penalty = self.aux_penalty_max / \ + (1 + self.sq_dist(entity.pos, self.agent.pos)) + + if self.aux_reward_discretize: + penalty = int(penalty*self.aux_reward_discretize*2) / \ + self.aux_reward_discretize / 2 + + aux_reward -= penalty return aux_reward def step(self, action):