Comments (2)
Hi @jlin816
Thanks for pointing this out and apologies for a late reply.
I see where the issue is. Firstly, MiniHack's seeding is slightly different from that of NLE's. The seeds
argument in of a MiniHack environment assumes a list of integers which is used as a training distribution for an agent, e.g. [1, 3, 9, 27]. (Perhaps the documentation should make this clearer)
Lines 175 to 177 in 2054e7f
Specifically, when a reset
function is called, minihack randomly samples one of the seeds, e.g. 27, (they are now stores as self._level_seeds
since we treat them as levels of the same environment) and sets it using nle.seed(27, 27, False)
like this
Lines 325 to 327 in 2054e7f
I understand this made the seed()
function ignored if seeds
was originally passed to the environment. Therefore, I added a new parameter in the reset()
function of minihack called sample_seed
(defaults to True). If True, the reset() function will randomly sample a level from the original list. If False, it will not do so, hence the manually setting the level seed with NLE's seed()
function will work as desired.
Here is the PR #68. Please let me know if it works for you.
from minihack.
With this new PR, here is how one would use the seeding functionality
import minihack, gym
env = gym.make("MiniHack-KeyRoom-Fixed-S5-v0",
observation_keys=("pixel", "colors", "chars", "glyphs", "tty_chars"),
seeds=[1, 3, 9, 27])
For now let's sample random episodes a few times
obs = env.reset()
env.render()
print(env.get_seeds())
This outputs
You are lucky! Full moon tonight.
|
----..|
|.....|
|@.(..|
-------
Agent the Footpad St:13 Dx:17 Co:13 In:13 Wi:13 Ch:9 Chaotic S:0
Dlvl:1 $:0 HP:12(12) Pw:2(2) AC:7 Xp:1/0
(27, 27, False)
or perhaps
You are lucky! Full moon tonight.
----
|..|
+..|
----..|
|.....|
|.(..@|
-------
Agent the Footpad St:14 Dx:18 Co:13 In:9 Wi:12 Ch:9 Chaotic S:0
Dlvl:1 $:0 HP:12(12) Pw:2(2) AC:7 Xp:1/0
(3, 3, False)
Now when we manually set the seed and use sample_seed=False
, we will get the exact level we want
env.seed(42, 42, False)
obs = env.reset(sample_seed=False)
env.render()
print(env.get_seeds())
will result in the following.
You are lucky! Full moon tonight.
----
|..|
+(.|
----..|
|.....|
|...@.|
-------
Agent the Footpad St:18/02 Dx:18 Co:13 In:8 Wi:9 Ch:7 Chaotic S:0
Dlvl:1 $:0 HP:12(12) Pw:2(2) AC:7 Xp:1/0
(42, 42, False)
from minihack.
Related Issues (20)
- [BUG] access to _actions HOT 1
- [BUG] `reward_lose` not correctly set at timeout HOT 1
- [BUG] Sokoban envs crash consistently
- [BUG] Minihack does not work with NLE v0.9.0 HOT 1
- flake8 link incorrect in pre-commit hook
- [QUESTION] any way to respawn the agent after death HOT 1
- [BUG] Can't decode reward (manager) HOT 2
- [FEATURE] HOT 2
- [BUG] TypeError: __init__() got an unexpected keyword argument 'archivefile' HOT 2
- [BUG] It looks like there some references to the legacy _actions property HOT 1
- [BUG] tty_* observations not changing during rollout HOT 1
- open source the editor HOT 1
- [BUG] FileNotFoundError: [Errno 2] No such file or directory: '/tmp/nlew7mo9hzl' HOT 2
- [BUG] Wrong link to paper in README
- [FEATURE] Gymnasium support HOT 2
- Help: running the "get_des_file_rendering" HOT 2
- [BUG] flake8 rejecting commits due to existing code HOT 2
- [BUG] Outdated documentation HOT 1
- Menus not resolving properly
- [FEATURE] Align to gym>=0.26 API HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minihack.