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

Update windy_gridworld_env.py #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
57 changes: 30 additions & 27 deletions gym_windy_gridworlds/envs/windy_gridworld_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,36 @@ def render(self, mode='human', close=False):
''' Renders the environment. Code borrowed and then modified
from
https://github.com/openai/gym/blob/master/gym/envs/toy_text/cliffwalking.py'''
outfile = sys.stdout
nS = self.grid_height * self.grid_width
shape = (self.grid_height, self. grid_width)

outboard = ""
for y in range(-1, self.grid_height + 1):
outline = ""
for x in range(-1, self.grid_width + 1):
position = (y, x)
if self.observation == position:
output = "X"
elif position == self.goal_state:
output = "G"
elif position == self.start_state:
output = "S"
elif x in {-1, self.grid_width } or y in {-1, self.grid_height}:
output = "#"
else:
output = " "

if position[1] == shape[1]:
output += '\n'
outline += output
outboard += outline
outboard += '\n'
outfile.write(outboard)


try:
outfile = sys.stdout
nS = self.grid_height * self.grid_width
shape = (self.grid_height, self. grid_width)

outboard = ""
for y in range(-1, self.grid_height + 1):
outline = ""
for x in range(-1, self.grid_width + 1):
position = (y, x)
if self.observation == position:
output = "X"
elif position == self.goal_state:
output = "G"
elif position == self.start_state:
output = "S"
elif x in {-1, self.grid_width } or y in {-1, self.grid_height}:
output = "#"
else:
output = " "

if position[1] == shape[1]:
output += '\n'
outline += output
outboard += outline
outboard += '\n'
outfile.write(outboard)
except AttributeError:
raise RuntimeError("You should first reset the environment.")
def seed(self, seed=None):
pass

Expand Down