Made rewards make more sense and removed extra punishment for death

This commit is contained in:
Vasilis Valatsos 2024-03-26 12:40:56 +01:00
parent e45b2fb914
commit 27d87e9c92
3 changed files with 2 additions and 3 deletions

View file

@ -161,7 +161,7 @@ class Player(pygame.sprite.Sprite):
self.old_state_features = self.state_features self.old_state_features = self.state_features
self.reward = self.stats.exp\ 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)) # - nearest_dist/np.sqrt(np.sum(self.map_edge))
self.state_features = [ self.state_features = [

View file

@ -293,7 +293,6 @@ class Level:
for player in self.player_sprites: for player in self.player_sprites:
if player.is_dead(): if player.is_dead():
print(f"\nPlayer {player.player_id} is dead\n") print(f"\nPlayer {player.player_id} is dead\n")
player.stats.exp = -10
self.dead_players[player.player_id] = player.is_dead() self.dead_players[player.player_id] = player.is_dead()
self.done = True if (self.dead_players.all() == 1 self.done = True if (self.dead_players.all() == 1

View file

@ -116,7 +116,7 @@ def main():
episode_reward[player.player_id][step] = player.reward 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() player.agent.learn()