Code Monkey home page Code Monkey logo

maca's Introduction

MaCA

Multi-agent Combat Arena (MaCA) is a heterogeneous multi-agent distributed decision and control technology reasearch platform produced by CETC-TFAI team. It focuses on the application of AI technologies e.g. reinforcement learning in multi-agent cooperation and confrontation

System Requirements

  • Linux 64-bit or Mac OS with Python 3.6
  • numpy 1.14.2 or later
  • pygame 1.9.3 or later

There is no limitation on agents' structure. You can write rule-based algorithms or use deep learning frameworks.

Quick Start Guide

Installation

pip install -U numpy pandas pygame
git clone https://github.com/CETC-TFAI/MaCA.git
cd MaCA
export PYTHONPATH=$(pwd)/environment:$PYTHONPATH

Run a combat between two agents

fight_mp.py can execute two agents. It uses two instances of a fixed-rule agent to fight each other by default.

python fight_mp.py

You can specify agents and map by input arguments. In addition an agent should provide a call interface follows the MaCa platform specification.

Replay

MaCa can record runtime log while playing and training. Use replay.py to perform a replay.

First, run fight_mp.py and enable log record function

python fight_mp.py --log

Then, run replay.py to replay the log

python replay.py fix_rule_vs_fix_rule

The log structure of MaCA is a set of .macalog files, they will be saved in path "log/log-name/". When you run the replay.py, You must input a "log-name" as the parameter to specify which log you want to replay.

For more information, see tutorial

maca's People

Contributors

cetc-tfai avatar leonfg 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

maca's Issues

能否支持下更高版本的python,比如3.8

在Python 3.8,Pygame 1.9.6 下运行会报错:
Traceback (most recent call last):
File "D:/RL/MaCA/fight_mp.py", line 14, in
from interface import Environment
File "D:\RL\MaCA\environment\interface.py", line 15, in
from world.em_battle import BattleField
File "D:\RL\MaCA\environment\world_init_.py", line 1, in
pyarmor(name, file, b'\xec\x50\x8c\x64\x26\x42\xd6\x01\x10\x54\xca\x9c\xb6\x33\x81\x05\x30\xdb\x46\xb3\x6d\x0c\xa2\x2d\x19\xe2\x8f\xf9\x44\x25\xd5\x53\xc7\x67\x06\x76\x71\x8d\x42\xe2\xc3\xef\x00\x16\xa3\x91\x11\x67\x09\x92\x9a\x72\x18\xf6\x31\xbd\x95\x78\x69\xe0\x84\xc1\x30\x40\x93\x62\xc4\x8e\xd6\xf0\x0d\x5b\x82\x29\x55\x63\xd9\x3e\x7a\x4e\x40\xcb\xae\x0e\x9d\x45\x72\xa4\x22\x50\xc5\x00\x06\x2d\x29\xe5\xe1\x5f\xa6\xee\x04\xfd\x9f\xc1\x10\xe5\xd5\x07\xef\xb6\xee\x36\xcc\x39\x5c\xa0\xab\x6f\x6e\x9e\xb6\xf5\x42\x3f\x41\xeb\x1b\x0a\x07\xbe\x67\x3e\x0f\x8f\xe7\x61\x8a\xcf\x9b\xa3\x22\x07\xb0\x4c\xc0\x53\x6f\xf9\x0c\x1c\x61\xfa\xa0\x28\xa4', 1)
MemoryError
涉及加密代码,没法自行更改。
注:在Python 3.6,Pygame 1.9.6 测试没有问题。

请问能否提供有一定效果的RL训练trick?

我在环境中尝试了fighter10v10与fighter5v5,使用了simple dqn算法与自己编写的ippo算法与fix rule agent进行对抗,实际动作空间仅选取了航向和攻击,并且我降低了航向的个数,但效果都很差。
能否提供一些RL训练的trick?雷达开关频点动作是否对结果有很大的影响呢(是否是因为雷达频点固定为1而导致无法探测到敌方?)?是否需要添加更多非稀疏奖励来引导agent学习?

希望能得到回答,谢谢

可视化在哪

您好,目前在学习这个程序,能跑,只是可视化渲染一直出不来,是哪个代码块需要修改吗?mac,感谢

pytransform.PytransformError

你好,我将“environment/”文件夹设置为“Sources Root”,也把fight_mp.py的“Working Directory”设置为MaCA根目录了,但是运行的时候报错。请问这是什么原因?

Traceback (most recent call last):
File "E:/MaCA-master/fight.py", line 15, in
from interface import Environment
File "E:\MaCA-master\environment\interface.py", line 4, in
pyarmor_runtime()
File "E:\MaCA-master\environment\pytransform.py", line 274, in pyarmor_runtime
pyarmor_init(path)
File "E:\MaCA-master\environment\pytransform.py", line 271, in pyarmor_init
init_pytransform()
File "E:\MaCA-master\environment\pytransform.py", line 72, in wrap
raise PytransformError(format_message(errmsg, *args, **kwargs))
pytransform.PytransformError: b"\nOpen pyshield license file 'E:\\xe9\xa1\xb9\xe7\x9b\xae\\xe6\x99\xba\xe8\x84\x91\MaCA-master\environment\pyshield.lic'\nNo such file or directory\nInitialize license key failed\nInitialize pytransform failed"

Process finished with exit code 1

from world.em_battle import BattleField File "C:\Users\panqiufeng\MaCA\environment\world\__init__.py", line 2, in <module> __pyarmor__(__name__, __file__, b'\xec\x50\x8c\x64\x26\x42\xd6\x01\x10\x54\xca\x9c\xb6\x33\x81\x05\x30\xdb\x46\xb3\x6d\x0c\xa2\x2d\x19\xe2\x8f\xf9\x44\x25\xd5\x53\xc7\x67\x06\x76\x71\x8d\x42\xe2\xc3\xef\x00\x16\xa3\x91\x11\x67\x09\x92\x9a\x72\x18\xf6\x31\xbd\x95\x78\x69\xe0\x84\xc1\x30\x40\x93\x62\xc4\x8e\xd6\xf0\x0d\x5b\x82\x29\x55\x63\xd9\x3e\x7a\x4e\x40\xcb\xae\x0e\x9d\x45\x72\xa4\x22\x50\xc5\x00\x06\x2d\x29\xe5\xe1\x5f\xa6\xee\x04\xfd\x9f\xc1\x10\xe5\xd5\x07\xef\xb6\xee\x36\xcc\x39\x5c\xa0\xab\x6f\x6e\x9e\xb6\xf5\x42\x3f\x41\xeb\x1b\x0a\x07\xbe\x67\x3e\x0f\x8f\xe7\x61\x8a\xcf\x9b\xa3\x22\x07\xb0\x4c\xc0\x53\x6f\xf9\x0c\x1c\x61\xfa\xa0\x28\xa4', 1) MemoryError

SystemError: unknown opcode

你好,我在运行程序时回出现这样的错误,,请问您这边知道如何处理吗

XXX lineno: 41, opcode: 160
Traceback (most recent call last):
File "/home/simsimi/MaCA/fight.py", line 77, in
random_pos=args.random_pos, log=log_flag)
File "/home/simsimi/MaCA/environment/interface.py", line 44, in init
self.map = Map(map_path)
File "", line 41, in init
SystemError: unknown opcode

Inference GPU-trained model On CPU raise error

Hi there
I was able to train a model on GPU
And the model was fine when inference on GPU
image

But my GPU server does not have display access so I wanted to show the demo on my local CPU, but when I ran the code I met this problem
image

And as you know the files under environment are all encrypted so I have no idea what when wrong, can you shed some lights on me ? Thanks A lot !!!!!

类似的环境问题请教

您好,我自学RL有一段时间了,因为对海战感兴趣,一直想把RL应用在海战上,但是gym上没有合适的环境,一直想自己写一个,但是又无从下手,看了您的这个项目虽有所启发,但您的项目有些复杂,我还是有太多不理解的地方,不知您是否有时间指导一下呢?我前期想写一个一条舰艇防导弹攻击的场景,算法方面看的资料也不少了,就是环境这块不知该怎么搞。我现在在研究您的environment,如果您有时间指导学生一下那万分感谢了。

ModuleNotFoundError: No module named 'numpy'

Traceback (most recent call last):
File "E:/code/github/MaCA/fight_mp.py", line 14, in
from interface import Environment
File "E:\code\github\MaCA\environment\interface.py", line 15, in
from world.em_battle import BattleField
File "E:\code\github\MaCA\environment\world\em_battle.py", line 1, in
pyarmor(name, file, b'...', 1)
File "", line 27, in
File "E:\code\github\MaCA\environment\world\position_calc.py", line 1, in
pyarmor(name, file, '...', 1)
File "", line 26, in
ModuleNotFoundError: No module named 'numpy'

提示 license failed,怎么解决

Traceback (most recent call last):
File "Y:/demo/MaCA/fight_mp.py", line 14, in
from interface import Environment
File "Y:\demo\MaCA\environment\interface.py", line 4, in
pyarmor_runtime()
File "Y:\demo\MaCA\environment\pytransform.py", line 274, in pyarmor_runtime
pyarmor_init(path)
File "Y:\demo\MaCA\environment\pytransform.py", line 271, in pyarmor_init
init_pytransform()
File "Y:\demo\MaCA\environment\pytransform.py", line 72, in wrap
raise PytransformError(format_message(errmsg, *args, **kwargs))
pytransform.PytransformError: b'License is expired\nCheck license failed\nInitialize pytransform failed'

Cannot load objects from other files

Hi, I am using python 3.6.3 (in pyenv and venv) on Ubuntu 18.04 LTS in terminal. The fight_mp works fine, but when I run fight.py --map=1000_1000_fighter10v10 --agent1 fix_rule --agent2 simple --log --log_path default_log I get the 'Error: agent simple model data not exist!' error. I tried to run main.py from train folder first, but I get 'ModuleNotFoundError: No module named 'agent'' error. Generally when I try to run files, it seems like it can't load objects from other files. I tried adding files'
path to the python path, but it didn't work.
I would like to ask you if you have any solution to this problem and also if you could clarify the order that i should run the files (for training and running the DQN case.) Thank you very much in advance.
errors

好像是pyarmor的加密的部分出现的问题?求助!

D:\Conda\envs\fly\python.exe D:/pycharm_workplace/MaCA-master/train/simple/main.py
pygame 2.0.1 (SDL 2.0.14, Python 3.6.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "D:/pycharm_workplace/MaCA-master/train/simple/main.py", line 45, in
env = Environment(MAP_PATH, red_agent_obs_ind, blue_agent_obs_ind, render=RENDER)
File "D:\pycharm_workplace\MaCA-master\environment\interface.py", line 53, in init
side2_name=side2_name)
File "", line 128, in init
File "", line 29, in init
FileNotFoundError: No such file or directory.

Process finished with exit code 1
在运行main.py的时候出现了这个问题,感觉是加密的模块读取失误?想请您帮忙看看
另外,想请问license什么时候过期,我想在毕设的时候引用一下贵司的平台,担心到时候license过期了…

list out of range

用系统自带的main和dqn函数训练时,训练到一定阶段当我方有战机损失时,程序报错,list out of range,是怎么回事

not enough memory

已经按照要求配置了需要的环境,但是在运行示例的main.py时报内存错误,试了8G和16G内存的电脑,都不行,是pytorch版本的问题?

RuntimeError: $ Torch: not enough memory: you tried to allocate 3GB. Buy new RAM! at ..\aten\src\TH\THGeneral.cpp:201

您好 请问一下运行train中main的问题

根目录更改成了environment 并且main的working directory也改成了maca的根目录 但是一直出现报ModuleNotFoundError: No module named 'agent'
请问是怎么回事 有解决方案吗

可以自己建地图吗?

不知道是什么原因,windows 10 下不能完全看到整张地图,因此我想在一个更小的地图上进行训练。但是新建了新的地图图片以及.map文件,并在main里修改了map-path,提示找不到.map文件,我想是不是因为无法对environment里的loadmap进行修改造成的错误。
所以我想知道是否有可能重建地图,或者在win10上看到地图全部?
第二就是除了核心模型外,是不是科技将地图以及其他可扩展的功能开放?让我们可以根据需要自己修改,我认为这是一个比较好的开源平台,如果只是局限在比赛的内容上就有些局限了。还是期待您可以开源一个类似的完全开放的平台。

实际功能与文档描述不符

文档描述每一个fighter的striking_list是一个元素为字典的列表,实际代码中是元素为int型的列表。
striking_list
打击列表[{'attacker_id': 攻击者编号, 'target_id': 目标编号, 'missile_type':导弹类型(1:远程, 2:中程), information_source_type: 信息来源类型(0: L 探测单元, 1:S 探测单元, 2:战机, 3:被动侦测) step_count:step 计数, op_count: 观测点计数, del_ind: 删除指示(默认 false)}]

实际输出是:[3,3]

side1_obs_dict

屏幕截图 2022-01-13 175242
您好,可以告知观测数据字典中的 'info' 和 'screen'分别指的是什么吗?

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.