Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wumpus-tessaris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lanti Davide
wumpus-tessaris
Commits
5e005132
Commit
5e005132
authored
4 years ago
by
Tessaris Sergio
Browse files
Options
Downloads
Patches
Plain Diff
feat: handling missing gym module
parent
fd779ece
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/gym-random-hunter.py
+11
-8
11 additions, 8 deletions
examples/gym-random-hunter.py
gym_wumpus/__init__.py
+4
-3
4 additions, 3 deletions
gym_wumpus/__init__.py
with
15 additions
and
11 deletions
examples/gym-random-hunter.py
+
11
−
8
View file @
5e005132
...
...
@@ -3,12 +3,11 @@
import
argparse
import
json
import
gym
from
gym
import
envs
import
gym_wumpus
from
gym_wumpus.envs
import
WumpusEnv
from
gym
import
envs
,
error
,
make
def
run_episode
(
env
:
WumpusEnv
):
obs
=
env
.
reset
()
...
...
@@ -39,13 +38,17 @@ def main():
return
if
args
.
file
is
not
None
:
env
=
gym
.
make
(
'
wumpus-custom-v0
'
,
desc
=
json
.
load
(
args
.
file
))
env
=
make
(
'
wumpus-custom-v0
'
,
desc
=
json
.
load
(
args
.
file
))
else
:
try
:
env
=
gym
.
make
(
args
.
id
)
except
:
env
=
gym
.
make
(
default_env
)
run_episode
(
env
)
env
=
make
(
args
.
id
)
except
error
.
Error
as
e
:
print
(
'
Bad Gym environment {}, using {}. Error is {}
'
.
format
(
args
.
id
,
default_env
,
e
))
env
=
make
(
default_env
)
if
isinstance
(
env
,
WumpusEnv
):
run_episode
(
env
)
else
:
print
(
'
Environment {} is not a Wumpus world.
'
.
format
(
env
))
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
gym_wumpus/__init__.py
+
4
−
3
View file @
5e005132
from
gym.envs.registration
import
register
__version__
=
"
1.0.0
"
try
:
from
gym.envs.registration
import
register
except
ImportError
as
e
:
raise
Exception
(
'
OpenAI gym not installed, you should install wumpus package with [gym] feature.
'
)
from
e
register
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment