MCPcopy
hub / github.com/geek-ai/MAgent

github.com/geek-ai/MAgent @main sqlite

repository ↗ · DeepWiki ↗
373 symbols 1,319 edges 66 files 145 documented · 39%
README

This project is no longer maintained

Please see https://github.com/Farama-Foundation/MAgent2 for a maintained fork of this project that's installable with pip.

MAgent

MAgent is a research platform for many-agent reinforcement learning. Unlike previous research platforms that focus on reinforcement learning research with a single agent or only few agents, MAgent aims at supporting reinforcement learning research that scales up from hundreds to millions of agents.

Requirement

MAgent supports Linux and OS X running Python 2.7 or python 3. We make no assumptions about the structure of your agents. You can write rule-based algorithms or use deep learning frameworks.

Install on Linux

git clone git@github.com:geek-ai/MAgent.git
cd MAgent

sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev

bash build.sh
export PYTHONPATH=$(pwd)/python:$PYTHONPATH

Install on OSX

Note: There is an issue with homebrew for installing websocketpp, please refer to #17

git clone git@github.com:geek-ai/MAgent.git
cd MAgent

brew install cmake llvm boost@1.55
brew install jsoncpp argp-standalone
brew tap david-icracked/homebrew-websocketpp
brew install --HEAD david-icracked/websocketpp/websocketpp
brew link --force boost@1.55

bash build.sh
export PYTHONPATH=$(pwd)/python:$PYTHONPATH

Docs

Get started

Examples

The training time of following tasks is about 1 day on a GTX1080-Ti card. If out-of-memory errors occur, you can tune infer_batch_size smaller in models.

Note : You should run following examples in the root directory of this repo. Do not cd to examples/.

Train

Three examples shown in the above video. Video files will be saved every 10 rounds. You can use render to watch them.

  • pursuit

    python examples/train_pursuit.py --train

  • gathering

    python examples/train_gather.py --train

  • battle

    python examples/train_battle.py --train

    Play

    An interactive game to play with battle agents. You will act as a general and dispatch your soldiers.

  • battle game python examples/show_battle_game.py

Baseline Algorithms

The baseline algorithms parameter-sharing DQN, DRQN, a2c are implemented in Tensorflow and MXNet. DQN performs best in our large number sharing and gridworld settings.

Acknowledgement

Many thanks to Tianqi Chen for the helpful suggestions.

Core symbols most depended-on inside this repo

append
called by 151
python/magent/utility.py
get_num
called by 42
python/magent/gridworld.py
add_agents
called by 32
python/magent/gridworld.py
set
called by 26
python/magent/gridworld.py
add_reward_rule
called by 26
python/magent/gridworld.py
reset
called by 23
python/magent/gridworld.py
add_group
called by 23
python/magent/gridworld.py
get_view_space
called by 20
python/magent/gridworld.py

Shape

Method 239
Function 99
Class 35

Languages

Python96%
TypeScript4%

Modules by API surface

python/magent/gridworld.py56 symbols
python/magent/discrete_snake.py30 symbols
python/magent/model.py24 symbols
python/magent/renderer/server/arrange_server.py23 symbols
python/magent/utility.py22 symbols
src/render/frontend/js/render-handle.js15 symbols
python/magent/renderer/server/battle_server.py14 symbols
python/magent/environment.py13 symbols
python/magent/builtin/tf_model/drqn.py13 symbols
examples/train_arrange.py13 symbols
python/magent/builtin/tf_model/dqn.py12 symbols
python/magent/builtin/mx_model/dqn.py12 symbols

For agents

$ claude mcp add MAgent \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact