Git Product home page Git Product logo

crafter's Issues

VideoRecorder saving path error

First of all, thank you for this environment!

I think VideoRecorder has a small bug that causes duplicate directories in the path, which causes an error when saving logs.

Example of an error for directory="videos":

FileNotFoundError: The directory '/home/project_path/videos/videos' does not exist

Removing self._directory / from filename fixes this error for me.

filename = str(self._directory / (self._env.episode_name + '.mp4'))

Multiagent support

Thanks Hafner for this environment. Have you or anyone else made multiagent versions of it?

Can't initialize the enviroment

I followed the instructions but I got the error:

"reset() missing 1 required positional argument: 'self'"

When using:

env = crafter.Recorder(
env, './',
save_stats=True,
save_video=True,
save_episode=True,
)

env.reset()

Any solution? I really would like to try this environment :(

There is an functools has no "cache" error when I try to import crafter

The installation seems to go well but when I try to import crafter it doesn't work. I looked for some ways to solve this problem but the only solution I could find was to upgrade to Python 3.9 but I can't do that since I plan on using an online service like google colab or kaggle. What would you suggest I do?

Cannot install crafter

I'm trying to get DREAMER v3 working, but can't get all dependencies to install. I'm using >> pip install crafter or with specific version 1.8.2, and getting the following error (I was able to install version 1.8.1, but then got the error in using yaml when trying to do load):

I am using pip (23.3.1), python (3.9), and setuptools (69.0.1). After >> pip install crafter, I get this error:

Collecting crafter==1.8.2
Using cached crafter-1.8.2.tar.gz (107 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "~AppData\Local\Temp\pip-install-qn4q8ono\crafter_8c8a23be6c8f433b9c43fe2ca828a022\setup.py", line 10, in
long_description=pathlib.Path('README.md').read_text(),
File "~AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1267, in read_text
return f.read()
File "~AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 6432: character maps to
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Rainbow Hyperparameters

Hi. The paper mentions

Rainbow (Hessel et al., 2018) is based on Q-Learning and combines several advances, including for exploration. The defaults for Atari did not work well, so we tuned the hyper parameters for Crafter and found a compromise between Atari defaults and the data-efficient version of the method (van Hasselt et al., 2019) to be ideal.

Are these hyperparameters available anywhere, and if not, can you please share these? The crafter baselines for Rainbow has the same hyperparameters as Kaixhin's Rainbow (which are designed for ALE), and there are no hyper parameter values mentioned in the paper. Thanks for your time!

Error when using env.render() along with stable-baselines3

Hello,

In the gym.Env class, the first argument is defined as the mode, which is either "human" or "rgb_array". In Crafter, the render function takes only one argument, size. This causes errors when using stable-baselines3 to evaluate policies and create videos since their helper functions assume envs follow gym.Env and have the first argument as the mode.

A fix would be to just add a dummy first argument mode to the render function

crafter/crafter/env.py

Lines 120 to 122 in e955b11

def render(self, size=None):
size = size or self._size
unit = size // self._view

Integration in Envpool

Hi!

I was wondering if there exists a plan to integrate the crafter learning environment in Envpool. I think it would be very useful since it would allow training agents in parallel to benefit from the high-performance framework of Envpool, and build on top of great baselines.

There exists this guide which can be useful.

Thank you very much!

Saving videos

Hi!,

I am having problems with the recorder, as

env = crafter.Recorder(
  env, './logs',
  save_stats=True,
  save_video=True,
  save_episode=True,
)

returns TypeError: render() takes 1 positional argument but 2 were given

and

env.render()

returns AttributeError: 'NoneType' object has no attribute 'get'

Global View of the map

Hi! Is there any way to generate a global view of the map like the ones in the readme? I have seen a Global View class in engine.py but it is not implemented. Thank you!

ruamel.yaml version

The newest version of ruamel.yaml has removed the safe_load function used by crafter, causing the following error when trying to run through the gui:

AttributeError: 
"safe_load()" has been removed, use

  yaml = YAML(typ='safe', pure=True)
  yaml.load(...)

The can be fixed most easily by running
pip install "ruamel.yaml<0.18.0"

Any plan to make Crafter compatible with the latest Gym API?

The latest Gym API expects terminated, truncated rather than just done after a env.step(), and seeds the environment with env.reset(seed=seed) rather than env.seed(seed=seed). It is possible to apply a compatibility wrapper by making the env with env = gym.make('CrafterReward-v1', apply_api_compatibility=True) but to work properly the base env must have the env.seed(seed=seed) function, which your Env class does not have (instead, it has the self._seed attribute).

Is there any plan to add the env.seed() function, to make it fully compatible with the latest API? That would also make it compatible with Gymnasium.

Running analysis scripts with jsonl files

Hi!

I am not being able to load the scripts in the analysis folder with the stored .jsonl files from the Recorder. I think the format of the saved files (line-separated dictionaries) is not the expected format for the analysis code. It is also not the same as the .json files that are stored in the scores/ folder. Am I missing something?

Thank you!

Potentially port to the Griddly RL Engine

Hi @danijar!

I'm the creator of Griddly https://griddly.readthedocs.io/en/latest/ and I'm pretty sure it would be possible to port most of the crafter environment to use the Griddly Engine.

Using Griddly you get a bunch of features that work out of the box

  • Multi-agent interfaces (just put more players in the level map and it just works)
    • Hardware accellerated video recording per-agent and globally.
  • Really easily modifiable mechanics (you just change the YAML a bit)
  • 5 different ways to produce observations,
    • Vector observations can be about 70k observations per second (on a single thread))
    • 3 different GPU accellerated observation types (probably around 4k obs per second (on a single thread))
    • ASCII observations (if you're one of those NetHack/Dwarf Fortress nerds)
  • RLLib support (if you want to do multiple policies/agents competitive/collaborative etc)

It would be super simple to skin crafter like this also for interesting demos:
image

What do you think? There's definitely some things I'd have to add to Griddly (such as the chasing mechanics) But I've been looking to do that for a while anyway.

Ill see if I can make a super simple example and add some images/gifs this weekend.

Clarification about Training and Evalaution Steps

Hi. I am a little confused about how many steps should the agent train and then evalauted on. To add a little context, the paper mentions on pg2

Crafter evaluates many different abilities of an agent by training only on a single environment for 5M steps

and this can be seen in crafter_baselines code as well (e.g. PPO, Rainbow)

But in Sec 3.3 of the paper

An agent is granted a budget of 1M environment steps to interact with the environment.

elsewhere (pg 6, sec 4.1), multiple figures

budget of 1M environment steps

Table A.1

It is computed across all training episodes within the budget of 1M environment steps

I also see that you commented out evaluation code from the Rainbow code (here).

What I can make of this is that I need to run crafter agent for 1M steps (I saw the PPO example) and then use the saved stats (json file?) and the analysis code to calculate the success rate and score. Precisely, using the existing crafter code available, how can I go from training to plotting meaningful results. Can you please clarify? Thanks

How can I render when training an agent?

Hi, danijar.

Thanks for making a good environment.

I could check 'Play Yourself' and play the game myself. however, I just got information on (obs, reward, done, info), the gui game is not working when I tried to import crafter in a python script. And env.render() is also not working.

could you give me the answer how can I render in a python script?

dreamer v2 config

Hi,

Thank you for this environment. What would be the dreamer config for training this environment?

p.

Add no-enemy mode

It would be nice to add no-enemy mode, it would be extremely useful for learning game mechanics/crafting without dying or avoiding enemies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.