Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fishwood's inconsistent observation dimension #103

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading