Skip to content

Commit

Permalink
Fix fishwood's inconsistent observation dimension (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Alegre <[email protected]>
  • Loading branch information
timondesch and LucasAlegre authored Sep 7, 2024
1 parent 7087d48 commit 389b919
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mo_gymnasium/envs/fishwood/fishwood.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class FishWood(gym.Env, EzPickle):
"""

metadata = {"render_modes": ["human"]}
FISH = 0
WOOD = 1
FISH = np.array([0], dtype=np.int32)
WOOD = np.array([1], dtype=np.int32)
MAX_TS = 200

def __init__(self, render_mode: Optional[str] = None, fishproba=0.1, woodproba=0.9):
Expand All @@ -55,17 +55,17 @@ def __init__(self, render_mode: Optional[str] = None, fishproba=0.1, woodproba=0

self.action_space = spaces.Discrete(2) # 2 actions, go fish and go wood
# 2 states, fishing and in the woods
self.observation_space = spaces.Discrete(2)
self.observation_space = spaces.Box(low=0, high=1, shape=(1,), dtype=np.int32)
# 2 objectives, amount of fish and amount of wood
self.reward_space = spaces.Box(low=np.array([0, 0]), high=np.array([1.0, 1.0]), dtype=np.float32)
self.reward_dim = 2

self._state = self.WOOD
self._state = self.WOOD.copy()

def reset(self, seed=None, **kwargs):
super().reset(seed=seed)

self._state = self.WOOD
self._state = self.WOOD.copy()
self._timestep = 0
if self.render_mode == "human":
self.render()
Expand All @@ -89,7 +89,7 @@ def step(self, action):
rewards[self.FISH] = 1.0

# Execute the action
self._state = action
self._state = np.array([action], dtype=np.int32)
self._timestep += 1

if self.render_mode == "human":
Expand Down

0 comments on commit 389b919

Please sign in to comment.