-
-
Notifications
You must be signed in to change notification settings - Fork 15
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 #35 from rradules/mo-games
Merge Mo-Games into main
- Loading branch information
Showing
21 changed files
with
1,462 additions
and
4 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 @@ | ||
"""Adaptation of the Breakthrough game to multi-objective settings.""" |
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
"""MO Breakthrough check.""" | ||
|
||
import numpy as np | ||
from breakthrough import MOBreakthrough | ||
|
||
|
||
def check_env(): | ||
"""Check the environment.""" | ||
environment = MOBreakthrough(board_width=6, board_height=6, num_objectives=4, render_mode="ansi") | ||
environment.reset(seed=42) | ||
|
||
for agent in environment.agent_iter(): | ||
observation, reward, termination, truncation, info = environment.last() | ||
|
||
print("rewards from the last timestep", reward) | ||
print("cumulative rewards before action", environment._cumulative_rewards) | ||
if termination or truncation: | ||
action = None | ||
else: | ||
if observation: | ||
print("environment before action:") | ||
environment.render() | ||
# print("observation:") | ||
# print(observation) | ||
# this is where you would insert your policy | ||
action = np.where(observation["action_mask"] != 0)[0][0] | ||
print("action: ", action) | ||
|
||
environment.step(action) | ||
print("environment after action:") | ||
environment.render() | ||
print("cumulative rewards after action", environment._cumulative_rewards) | ||
|
||
# print("observation: ", observation) | ||
# print("reward: ", reward) | ||
print("game end: rewards", environment.rewards) | ||
print("game end: cumulative rewards", environment._cumulative_rewards) | ||
# name = input("Press key to end\n") | ||
environment.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
(check_env()) |
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,5 @@ | ||
"""Breakthrough environment with multiple objectives.""" | ||
from momaland.envs.breakthrough.breakthrough import env, raw_env | ||
|
||
|
||
__all__ = ["env", "raw_env"] |
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 @@ | ||
"""Adaptation of the Connect4 game to multi-objective settings.""" |
Oops, something went wrong.