Coder Social home page Coder Social logo

gym_missile_command's Introduction

gym_missile_command

Open AI Gym environment of the Missile Command Atari game.

Demonstration (gif)

Game

The player musts defend 6 cities from incoming enemy ballistic missiles. To do so, he can fire missiles from an anti-missiles battery. An episode ends when all enemy missiles or cities are destroyed. This environment does not reproduce an exact version of the Missile Command Atari game but a simplified one.

  • The anti-missiles battery can not be destroyed.
  • There are no levels, all episodes have the same difficulty.
  • Enemy missiles do not have an explosion radius and do not split.

The reward depends on several variables, each one contributing to a specific wanted skill of the agent.

  • Number of cities destroyed, to protect the cities.
  • Number of enemy missiles destroyed, to improve accuracy.
  • Number of missiles launched, to minimize the use of missiles.

Installation

Python 3.8+ is required. The installation is done with the following commands.

git clone https://github.com/ElieKadoche/gym_missile_command.git
pip install -e ./gym_missile_command

Examples

For a human to play, commands are: arrow keys to move the target and space to fire a missile.

python -m gym_missile_command.examples.random_agent  # For a random agent to play
python -m gym_missile_command.examples.human_agent  # For a human to play

Usage

import gymnasium as gym

import gym_missile_command

# Environment configuration (see CONFIG.md)
env_context = {"ENEMY_MISSILES.NUMBER": 42,
               "FRIENDLY_MISSILES.EXPLOSION_RADIUS": 17}

# Create the environment
env = gym.make("missile-command-v0", env_context=env_context)

# Reset it
observation, info = env.reset(seed=None)

# While the episode is not finished
terminated = False
while not terminated:

    # Select an action (here, a random one)
    action = env.action_space.sample()

    # One step forward
    observation, reward, terminated, truncated, info = env.step(action)

    # Render (or not) the environment
    env.render()

# Close the environment
env.close()

gym_missile_command's People

Contributors

eliekadoche avatar

Stargazers

 avatar  avatar  avatar  avatar Chace Ashcraft avatar Ryusuke Hokuto avatar  avatar Norio Kosaka avatar talha korkmaz avatar  avatar  avatar Simon Queyrut avatar  avatar

Watchers

 avatar

gym_missile_command's Issues

Pip install fails

Pip install did not work for me.

Obtaining file:///Users/ashcrcc1/PycharmProjects/drl_missile_command/gym_missile_command
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      error: Multiple top-level packages discovered in a flat-layout: ['materials', 'gym_missile_command'].
      
      To avoid accidental inclusion of unwanted files or directories,
      setuptools will not proceed with this build.
      
      If you are trying to create a single distribution with multiple packages
      on purpose, you should not rely on automatic discovery.
      Instead, consider the following options:
      
      1. set up custom discovery (`find` directive with `include` or `exclude`)
      2. use a `src-layout`
      3. explicitly set `py_modules` or `packages` with a list of names
      
      To find more information, look for "package discovery" on setuptools docs.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

adding py_modules=['gym_missile_command'] to the setup call in setup.py allowed me to install, but I don't know if that is that preferred fix.

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.