From 27d87e9c9247c73e53dd6bd76a80bbd4cbc2ea21 Mon Sep 17 00:00:00 2001 From: Vasilis Valatsos Date: Tue, 26 Mar 2024 12:40:56 +0100 Subject: [PATCH] Made rewards make more sense and removed extra punishment for death --- entities/player.py | 2 +- level.py | 1 - main.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/entities/player.py b/entities/player.py index e7c0c94..f061d15 100644 --- a/entities/player.py +++ b/entities/player.py @@ -161,7 +161,7 @@ class Player(pygame.sprite.Sprite): self.old_state_features = self.state_features self.reward = self.stats.exp\ - + self.stats.health/self.stats.stats['health'] - 1 + + self.stats.health/self.stats.stats['health'] # - nearest_dist/np.sqrt(np.sum(self.map_edge)) self.state_features = [ diff --git a/level.py b/level.py index cfb0112..636b89d 100644 --- a/level.py +++ b/level.py @@ -293,7 +293,6 @@ class Level: for player in self.player_sprites: if player.is_dead(): print(f"\nPlayer {player.player_id} is dead\n") - player.stats.exp = -10 self.dead_players[player.player_id] = player.is_dead() self.done = True if (self.dead_players.all() == 1 diff --git a/main.py b/main.py index 3af7301..054c8fa 100644 --- a/main.py +++ b/main.py @@ -116,7 +116,7 @@ def main(): episode_reward[player.player_id][step] = player.reward - if not no_training and ((step % horizon == 0 and step != 0) or player.is_dead()): + if not no_training and ((step % horizon == 0 and step != 0): player.agent.learn()