-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from goncamateus:dqn-DyLam
Dqn-DyLam
- Loading branch information
Showing
17 changed files
with
551 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from mo_gymnasium.envs.minecart.minecart import Minecart | ||
|
||
|
||
class MinecartEnv(Minecart): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.cumulative_info = { | ||
"reward_First_minerium": 0, | ||
"reward_Second_minerium": 0, | ||
"reward_Fuel": 0, | ||
"Original_reward": 0, | ||
} | ||
|
||
def reset(self, *args, **kwargs): | ||
obs, info = super().reset(*args, **kwargs) | ||
self.cumulative_info = { | ||
"reward_First_minerium": 0, | ||
"reward_Second_minerium": 0, | ||
"reward_Fuel": 0, | ||
"Original_reward": 0, | ||
} | ||
return obs, info | ||
|
||
def step(self, action): | ||
obs, reward, termination, truncation, info = super().step(action) | ||
self.cumulative_info["reward_First_minerium"] += reward[0] | ||
self.cumulative_info["reward_Second_minerium"] += reward[1] | ||
self.cumulative_info["reward_Fuel"] += reward[2] | ||
self.cumulative_info["Original_reward"] += reward.sum() | ||
return obs, reward, termination, truncation, self.cumulative_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from mo_gymnasium.envs.mountain_car.mountain_car import MOMountainCar | ||
|
||
|
||
class MountainCar(MOMountainCar): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.cumulative_reward_info = { | ||
"reward_time": 0, | ||
"reward_reverse": 0, | ||
"reward_forward": 0, | ||
"Original_reward": 0, | ||
} | ||
|
||
def reset(self, *, seed: int | None = None, options: dict | None = None): | ||
result = super().reset(seed=seed, options=options) | ||
self.cumulative_reward_info = { | ||
"reward_time": 0, | ||
"reward_reverse": 0, | ||
"reward_forward": 0, | ||
"Original_reward": 0, | ||
} | ||
return result | ||
|
||
def step(self, action: int): | ||
state, reward, terminated, truncated, info = super().step(action) | ||
self.cumulative_reward_info["reward_time"] += reward[0] | ||
self.cumulative_reward_info["reward_reverse"] += reward[1] | ||
self.cumulative_reward_info["reward_forward"] += reward[2] | ||
self.cumulative_reward_info["Original_reward"] += -1 | ||
return state, reward, terminated, truncated, self.cumulative_reward_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.