Convert Figma logo to code with AI

microsoft logomalmo

Project Malmo is a platform for Artificial Intelligence experimentation and research built on top of Minecraft. We aim to inspire a new generation of research into challenging new problems presented by this unique environment. --- For installation instructions, scroll down to *Getting Started* below, or visit the project page for more information:

4,181
604
4,181
171

Top Related Projects

35,868

A toolkit for developing and comparing reinforcement learning algorithms.

18,027

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.

OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games.

Universe: a software platform for measuring and training an AI's general intelligence across the world's supply of games, websites and other applications.

An API standard for multi-agent reinforcement learning environments, with popular reference environments and related utilities

Quick Overview

Project Malmo is an AI experimentation platform built on top of Minecraft. It allows researchers and developers to create and test AI agents in complex, interactive 3D environments. Malmo provides a flexible framework for defining tasks, rewards, and observations for AI agents within the Minecraft world.

Pros

  • Rich, customizable 3D environment for AI research
  • Supports multiple programming languages (Python, C#, C++, Java)
  • Large community and extensive documentation
  • Integrates well with popular machine learning libraries

Cons

  • Steep learning curve for newcomers to AI and Minecraft
  • Performance can be resource-intensive, especially for complex scenarios
  • Limited to Minecraft's graphical capabilities and physics engine
  • Requires Minecraft installation and setup

Code Examples

  1. Creating a simple Malmo mission:
import MalmoPython

agent_host = MalmoPython.AgentHost()
my_mission = MalmoPython.MissionSpec()
my_mission.timeLimitInSeconds(10)
my_mission.requestVideo(320, 240)
my_mission.setViewpoint(1)

agent_host.startMission(my_mission, MalmoPython.MissionRecordSpec())
  1. Retrieving observations from the Minecraft environment:
world_state = agent_host.getWorldState()
if world_state.number_of_observations_since_last_state > 0:
    msg = world_state.observations[-1].text
    observations = json.loads(msg)
    block_in_front = observations.get('block_in_front', 'unknown')
    print(f"Block in front: {block_in_front}")
  1. Sending commands to the agent:
agent_host.sendCommand("move 1")    # Move forward
agent_host.sendCommand("turn 0.5")  # Turn right
agent_host.sendCommand("jump 1")    # Jump

Getting Started

  1. Install Minecraft and Malmo:

    pip install malmo
    
  2. Set up environment variables:

    export MALMO_XSD_PATH=/path/to/malmo/Schemas
    
  3. Create a simple Malmo mission:

    import MalmoPython
    
    agent_host = MalmoPython.AgentHost()
    my_mission = MalmoPython.MissionSpec()
    my_mission.timeLimitInSeconds(10)
    my_mission.requestVideo(320, 240)
    
    agent_host.startMission(my_mission, MalmoPython.MissionRecordSpec())
    
    # Wait for mission to start
    world_state = agent_host.getWorldState()
    while not world_state.has_mission_begun:
        time.sleep(0.1)
        world_state = agent_host.getWorldState()
    
    # Mission loop
    while world_state.is_mission_running:
        agent_host.sendCommand("move 1")
        time.sleep(0.5)
        world_state = agent_host.getWorldState()
    

This example creates a simple mission where the agent moves forward for 10 seconds.

Competitor Comparisons

35,868

A toolkit for developing and comparing reinforcement learning algorithms.

Pros of Gym

  • Broader range of environments, including classic control, robotics, and Atari games
  • More active community and frequent updates
  • Easier integration with popular deep learning frameworks

Cons of Gym

  • Less focus on specific domains like Minecraft
  • May require additional dependencies for certain environments
  • Limited built-in visualization tools

Code Comparison

Gym:

import gym
env = gym.make('CartPole-v1')
observation = env.reset()
for _ in range(1000):
    action = env.action_space.sample()
    observation, reward, done, info = env.step(action)

Malmo:

import MalmoPython
agent_host = MalmoPython.AgentHost()
my_mission = MalmoPython.MissionSpec(mission_xml, True)
agent_host.startMission(my_mission, my_client_pool, my_mission_record, 0, "")
world_state = agent_host.getWorldState()

Gym provides a simpler API for environment interaction, while Malmo offers more detailed control over the Minecraft-specific environment. Gym's broader scope makes it suitable for various reinforcement learning tasks, whereas Malmo excels in Minecraft-based AI research. The choice between the two depends on the specific requirements of the project and the desired level of environment customization.

18,027

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.

Pros of ml-agents

  • Broader application scope, supporting various game types and simulations
  • More active development and community support
  • Seamless integration with Unity, a popular game development engine

Cons of ml-agents

  • Steeper learning curve for non-Unity developers
  • Potentially higher resource requirements for complex environments

Code Comparison

ml-agents:

from mlagents_envs.environment import UnityEnvironment
from mlagents_envs.side_channel.engine_configuration_channel import EngineConfigurationChannel

channel = EngineConfigurationChannel()
env = UnityEnvironment(file_name="MyEnvironment", side_channels=[channel])

Malmo:

import MalmoPython

agent_host = MalmoPython.AgentHost()
my_mission = MalmoPython.MissionSpec(my_mission_xml, True)
my_mission_record = MalmoPython.MissionRecordSpec()
agent_host.startMission(my_mission, my_mission_record)

Both repositories provide frameworks for reinforcement learning in game-like environments. Malmo focuses specifically on Minecraft-based research, while ml-agents offers a more versatile platform for various Unity-based simulations. ml-agents benefits from Unity's widespread use in game development, making it more accessible to a broader audience. However, this can also make it more complex for those unfamiliar with Unity. Malmo's Minecraft focus provides a more constrained but potentially easier-to-use environment for specific research tasks.

OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games.

Pros of Open Spiel

  • Broader scope: Supports a wide variety of games and environments
  • Active development: More frequent updates and contributions
  • Extensive documentation and examples

Cons of Open Spiel

  • Steeper learning curve due to its broader scope
  • Less focus on 3D environments and visual aspects

Code Comparison

Malmo (Lua):

local my_mission = MissionSpec()
my_mission:drawBlock(3,0,3,"stone")
my_mission:createAgentStart(0.5, 0, 0.5)

Open Spiel (Python):

game = pyspiel.load_game("tic_tac_toe")
state = game.new_initial_state()
legal_actions = state.legal_actions()

Summary

Malmo focuses on AI experimentation in Minecraft, offering a 3D environment with visual feedback. Open Spiel provides a broader platform for reinforcement learning across various games and environments. While Malmo excels in 3D simulations, Open Spiel offers more versatility in game types and algorithms. The choice between them depends on specific research needs and the desired level of visual complexity in the experiments.

Universe: a software platform for measuring and training an AI's general intelligence across the world's supply of games, websites and other applications.

Pros of Universe

  • Supports a wider range of environments, including web browsers and Flash games
  • Designed for more general AI training across diverse tasks
  • Integrates well with OpenAI Gym for reinforcement learning

Cons of Universe

  • Less focused on a specific domain (like Minecraft in Malmo)
  • May require more setup and configuration for specific use cases
  • Potentially steeper learning curve for beginners

Code Comparison

Universe:

import gym
import universe

env = gym.make('flashgames.DuskDrive-v0')
observation_n = env.reset()

while True:
    action_n = [[('KeyEvent', 'ArrowUp', True)] for _ in observation_n]
    observation_n, reward_n, done_n, info = env.step(action_n)

Malmo:

import MalmoPython

agent_host = MalmoPython.AgentHost()
my_mission = MalmoPython.MissionSpec(mission_xml, True)
my_mission_record = MalmoPython.MissionRecordSpec()

agent_host.startMission(my_mission, my_mission_record)
world_state = agent_host.getWorldState()

Both repositories offer platforms for AI research and development, but they cater to different needs. Universe provides a broader scope for general AI training across various environments, while Malmo focuses specifically on Minecraft-based AI experiments. Universe's flexibility comes at the cost of potentially more complex setup, whereas Malmo offers a more streamlined experience within its domain.

An API standard for multi-agent reinforcement learning environments, with popular reference environments and related utilities

Pros of PettingZoo

  • Broader scope: Supports various multi-agent environments beyond just Minecraft
  • More active development: Regular updates and contributions from the community
  • Easier integration: Designed to work seamlessly with popular RL libraries

Cons of PettingZoo

  • Less immersive: Lacks the rich 3D environment provided by Malmo's Minecraft integration
  • Potentially less realistic: Some environments may be more abstract compared to Malmo's real-world-like scenarios

Code Comparison

Malmo example:

import MalmoPython

agent_host = MalmoPython.AgentHost()
my_mission = MalmoPython.MissionSpec(mission_xml, True)
my_mission_record = MalmoPython.MissionRecordSpec()

agent_host.startMission(my_mission, my_mission_record)

PettingZoo example:

from pettingzoo.butterfly import knights_archers_zombies_v10

env = knights_archers_zombies_v10.env()
env.reset()

for agent in env.agent_iter():
    observation, reward, done, info = env.last()
    action = policy(observation)
    env.step(action)

The code examples demonstrate the initialization and basic usage of each library. Malmo focuses on setting up a Minecraft-based mission, while PettingZoo provides a more generalized approach to multi-agent environments.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Malmö

Project Malmö is a platform for Artificial Intelligence experimentation and research built on top of Minecraft. We aim to inspire a new generation of research into challenging new problems presented by this unique environment.

Join the chat at https://gitter.im/Microsoft/malmo Build Status license

Getting Started

MalmoEnv

MalmoEnv implements an Open AI "gym"-like environment in Python without any native code (communicating directly with Java Minecraft). If you only need this functionallity then please see MalmoEnv. This will most likely be the preferred way to develop with Malmo Minecraft going forward.

If you wish to use the "native" Malmo implementation, either install the "Malmo native Python wheel" (if available for your platform) or a pre-built binary release (more on these options below). Building Malmo yourself from source is always an option!

Advantages:

  1. No native code - you don't have to build or install platform dependent code.
  2. A single network connection is used to run missions. No dynamic ports means it's more virtualization friendly.
  3. A simpler multi-agent coordination protocol. One Minecraft client instance, one single port is used to start missions.
  4. Less impedance miss-match with the gym api.

Disadvantages:

  1. The existing Malmo examples are not supported (as API used is different). Marlo envs should work with this port.
  2. The API is more limited (e.g. selecting video options) - can edit mission xml directly.

Malmo as a native Python wheel

On common Windows, MacOSX and Linux variants it is possible to use pip3 install malmo to install Malmo as a python with native code package: Pip install for Malmo. Once installed, the malmo Python module can be used to download source and examples and start up Minecraft with the Malmo game mod.

Alternatively, a pre-built version of Malmo can be installed as follows:

  1. Download the latest pre-built version, for Windows, Linux or MacOSX.
    NOTE: This is not the same as downloading a zip of the source from Github. Doing this will not work unless you are planning to build the source code yourself (which is a lengthier process). If you get errors along the lines of "ImportError: No module named MalmoPython" it will probably be because you have made this mistake.

  2. Install the dependencies for your OS: Windows, Linux, MacOSX.

  3. Launch Minecraft with our Mod installed. Instructions below.

  4. Launch one of our sample agents, as Python, C#, C++ or Java. Instructions below.

  5. Follow the Tutorial

  6. Explore the Documentation. This is also available in the readme.html in the release zip.

  7. Read the Blog for more information.

If you want to build from source then see the build instructions for your OS: Windows, Linux, MacOSX.


Problems:

We're building up a Troubleshooting page of the wiki for frequently encountered situations. If that doesn't work then please ask a question on our chat page or open a new issue.


Launching Minecraft with our Mod:

Minecraft needs to create windows and render to them with OpenGL, so the machine you do this from must have a desktop environment.

Go to the folder where you unzipped the release, then:

cd Minecraft
launchClient (On Windows)
./launchClient.sh (On Linux or MacOSX)

or, e.g. launchClient -port 10001 to launch Minecraft on a specific port.

on Linux or MacOSX: ./launchClient.sh -port 10001

NB: If you run this from a terminal, the bottom line will say something like "Building 95%" - ignore this - don't wait for 100%! As long as a Minecraft game window has opened and is displaying the main menu, you are good to go.

By default the Mod chooses port 10000 if available, and will search upwards for a free port if not, up to 11000. The port chosen is shown in the Mod config page.

To change the port while the Mod is running, use the portOverride setting in the Mod config page.

The Mod and the agents use other ports internally, and will find free ones in the range 10000-11000 so if administering a machine for network use these TCP ports should be open.


Launch an agent:

Running a Python agent:

cd Python_Examples
python3 run_mission.py

Running a C++ agent:

cd Cpp_Examples

To run the pre-built sample:

run_mission (on Windows)
./run_mission (on Linux or MacOSX)

To build the sample yourself:

cmake .
cmake --build .
./run_mission (on Linux or MacOSX)
Debug\run_mission.exe (on Windows)

Running a C# agent:

To run the pre-built sample (on Windows):

cd CSharp_Examples
CSharpExamples_RunMission.exe

To build the sample yourself, open CSharp_Examples/RunMission.csproj in Visual Studio.

Or from the command-line:

cd CSharp_Examples

Then, on Windows:

msbuild RunMission.csproj /p:Platform=x64
bin\x64\Debug\CSharpExamples_RunMission.exe

Running a Java agent:

cd Java_Examples
java -cp MalmoJavaJar.jar:JavaExamples_run_mission.jar -Djava.library.path=. JavaExamples_run_mission (on Linux or MacOSX)
java -cp MalmoJavaJar.jar;JavaExamples_run_mission.jar -Djava.library.path=. JavaExamples_run_mission (on Windows)

Running an Atari agent: (Linux only)

cd Python_Examples
python3 ALE_HAC.py

Citations

Please cite Malmo as:

Johnson M., Hofmann K., Hutton T., Bignell D. (2016) The Malmo Platform for Artificial Intelligence Experimentation. Proc. 25th International Joint Conference on Artificial Intelligence, Ed. Kambhampati S., p. 4246. AAAI Press, Palo Alto, California USA. https://github.com/Microsoft/malmo


Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.