Updated state_features

This commit is contained in:
Vasilis Valatsos 2023-11-21 22:35:24 +01:00
parent be0485b2b9
commit 60c09ff2c4
4 changed files with 7 additions and 7 deletions

View file

@ -34,7 +34,6 @@ class Player(pygame.sprite.Sprite):
self.animation.import_assets(position)
self.image = self.animation.image
self.rect = self.animation.rect
# Setup Inputs
self._input = InputHandler(
self.sprite_type, self.animation_player) # , self.status)
@ -116,8 +115,10 @@ class Player(pygame.sprite.Sprite):
self.state_features = [
# TODO: Find a way to normalize
# self.rect.center[0],
# self.rect.center[1],
self.rect.center[0]/3616,
self.rect.center[1]/3168,
self._input.movement.direction.x,
self._input.movement.direction.y,
self.stats.health/self.stats.stats['health'],
self.stats.energy/self.stats.stats['energy']
]
@ -127,7 +128,7 @@ class Player(pygame.sprite.Sprite):
for distance, direction, enemy in sorted_distances[:5]:
enemy_states.extend([
distance/sorted_distances[-1][1],
distance/sorted_distances[-1][0],
direction[0],
direction[1],
enemy.stats.health/enemy.stats.monster_info['health'],
@ -173,7 +174,6 @@ class Player(pygame.sprite.Sprite):
# Get the current state
self.get_current_state()
# Choose action based on current state
action, probs, value = self.agent.choose_action(self.state_features)

View file

@ -6,7 +6,7 @@ environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
if __name__ == '__main__':
n_episodes = 1000
n_episodes = 1
figure_file = 'plots/score.png'
score_history = []
@ -15,7 +15,7 @@ if __name__ == '__main__':
agent_list = []
game_len = 5000
game_len = 1
game = Game()

Binary file not shown.

Binary file not shown.