Code Monkey home page Code Monkey logo

gym-minecraft's Introduction

Gym Minecraft

Gym Minecraft is an environment bundle for OpenAI Gym. It is based on Microsoft's Malmö, which is a platform for Artificial Intelligence experimentation and research built on top of Minecraft.

MinecraftDefaultWorld1-v0
MinecraftDefaultFlat1-v0
MinecraftTrickyArena1-v0
MinecraftEating1-v0
MinecraftCliffWalking1-v0
MinecraftMaze1-v0
MinecraftMaze2-v0
MinecraftBasic-v0
MinecraftObstacles-v0
MinecraftSimpleRoomMaze-v0
MinecraftAttic-v0
MinecraftVertical-v0
MinecraftComplexityUsage-v0
MinecraftMedium-v0
MinecraftHard-v0

Basically these are original Malmö missions with only <PrioritiseOffscreenRendering> added to speed up training.

Installation

  1. Install the dependencies for your OS: Windows, Linux, MacOSX. You can skip Torch, Mono and ALE parts.

  2. Install OpenAI Gym and its dependencies.

pip install gym
  1. Download and install minecraft_py.
git clone https://github.com/tambetm/minecraft-py.git
cd minecraft-py
# NB! `minecraft_py` should be installed to writable user directory, either in virtualenv or with `--user` option.
python setup.py install
  1. Download and install gym-minecraft:
git clone https://github.com/tambetm/gym-minecraft.git
cd gym-minecraft
python setup.py install

gym-minecraft needs pygame to render Minecraft screen. It is best to have pygame installed via your system commands, i.e. sudo apt-get install python-pygame or conda install pygame. Otherwise setup will automatically download and compile pygame. This might need some additional dependencies though, see instructions for Ubuntu, OSX or Windows.

  1. Run once following snippet:
import logging
logging.basicConfig(level=logging.DEBUG)

import minecraft_py

proc, port = minecraft_py.start()
minecraft_py.stop(proc)

Basically Minecraft downloads and compiles everything on first start, this snippet just starts minecraft_py in debug mode, so you can see when Minecraft gets stuck.

Running

import gym
import gym_minecraft

env = gym.make('MinecraftBasic-v0')
env.init(start_minecraft=True)
env.reset()

done = False
while not done:
        env.render()
        action = env.action_space.sample()
        obs, reward, done, info = env.step(action)

env.close()

NB! Running Minecraft for the first time might take a while as it downloads and compiles itself. Next time the startup time should be shorter, but still around 30 seconds. In active development phase you might want to start one permanent Minecraft process in background and remove start_minecraft=True, see wiki.

Overriding default settings

The default settings for environments might not be optimal for you. Luckily you can easily override them using init().

For example to use discrete actions instead of continuous actions:

env = gym.make('MinecraftBasic-v0')
env.init(allowDiscreteMovement=["move", "turn"])

To use continuous actions instead of discrete actions:

env = gym.make('MinecraftBasic-v0')
env.init(allowContinuousMovement=["move", "turn"])

To use different video resolution:

env = gym.make('MinecraftBasic-v0')
env.init(videoResolution=[40, 30])

More documentation about configuration options is in wiki.

gym-minecraft's People

Contributors

tambetm avatar yet-another-account avatar bowenjiangubc avatar figgybit avatar

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.