Skip to content

Commit

Permalink
fixed a bug with the reward system in pvp mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ocram444 committed Sep 12, 2023
1 parent 837f30b commit cacd734
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions EldenReward.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def update(self, frame):
hp_reward = -420 #Large negative reward for dying

time_since_taken_dmg_reward = 0
if time.time() - self.time_since_dmg_taken > 7: #Reward if we have not taken damage for 7 seconds (every step for as long as we dont take damage)
if time.time() - self.time_since_dmg_taken > 5: #Reward if we have not taken damage for 7 seconds (every step for as long as we dont take damage)
time_since_taken_dmg_reward = 25


Expand Down Expand Up @@ -208,14 +208,17 @@ def update(self, frame):
if time.time() - self.time_since_pvp_damaged > 5: #Negative reward if we have not damaged the enemy for 5 seconds (every step for as long as we dont damage the enemy)
pvp_reward = -25
#print("🔫 Duelist not damaged for 5s")
else:
pvp_reward = 0

#staying alive reward
''' #a time alive reward could cause problems because the agent will still get rewarded even if performing bad when the time alive reward is higher than the other punishments
time_alive_reward = 0
if time.time() - self.time_alive > 5: #Reward if we have been alive for 5 seconds (we give an increasinig reward for every second we are alive)
time_alive_reward = time.time() - self.time_alive - 5
#print("🕒 Time alive reward: ", time_alive_reward)
print("🕒 Time alive reward: ", time_alive_reward)
pvp_reward += time_alive_reward

'''

#winning
self.game_won = self.detect_win(frame) #not implemented yet
Expand Down Expand Up @@ -263,5 +266,5 @@ def update(self, frame):
reward.update(frame)
print("🧠 Done...")
print(" Done...")
"""
2 changes: 1 addition & 1 deletion deathCounter.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0
28
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if __name__ == '__main__':
'''User Settings'''
PYTESSERACT_PATH = r'C:\Program Files\Tesseract-OCR\tesseract.exe' # Set the path
RESUME_TRAINING = False #Start training from a saved model or create a new model
RESUME_TRAINING = True #Start training from a saved model or create a new model
DEBUG_MODE = False #Renders the AI vision (pretty scuffed)
GAME_MODE = "PVP" #PVP or PVE
BOSS = 1 #1-6 for PVE (look at walkToBoss.py for boss names) | Is ignored for GAME_MODE PVP
Expand Down

0 comments on commit cacd734

Please sign in to comment.