Giter Site home page Giter Site logo

mgym's Introduction

Multi-agent gym environments

snakeclip

This repository has a collection of multi-agent OpenAI gym environments.

DISCLAIMER: This project is in its early stages --- it is still a work in progress.

Dependencies

  • gym
  • numpy

Installation

git clone https://github.com/cjm715/mgym.git
cd mgym/
pip install -e .

Environments

Examples

import gym
import mgym
import random

env = gym.make('TicTacToe-v0')
fullobs = env.reset()
while True:
    print('Player O ') if fullobs[0] else print('Player X')
    a = random.choice(env.get_available_actions())
    fullobs,rewards,done,_ = env.step(a)
    env.render()
    if done:
        break
import gym
import mgym

env = gym.make('MatchingPennies-v0')
env.reset(3)
while True:
    a = env.action_space.sample()
    _,r,done,_ = env.step(a)
    env.render()
    if done:
        break

See further examples in mgym/examples/examples.ipynb.

How are multi-agent environments different than single-agent environments?

When dealing with multiple agents, the environment must communicate which agent(s) can act at each time step. This information must be incorporated into observation space. Conversely, the environment must know which agents are performing actions. Therefore this must be communicated in the action passed to the environment. The form of the API used for passing this information depends on the type of game. The two types are

  • one-at-a-time play (like TicTacToe, Go, Monopoly, etc) or
  • simultaneous play (like Soccer, Basketball, Rock-Paper-Scissors, etc).

In the TicTacToe example above, this is an instance of one-at-a-time play. The fullobs is a tuple (next_agent, obs). The variable next_agent indicates which agent will act next. obs is the typical observation of the environment state. The action a is also a tuple given by a = (acting_agent, action) where the acting_agent is the agent acting with the action given by variable action.

Testing

To run tests, install pytest with pip install pytest and run python -m pytest

mgym's People

Contributors

cjm715 avatar worldlife123 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.