Code Monkey home page Code Monkey logo

magent's Introduction

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 [email protected]: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 [email protected]:geek-ai/MAgent.git
cd MAgent

brew install cmake llvm [email protected]
brew install jsoncpp argp-standalone
brew tap david-icracked/homebrew-websocketpp
brew install --HEAD david-icracked/websocketpp/websocketpp
brew link --force [email protected]

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.

magent's People

Contributors

bywbilly avatar jkterry1 avatar kipsora avatar kornbergfresnel avatar merrymercy avatar passionke avatar seawan avatar timerchen avatar wnzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magent's Issues

cannot find a blank position in a filled map

While I was running some simulation, this happened. I cannot replicate it since it happened only one. However, you might want to investigate it

terminate called after throwing an instance of 'std::runtime_error'
  what():  /home/MAgent/src/gridworld/Map.cc:60 : cannot find a blank position in a filled map

libwebsocketpp-dev 未发现软件包

XXXX-virtual-machine:~/MAgent-master$ sudo apt-get install cmake libwebsocketpp-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
E: 未发现软件包 libwebsocketpp-dev
前两个软件包没有问题 ,但是libwebsocketpp-dev显示未发现,应该如何解决。

How to implement different types of food, that gets consumed one by one. Or: How to prevent sampling to stop too early.

Hey, thanks for publishing this great platform!

Question: During --train mode, sampling seems to stop, if there's no agent of e.g. g_f left. Any tips how to prevent this / implement many different types of agents which get consumed one by one?

Use case: I tried to add food with different types of value to train_gather.py to see if agents gather the more valuable food first. Unfortunately I'm not able to set this up, because sampling simply stops when one of the food agents has been used up.

    g_s = cfg.add_group(agent)
    g_f = cfg.add_group(food)
    g_f_2 = cfg.add_group(food)

    a = gw.AgentSymbol(g_s, index='any')
    b = gw.AgentSymbol(g_f, index='any')
    c = gw.AgentSymbol(g_f_2, index='any')

    cfg.add_reward_rule(gw.Event(a, 'attack', b), receiver=a, value=5.0)
    cfg.add_reward_rule(gw.Event(a, 'attack', c), receiver=a, value=1.0)

Thank you!

g++版本咨询

您好,我按readme操作,在Ubuntu14.04上运行bash build.sh ,总是会报错。报错内容如下

/usr/lib/gcc/x86_64-linux-gnu/5/include/smmintrin.h: In function ‘__m128i _mm_cvtepi16_epi64(__m128i)’:
/usr/lib/gcc/x86_64-linux-gnu/5/include/smmintrin.h:508:59: error: cannot convert ‘__v8hi {aka short int}’ to ‘__vector(8) short int’ for argument ‘1’ to ‘__vector(2) long long int __builtin_ia32_pmovsxwq128(__vector(8) short int)’
   return (__m128i) __builtin_ia32_pmovsxwq128 ((__v8hi)__X);
                                                           ^
/usr/lib/gcc/x86_64-linux-gnu/5/include/smmintrin.h: In function ‘__m128i _mm_cvtepi8_epi16(__m128i)’:
/usr/lib/gcc/x86_64-linux-gnu/5/include/smmintrin.h:514:60: error: cannot convert ‘__v16qi {aka char}’ to ‘__vector(16) cha^Cmake[2]: *** wait: 没有子进程。 停止。

目前我的cmake版本是3.2.2,g++版本是5.4.1。我有在谷歌检索类似内容,但都没有答案。初步推断是g++的版本问题。因而想向您咨询g++版本。

How to get the neighbors for each agent?

Hi, at first, I want to express my thanks to this awesome framework!

I want to obtain the neighbors of each agent, i.e., the spacial local view include the observed agents of both group 1 and group 2, I want to obtain the IDs and positions of all it's neighbors.

Ubuntu 14.04 build problem

I'm not sure if ubuntu 14 is supported for this project, because when I sudo apt-get install libwebsocketpp-dev, there was no matching package.

When I build:

The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/shawnlue/Applications/MAgent/build
Scanning dependencies of target magent
Scanning dependencies of target render
Scanning dependencies of target testlib
[  3%] [  6%] [ 10%] Building CXX object CMakeFiles/render.dir/src/render/backend/websocket.cc.o
Building CXX object CMakeFiles/magent.dir/src/runtime_api.cc.o
[ 13%] Building CXX object CMakeFiles/magent.dir/src/temp_c_booster.cc.o
Building CXX object CMakeFiles/testlib.dir/src/runtime_api.cc.o
In file included from /home/shawnlue/Applications/MAgent/src/render/backend/websocket.cc:1:0:
/home/shawnlue/Applications/MAgent/src/render/backend/websocket.h:4:53: fatal error: websocketpp/config/asio_no_tls_client.hpp: 没有那个文件或目录
 #include <websocketpp/config/asio_no_tls_client.hpp>
                                                     ^
compilation terminated.
make[2]: *** [CMakeFiles/render.dir/src/render/backend/websocket.cc.o] 错误 1
make[1]: *** [CMakeFiles/render.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
[ 16%] Building CXX object CMakeFiles/testlib.dir/src/temp_c_booster.cc.o
[ 20%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/RenderGenerator.cc.o
[ 23%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o
/home/shawnlue/Applications/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
     #pragma omp declare reduction (merge : std::vector<RenderAttackEvent> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
 ^
[ 26%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/Map.cc.o
[ 30%] Building CXX object CMakeFiles/magent.dir/src/gridworld/RenderGenerator.cc.o
/home/shawnlue/Applications/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int*)’:
/home/shawnlue/Applications/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
     #pragma omp parallel for reduction(merge: render_attack_buffer)
                                        ^
make[2]: *** [CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o] 错误 1
make[2]: *** 正在等待未完成的任务....
[ 33%] Building CXX object CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o
/home/shawnlue/Applications/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
     #pragma omp declare reduction (merge : std::vector<RenderAttackEvent> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
 ^
/home/shawnlue/Applications/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int*)’:
/home/shawnlue/Applications/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
     #pragma omp parallel for reduction(merge: render_attack_buffer)
                                        ^
[ 36%] Building CXX object CMakeFiles/magent.dir/src/gridworld/Map.cc.o
[ 40%] Building CXX object CMakeFiles/magent.dir/src/gridworld/AgentType.cc.o
make[2]: *** [CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[1]: *** [CMakeFiles/testlib.dir/all] 错误 2
make[1]: *** [CMakeFiles/magent.dir/all] 错误 2
make: *** [all] 错误 2

Hope someone can help me to fix this.

EOFError on Ubuntu 18.04

wx_camera_1552443987989
wx_camera_1552449117017
I met this error in the moring ,but i did not copy it at that time.
Here are some pictures about it.One is occured when running in the terminal , another is occored when runnning in pycharm.

How do MAgent handle collision?

Hi geek-ai:

Thank you for contributing this great work!
I want know how MAgent handle collision?
Could you provide some information about the mechanism of avoiding collision or handling the collision when it happens?

Thank you for your time!

Some questions about the action label

I have read the code and have some questions about the action label. In the doc file (get_start.md) you have provided, there are 23 different actions agents can take. However, I have no idea about how to map the action label to a specific action (left or right,1 step or 2 step,etc). I would be appreciate if you can provide more details.

Some queries about input views of agents

Hello,

We were checking the implementation of DQN in multi-agent environment (pursuit) as given in this repo. Everything seemed the same as the usual DQN, except for the input views (observations) that are being passed for each agent. What exactly do they represent and why does it have 4 dimensions ? As per my understanding in the usual DQN we only have observations with 3 dimensions.

Also, please let me know if there are any other differences compared to the single-agent DQN.

Thanks!

Can Not install websocketpp by homebrew (MacOS)

briandeMacBook-Pro:MAgent brian$ brew install --HEAD david-icracked/websocketpp/websocketpp
==> Installing websocketpp from david-icracked/websocketpp
==> Cloning git://github.com/zaphoyd/websocketpp
Updating /Users/brian/Library/Caches/Homebrew/websocketpp--git
==> Checking out branch master
Error: Calling Formula#std_cmake_parameters is disabled!
Use Formula#std_cmake_args instead.
/usr/local/Homebrew/Library/Taps/david-icracked/homebrew-websocketpp/websocketpp.rb:9:in `install'
Please report this to the david-icracked/websocketpp tap!
Or, even better, submit a PR to fix it!

Ubuntu Build error fix needed

system:
Ubuntu 16.04.3 LTS
conda 4.4.7
Python 2.7.14 :: Anaconda, Inc.
gcc (GCC) 4.8.5
libjsoncpp-dev is already the newest version (1.7.2-1).
libboost-system-dev is already the newest version (1.58.0.1ubuntu1).
libwebsocketpp-dev is already the newest version (0.7.0-5).
cmake is already the newest version (3.5.1-1ubuntu3).

(tensorflow_p27) ubuntu@ip-172-31-24-200:~/cs/MAgent$ bash build.sh 
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /home/ubuntu/anaconda3/envs/tensorflow_p27/bin/cc
-- Check for working C compiler: /home/ubuntu/anaconda3/envs/tensorflow_p27/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/ubuntu/anaconda3/envs/tensorflow_p27/bin/c++
-- Check for working CXX compiler: /home/ubuntu/anaconda3/envs/tensorflow_p27/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/cs/MAgent/build
Scanning dependencies of target magent
[  3%] Building CXX object CMakeFiles/magent.dir/src/temp_c_booster.cc.o
[  6%] Building CXX object CMakeFiles/magent.dir/src/runtime_api.cc.o
[  9%] Building CXX object CMakeFiles/magent.dir/src/gridworld/RenderGenerator.cc.o
[ 12%] Building CXX object CMakeFiles/magent.dir/src/gridworld/AgentType.cc.o
[ 15%] Building CXX object CMakeFiles/magent.dir/src/gridworld/RewardEngine.cc.o
[ 18%] Building CXX object CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
     #pragma omp declare reduction (merge : std::vector<RenderAttackEvent> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
 ^
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int*)’:
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
     #pragma omp parallel for reduction(merge: render_attack_buffer)
                                        ^
CMakeFiles/magent.dir/build.make:182: recipe for target 'CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o' failed
make[2]: *** [CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/magent.dir/all' failed
make[1]: *** [CMakeFiles/magent.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Scanning dependencies of target render
Scanning dependencies of target testlib
[  3%] Building CXX object CMakeFiles/render.dir/src/render/backend/websocket.cc.o
[  6%] Building CXX object CMakeFiles/render.dir/src/render/backend/render.cc.o
[  9%] Building CXX object CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o
[ 12%] Building CXX object CMakeFiles/testlib.dir/src/temp_c_booster.cc.o
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
     #pragma omp declare reduction (merge : std::vector<RenderAttackEvent> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
 ^
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int*)’:
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
     #pragma omp parallel for reduction(merge: render_attack_buffer)
                                        ^
CMakeFiles/magent.dir/build.make:182: recipe for target 'CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o' failed
make[2]: *** [CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/magent.dir/all' failed
make[1]: *** [CMakeFiles/magent.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 15%] Building CXX object CMakeFiles/render.dir/src/render/backend/data.cc.o
[ 18%] Building CXX object CMakeFiles/testlib.dir/src/runtime_api.cc.o
[ 21%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/RenderGenerator.cc.o
[ 24%] Building CXX object CMakeFiles/render.dir/src/render/backend/text.cc.o
[ 27%] Building CXX object CMakeFiles/render.dir/src/render/backend/utility/logger.cc.o
/home/ubuntu/cs/MAgent/src/render/backend/utility/logger.cc: In member function ‘void magent::render::Logger::log(const string&)’:
/home/ubuntu/cs/MAgent/src/render/backend/utility/logger.cc:14:20: error: ‘put_time’ is not a member of ‘std’
         ostream << std::put_time(std::localtime(&time), "[%Y-%m-%d %H:%M:%S] [")
                    ^
CMakeFiles/render.dir/build.make:158: recipe for target 'CMakeFiles/render.dir/src/render/backend/utility/logger.cc.o' failed
make[2]: *** [CMakeFiles/render.dir/src/render/backend/utility/logger.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 30%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/AgentType.cc.o
[ 33%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/RewardEngine.cc.o
[ 36%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
     #pragma omp declare reduction (merge : std::vector<RenderAttackEvent> : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
 ^
[ 39%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/test.cc.o
[ 42%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/Map.cc.o
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int*)’:
/home/ubuntu/cs/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
     #pragma omp parallel for reduction(merge: render_attack_buffer)
                                        ^
CMakeFiles/testlib.dir/build.make:182: recipe for target 'CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o' failed
make[2]: *** [CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:141: recipe for target 'CMakeFiles/testlib.dir/all' failed
make[1]: *** [CMakeFiles/testlib.dir/all] Error 2
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/render.dir/all' failed
make[1]: *** [CMakeFiles/render.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I am getting this message. How do I fix this?
I am using AWS Deep Learning AMI. So I tried in python3 and still having similar error.

Adding new actions

Hi guys, first of all I wanted to thank you for this awesome framework!

I am curious if there is a way of adding new actions for the agents, i.e. a second type of attack which has different properties and effects.

Does the built in model supports PyTorch?

I am learning how to use the magent toolkit. Below, i list some questions:

  1. It seems that PyTorch is much more friendly and efficient than tensorflow, especially in research community. does the builtin model support pytorch?

  2. How to run train_battle_game.py in my own pc without gpu despite it's expected it's time consuming to train large battle game? change map_size from 125 to 16? Actually, I only want to learn how to use this key APIs and embed this toolkit with my own project. Does any tutorial to introduce the key APIs?

socket.error: [Errno 98] Address already in use

zx@zx-MS-7A38:~/project/zx/MAgent$ python examples/train_pursuit.py
Traceback (most recent call last):
File "examples/train_pursuit.py", line 133, in
target_update=1000, train_freq=4
File "/home/zx/project/zx/MAgent/python/magent/model.py", line 153, in init
listener = multiprocessing.connection.Listener(addr)
File "/home/zx/anaconda2/lib/python2.7/multiprocessing/connection.py", line 132, in init
self._listener = SocketListener(address, family, backlog)
File "/home/zx/anaconda2/lib/python2.7/multiprocessing/connection.py", line 256, in init
self._socket.bind(address)
File "/home/zx/anaconda2/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
2017-12-12 21:01:39.301346: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Process Process-1:
Traceback (most recent call last):
File "/home/zx/anaconda2/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
self.run()
File "/home/zx/anaconda2/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/zx/project/zx/MAgent/python/magent/model.py", line 297, in model_client
conn = multiprocessing.connection.Client(addr)
File "/home/zx/anaconda2/lib/python2.7/multiprocessing/connection.py", line 169, in Client
c = SocketClient(address)
File "/home/zx/anaconda2/lib/python2.7/multiprocessing/connection.py", line 308, in SocketClient
s.connect(address)
File "/home/zx/anaconda2/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused

error of build.sh-what happened?

bash build.sh
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /home/laker/anaconda3/bin/cc
-- Check for working C compiler: /home/laker/anaconda3/bin/cc -- works
-- Detecting C compiler ABI info
-- Checking if C linker supports --verbose
-- Checking if C linker supports --verbose - yes
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/laker/anaconda3/bin/c++
-- Check for working CXX compiler: /home/laker/anaconda3/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Checking if CXX linker supports --verbose
-- Checking if CXX linker supports --verbose - yes
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/laker/MAgent/build
Scanning dependencies of target testlib
Scanning dependencies of target render
Scanning dependencies of target magent
[ 6%] Building CXX object CMakeFiles/render.dir/src/render/backend/render.cc.o
[ 9%] Building CXX object CMakeFiles/render.dir/src/render/backend/text.cc.o
[ 6%] Building CXX object CMakeFiles/render.dir/src/render/backend/data.cc.o
[ 12%] Building CXX object CMakeFiles/render.dir/src/render/backend/websocket.cc.o
[ 15%] Building CXX object CMakeFiles/render.dir/src/render/backend/utility/config.cc.o
[ 18%] Building CXX object CMakeFiles/testlib.dir/src/runtime_api.cc.o
[ 21%] Building CXX object CMakeFiles/render.dir/src/render/backend/utility/logger.cc.o
[ 24%] Building CXX object CMakeFiles/magent.dir/src/runtime_api.cc.o
[ 27%] Building CXX object CMakeFiles/magent.dir/src/temp_c_booster.cc.o
/home/laker/MAgent/src/render/backend/utility/logger.cc: In member function ‘void magent::render::Logger::log(const string&)’:
/home/laker/MAgent/src/render/backend/utility/logger.cc:14:20: error: ‘put_time’ is not a member of ‘std’
ostream << std::put_time(std::localtime(&time), "[%Y-%m-%d %H:%M:%S] [")
^
CMakeFiles/render.dir/build.make:182: recipe for target 'CMakeFiles/render.dir/src/render/backend/utility/logger.cc.o' failed
make[2]: *** [CMakeFiles/render.dir/src/render/backend/utility/logger.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 30%] Building CXX object CMakeFiles/magent.dir/src/gridworld/AgentType.cc.o
[ 33%] Building CXX object CMakeFiles/testlib.dir/src/temp_c_booster.cc.o
[ 36%] Building CXX object CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o
/home/laker/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
#pragma omp declare reduction (merge : std::vector : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
^
[ 39%] Building CXX object CMakeFiles/magent.dir/src/gridworld/Map.cc.o
[ 42%] Building CXX object CMakeFiles/magent.dir/src/gridworld/RenderGenerator.cc.o
[ 45%] Building CXX object CMakeFiles/magent.dir/src/gridworld/RewardEngine.cc.o
/home/laker/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int*)’:
/home/laker/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
#pragma omp parallel for reduction(merge: render_attack_buffer)
^
CMakeFiles/magent.dir/build.make:134: recipe for target 'CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o' failed
make[2]: *** [CMakeFiles/magent.dir/src/gridworld/GridWorld.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 48%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/AgentType.cc.o
[ 51%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o
[ 54%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/Map.cc.o
/home/laker/MAgent/src/gridworld/GridWorld.cc:456:0: warning: ignoring #pragma omp declare [-Wunknown-pragmas]
#pragma omp declare reduction (merge : std::vector : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
^
[ 57%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/RenderGenerator.cc.o
/home/laker/MAgent/src/gridworld/GridWorld.cc: In member function ‘virtual void magent::gridworld::GridWorld::step(int
)’:
/home/laker/MAgent/src/gridworld/GridWorld.cc:474:40: error: expected ‘+’, ‘*’, ‘-’, ‘&’, ‘^’, ‘|’, ‘&&’, ‘||’, ‘min’ or ‘max’ before ‘merge’
#pragma omp parallel for reduction(merge: render_attack_buffer)
^
[ 60%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/RewardEngine.cc.o
[ 63%] Building CXX object CMakeFiles/testlib.dir/src/gridworld/test.cc.o
CMakeFiles/testlib.dir/build.make:134: recipe for target 'CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o' failed
make[2]: *** [CMakeFiles/testlib.dir/src/gridworld/GridWorld.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/magent.dir/all' failed
make[1]: *** [CMakeFiles/magent.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/testlib.dir/all' failed
make[1]: *** [CMakeFiles/testlib.dir/all] Error 2
CMakeFiles/Makefile2:141: recipe for target 'CMakeFiles/render.dir/all' failed
make[1]: *** [CMakeFiles/render.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Invalid handle of the map data file

When I typed in config.json and video_100.txt, it says
magent::render::RenderException "Invalid handle of the map data file"
the file video_100.txt is in the directory build/render
Any ideas what may the problem be?

What the turn action means?

Actions are discrete actions. They can be move, attack and turn.
The move and attack action can be comprehend easily.
However, what does turn means?
I check the frames in render. I found the turn action correspond half-line. So I am confused with the turn action.
Hope for your reply.

more details about the observation

I consider the information provided in the doc about the observation of agents may be not sufficient enough. I wander what the group 2 or group 2 minimap stands for in the spatial observation. Besides, how many numbers the embedding ID in the non-spatial observation takes up in the sequence(【ID embedding, last action, last reward and normalized position】)? I consider these will be helpful for me to better understand the game. Thank you.

Can't run it in Linux

I used Ubuntu 14.02 and Anaconda with Python 3.5.2 to run this project. I downloaded this repository and run these commands:

cd MAgent
sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev
bash build.sh
export PYTHONPATH=$(pwd)/python:$PYTHONPATH

But there raised some errors and I couldn't install the python package successfully. So I copied the file "Magent" to my python project and used pycharm to mark the "Python" file in it as the Sources Root. When I run the file "api_demo.py", it showed some error massages:

/home/sean/anaconda3/bin/python3.6 /home/sean/DRL/MAgent/examples/train_pursuit.py
Traceback (most recent call last):
File "/home/sean/DRL/MAgent/examples/train_pursuit.py", line 11, in
import magent
File "/home/sean/DRL/MAgent/python/magent/init.py", line 2, in
from . import utility
File "/home/sean/DRL/MAgent/python/magent/utility.py", line 12, in
from magent.builtin.rule_model import RandomActor
File "/home/sean/DRL/MAgent/python/magent/builtin/rule_model/init.py", line 2, in
from .rush import RushPredator
File "/home/sean/DRL/MAgent/python/magent/builtin/rule_model/rush.py", line 7, in
from magent.c_lib import _LIB, as_int32_c_array, as_float_c_array
File "/home/sean/DRL/MAgent/python/magent/c_lib.py", line 42, in
_LIB = _load_lib()
File "/home/sean/DRL/MAgent/python/magent/c_lib.py", line 21, in _load_lib
lib = ctypes.CDLL(path_to_so_file, ctypes.RTLD_GLOBAL)
File "/home/sean/anaconda3/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: /home/sean/DRL/MAgent/python/magent/../../build/libmagent.so: cannot open shared object file: No such file or directory

Process finished with exit code 1

It seems that my file miss some resources. But I use files completely copied from git. Maybe I missed some steps. I need some help to use the repository. o_o

Mode that agents cannot penetrate each other?

Is there any support for environments where agents cannot go through each other?

For example,
in the following scenario, even if agent a has a moving speed of 2, it still cannot move away.

 b
bab
 b

ubutun16.04安装问题

是不是每次开机后再运行都需要重新安装或source一下?因为第一个例子跑过之后,第二个就会提示无法找到“”magent”

Compatibility problem with Python3

examples/show_arrange.py can not run in Python3.5 and Python3.6 on Ubuntu 16.04:
Traceback (most recent call last):
File "examples/show_arrange.py", line 22, in
PyGameRenderer().start(Server(messages=args.mess, mode=args.mode), grid_size=3.5)
File "/data/Work/MAgent/python/magent/renderer/server/arrange_server.py", line 345, in init
generate_map(mode, env, map_size, food_handle, handles, messages, font)
File "/data/Work/MAgent/python/magent/renderer/server/arrange_server.py", line 282, in generate_map
draw(base_x, base_y, scale, data)
File "/data/Work/MAgent/python/magent/renderer/server/arrange_server.py", line 270, in draw
for x in range(start_x, start_x + scale):
TypeError: 'float' object cannot be interpreted as an integer.

Python2.7 is OK.

MemoryError raised during training train_pursuit.py

I got a MemroyError when I run the example script train_pursuit.py. The traceback is copied as follow,

Process Process-1:
Traceback (most recent call last):
  File "/home/dl/.pyenv/versions/2.7.12/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/home/dl/.pyenv/versions/2.7.12/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/home/dl/Downloads/MAgent-master/python/magent/model.py", line 294, in model_client
    model = RLModel(**model_args)
  File "/home/dl/Downloads/MAgent-master/python/magent/builtin/tf_model/dqn.py", line 143, in __init__
    self.replay_buf_view     = ReplayBuffer(shape=(memory_size,) + self.view_space)
  File "/home/dl/Downloads/MAgent-master/python/magent/builtin/common.py", line 9, in __init__
    self.buffer = np.empty(shape=shape, dtype=dtype)
MemoryError

Quick fix for mac bash build.sh error (library not found for -lboost_system)

I was getting this error even though I installed boost library properly through both brew and macports.

| => bash build.sh 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/donghun/cs/MAgent/build
[ 75%] Built target testlib
[ 78%] Built target magent
[ 81%] Linking CXX executable render/render
ld: library not found for -lboost_system
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [render/render] Error 1
make[1]: *** [CMakeFiles/render.dir/all] Error 2
make: *** [all] Error 2

First, check if you properly installed boost
ls /usr/local/lib | grep --color boost_system
results:

libboost_system-mt.a
libboost_system-mt.dylib

Fix:
Change boost_system library to boost_system-mt (multi thread)

vi build/CMakeFiles/render.dir/link.txt
change boost_system to boost_system-mt in 2 places

and the build works.

how to use 'parameter-sharing DQN' in my own task?

Thanks for your brilliant code.

I want to know how can I use the RL algorithm in my onw task? For example , If I have my own environment to provide reward and many agents, how can I use your RL code to train on my dataset? In other words, I just want to know what is 'parameter-sharing DQN' and which part of the code I can use to train my own dataset?

MAgent on Windows

Hi , is it possible to compile / install MAgent on Windows 10?

Best regard / Rock

Why the agents have learned nothing?

I have run the code (train battle) and watch the video. However, I found the agents have learned nothing. Why this happens?Do I need to prolong the training process?

ImportError: No module named 'base_renderer'

run show_battle_game.py error

Traceback (most recent call last):
  File "examples/show_battle_game.py", line 9, in <module>
    from magent.renderer import PyGameRenderer
  File "/home/minghigh/Desktop/MAgent/python/magent/renderer/__init__.py", line 1, in <module>
    from base_renderer import BaseRenderer
ImportError: No module named 'base_renderer'

my PYTHONPATH is okey.

screenshot from 2017-12-06 15-46-57

Cannot Run On Ubuntu18

$python examples/train_pursuit.py --train
Traceback (most recent call last):
File "examples/train_pursuit.py", line 11, in
import magent
ModuleNotFoundError: No module named 'magent'

laha@laha-unbutun:$ uname -a
Linux laha-unbutun 4.18.0-12-generic #13-Ubuntu SMP Wed Nov 14 15:17:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
laha@laha-unbutun:$ g++ --version
g++ (Ubuntu 8.2.0-7ubuntu1) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

laha@laha-unbutun:~$ cmake --version
cmake version 3.12.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

can't watch videos

Thanks for your brilliant code.
When I open index.html in browser.The page show: magent : :render::RenderException: "invalid handle of the map configuration file",and didn't show videos.I want to know the reason.

No module named pygame

File "examples/show_battle_game.py", line 9, in
from magent.renderer import PyGameRenderer
File "/Users/lanjiedediannao/MAgent/python/magent/renderer/init.py", line 2, in
from .pygame_renderer import PyGameRenderer
File "/Users/lanjiedediannao/MAgent/python/magent/renderer/pygame_renderer.py", line 6, in
import pygame
ImportError: No module named pygame
安装的过程没有报错,可是在执行show_battle_game的时候出现了这个错误,希望得到解答

Questions about the Observation

Spatial view consists of several rectangular channels, Walls, group 1, group 1's hp, group 1's minimap, group 2, group 2's hp, group 2's minimap. I have following questions:

  1. What's the meaning of hp?
  2. What are included in the minimap? It contains the walls?
  3. All these values should be o or 1. However, when I print some observation (Spatial view) out, it has other values like 1.667. I am very confused.

I really appreciate that if you can replay to it at your appropriate time.

TypeError: Argument must be rect style object

(I already run show_battle_game.py successfully with python2)

python3 examples/show_battle_game.py

error as follows

Traceback (most recent call last):
  File "examples/show_battle_game.py", line 15, in <module>
    PyGameRenderer().start(Server())
  File "/home/minghigh/Desktop/MAgent/python/magent/renderer/pygame_renderer.py", line 281, in start
    now_group[1] * grid_size
  File "/home/minghigh/Desktop/MAgent/python/magent/renderer/pygame_renderer.py", line 52, in draw_rect
    map(int, (round(a[0]), round(a[1]), round(w + a[0] - round(a[0])), round(h + a[1] - round(a[1]))))
TypeError: Argument must be rect style object

Not able to render after train_multi

After running train_multi.py, I cannot render the environment.
After typing config.json and video_*.txt generated by the command
python3 examples/train_multi.py into the input boxes,
It says invalid map file data.

is there something wrong?

python examples/train_pursuit.py --train

libgomp: Invalid value for environment variable OMP_NUM_THREADS
Traceback (most recent call last):
File "examples/train_pursuit.py", line 133, in
target_update=1000, train_freq=4
File "/home/hello/magent/python/magent/model.py", line 153, in init
listener = multiprocessing.connection.Listener(addr)
File "/usr/lib/python2.7/multiprocessing/connection.py", line 132, in init
self._listener = SocketListener(address, family, backlog)
File "/usr/lib/python2.7/multiprocessing/connection.py", line 256, in init
self._socket.bind(address)
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/hello/magent/python/magent/model.py", line 294, in model_client
model = RLModel(**model_args)
File "/home/hello/magent/python/magent/builtin/tf_model/dqn.py", line 94, in init
self.qvalues = self._create_network(self.input_view, self.input_feature, use_conv)
File "/home/hello/magent/python/magent/builtin/tf_model/dqn.py", line 164, in _create_network
h_conv1 = tf.layers.conv2d(input_view, filters=kernel_num[0], kernel_size=3,
AttributeError: 'module' object has no attribute 'layers'

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.