-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
860 additions
and
517 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,3 @@ | ||
test: | ||
flake8 | ||
py.test |
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
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
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,28 @@ | ||
import logging | ||
|
||
import gym | ||
import gym_maze # noqa: F401 | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
if __name__ == '__main__': | ||
maze = gym.make('Maze288-v0') | ||
maze.render() | ||
# for i_episode in range(1): | ||
# observation = maze.reset() | ||
# | ||
# for t in range(100): | ||
# logging.info(f"Time: [{t}], observation: [{observation}]") | ||
# | ||
# action = maze.action_space.sample() | ||
# | ||
# logging.info("\t\tExecuted action: [{}]".format(action)) | ||
# | ||
# observation, reward, done, info = maze.step(action) | ||
# | ||
# if done: | ||
# logging.info(f"Episode finished after {t+1} steps.") | ||
# logging.info(f"Last reward: {reward}") | ||
# break | ||
|
||
logging.info("Finished") |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import gym | ||
import gym_taxi_goal | ||
import gym_taxi_goal # noqa: F401 | ||
|
||
|
||
if __name__ == '__main__': | ||
|
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
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
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
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,4 @@ | ||
MAZE_PATH = 0 | ||
MAZE_WALL = 1 | ||
MAZE_ANIMAT = 5 | ||
MAZE_REWARD = 9 |
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 @@ | ||
import random | ||
|
||
import gym | ||
import numpy as np | ||
|
||
from gym_maze.common import MAZE_ANIMAT, MAZE_WALL, MAZE_PATH, MAZE_REWARD | ||
|
||
|
||
class MazeObservationSpace(gym.Space): | ||
def __init__(self, n): | ||
# n is the number of visible neighbour fields, typically 8 | ||
self.np_random = np.random.RandomState() | ||
self.n = n | ||
gym.Space.__init__(self, (self.n,), str) | ||
|
||
def seed(self, seed): | ||
self.np_random.seed(seed) | ||
|
||
def sample(self): | ||
states = map(str, [MAZE_PATH, MAZE_WALL, MAZE_REWARD]) | ||
return tuple(random.choice(list(states)) for _ in range(self.n)) | ||
|
||
def contains(self, x): | ||
states = map(str, [MAZE_PATH, MAZE_WALL, MAZE_ANIMAT, MAZE_REWARD]) | ||
return all(elem in states for elem in x) | ||
|
||
def to_jsonable(self, sample_n): | ||
return list(sample_n) | ||
|
||
def from_jsonable(self, sample_n): | ||
return tuple(sample_n) |
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,26 @@ | ||
import numpy as np | ||
from gym.utils import colorize | ||
|
||
from gym_maze.common import MAZE_ANIMAT, MAZE_WALL, MAZE_PATH, MAZE_REWARD | ||
|
||
|
||
def render(out, board: np.ndarray): | ||
out.write("\n") | ||
board = np.copy(board) | ||
|
||
for row in board: | ||
out.write(" ".join(_render_element(el) for el in row)) | ||
out.write("\n") | ||
|
||
|
||
def _render_element(el): | ||
if el == MAZE_WALL: | ||
return colorize('■', 'gray') | ||
elif el == MAZE_PATH: | ||
return colorize('□', 'white') | ||
elif el == MAZE_REWARD: | ||
return colorize('$', 'yellow') | ||
elif el == MAZE_ANIMAT: | ||
return colorize('A', 'red') | ||
else: | ||
return colorize(el, 'cyan') |
Oops, something went wrong.