Skip to content

Commit

Permalink
Add reward saving in an attribute #9
Browse files Browse the repository at this point in the history
  • Loading branch information
FranJNaranjo committed Dec 18, 2023
1 parent 11dd93b commit 6a55c47
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion line/gymnasium_playground_line/envs/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def __init__(self, render_mode=None, random_init=False, init_position=0., goal_p
# current step
self.current_step =0

# current reward
self.current_reward = 0

# set max vel
self.max_w = 0.1 # 0.3rad/step or 18grad/step
self.max_dif = self.goal_position - self.initial_position
Expand Down Expand Up @@ -71,7 +74,8 @@ def step(self, action):
penalization = 0.99**(self.current_step-1)
reward *= penalization

self.writer.add_scalar('reward_each_step', reward)
self.current_reward =reward
# self.writer.add_scalar('reward_each_step', reward)

terminated = False
if dif < self.max_w:
Expand All @@ -87,3 +91,4 @@ def render(self):
print("___________")
print("Current position: ", self.current_position)


0 comments on commit 6a55c47

Please sign in to comment.