# light_mappo
Lightweight version of MAPPO to help you quickly migrate to your local environment.
- [Video (in Chinese)](https://www.bilibili.com/video/BV1bd4y1L73N)
This is a translated English version. Please click [here](README_CN.md) for the orginal Chinese readme.
## Table of Contents
- [Background](#Background)
- [Installation](#Installation)
- [Usage](#Usage)
## Background
The original MAPPO code was too complex in terms of environment encapsulation, so this project directly extracts and encapsulates the environment. This makes it easier to transfer the MAPPO code to your own project.
## Installation
Simply download the code, create a Conda environment, and then run the code, adding packages as needed. Specific packages will be added later.
## Usage
- The environment part is an empty implementation, and the implementation of the environment part in the light_mappo/envs/env_core.py file is: [Code] (https://github.com/tinyzqh/light_mappo/blob/main/envs/env_core.py)
```python
import numpy as np
class EnvCore(object):
"""
# Environment Agent
"""
def __init__(self):
self.agent_num = 2 # set the number of agents(aircrafts), here set to two
self.obs_dim = 14 # set the observation dimension of agents
self.action_dim = 5 # set the action dimension of agents, here set to a five-dimensional
def reset(self):
"""
# When self.agent_num is set to 2 agents, the return value is a list, and each list contains observation data of shape = (self.obs_dim,)
"""
sub_agent_obs = []
for i in range(self.agent_num):
sub_obs = np.random.random(size=(14, ))
sub_agent_obs.append(sub_obs)
return sub_agent_obs
def step(self, actions):
"""
# When self.agent_num is set to 2 agents, the input of actions is a two-dimensional list, and each list contains action data of shape = (self.action_dim,).
# By default, the input is a list containing two elements, because the action dimension is 5, so each element has a shape of (5,)
"""
sub_agent_obs = []
sub_agent_reward = []
sub_agent_done = []
sub_agent_info = []
for i in range(self.agent_num):
sub_agent_obs.append(np.random.random(size=(14,)))
sub_agent_reward.append([np.random.rand()])
sub_agent_done.append(False)
sub_agent_info.append({})
return [sub_agent_obs, sub_agent_reward, sub_agent_done, sub_agent_info]
```
Just write this part of the code, and you can seamlessly connect with MAPPO. After env_core.py, two files, env_discrete.py and env_continuous.py, were separately extracted to encapsulate the action space and discrete action space. In elif self.continuous_action: in algorithms/utils/act.py, this judgment logic is also used to handle continuous action spaces. The # TODO here in runner/shared/env_runner.py is also used to handle continuous action spaces.
In the train.py file, choose to comment out continuous environment or discrete environment to switch the demo environment.
## Related Efforts
- [on-policy](https://github.com/marlbenchmark/on-policy) - 馃拰 Learn the author implementation of MAPPO.
## Maintainers
[@tinyzqh](https://github.com/tinyzqh).
## Translator
[@tianyu-z](https://github.com/tianyu-z)
## License
[MIT](LICENSE) 漏 tinyzqh
没有合适的资源?快使用搜索试试~ 我知道了~
mappo-combat
共144个文件
pyc:66个
py:58个
desktop-63olaia:8个
需积分: 1 0 下载量 117 浏览量
2024-05-07
11:09:20
上传
评论
收藏 492KB ZIP 举报
温馨提示
mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗 mappo--combat env mappo算法做多智能体对抗
资源推荐
资源详情
资源评论
收起资源包目录
mappo-combat (144个子文件)
events.out.tfevents.1714463749.DESKTOP-63OLAIA 164B
events.out.tfevents.1714463749.DESKTOP-63OLAIA 150B
events.out.tfevents.1714463749.DESKTOP-63OLAIA 148B
events.out.tfevents.1714463749.DESKTOP-63OLAIA 142B
events.out.tfevents.1714463749.DESKTOP-63OLAIA 140B
events.out.tfevents.1714463749.DESKTOP-63OLAIA 138B
events.out.tfevents.1714463749.DESKTOP-63OLAIA 128B
events.out.tfevents.1714462157.DESKTOP-63OLAIA 0B
.gitignore 50B
.gitignore 16B
light_mappo-main.iml 500B
README.md 3KB
README_CN.md 3KB
critic.pt 194KB
actor.pt 80KB
shared_buffer.py 27KB
separated_buffer.py 21KB
combat.py 20KB
config.py 17KB
env_runner.py 16KB
lumberjacks.py 16KB
predator_prey.py 15KB
env_runner.py 14KB
checkers.py 11KB
pong_duel.py 11KB
r_mappo.py 10KB
act.py 9KB
r_actor_critic.py 8KB
switch_one_corridor.py 7KB
rMAPPOPolicy.py 7KB
base_runner.py 7KB
traffic_junction.py 6KB
base_runner.py 6KB
eval.py 6KB
train.py 6KB
env_discrete.py 5KB
monitor.py 5KB
render_mpe.py 4KB
draw.py 4KB
popart.py 4KB
distributions.py 3KB
__init__.py 3KB
valuenorm.py 3KB
rnn.py 3KB
env_core.py 3KB
env_continuous.py 3KB
util.py 2KB
mlp.py 2KB
env_wrappers.py 2KB
cnn.py 2KB
__init__.py 2KB
observation_space.py 773B
action_space.py 509B
util.py 425B
stats_recorder.py 311B
__init__.py 187B
__init__.py 132B
__init__.py 90B
__init__.py 46B
__init__.py 43B
__init__.py 40B
__init__.py 39B
__init__.py 37B
__init__.py 31B
__init__.py 30B
__init__.py 27B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
__init__.py 0B
combat.cpython-37.pyc 17KB
combat.cpython-39.pyc 17KB
shared_buffer.cpython-37.pyc 15KB
config.cpython-39.pyc 13KB
config.cpython-37.pyc 13KB
separated_buffer.cpython-37.pyc 11KB
separated_buffer.cpython-39.pyc 10KB
env_runner.cpython-37.pyc 8KB
env_runner.cpython-39.pyc 8KB
r_actor_critic.cpython-39.pyc 7KB
r_actor_critic.cpython-37.pyc 7KB
env_runner.cpython-37.pyc 7KB
r_mappo.cpython-39.pyc 7KB
r_mappo.cpython-37.pyc 7KB
rMAPPOPolicy.cpython-39.pyc 6KB
rMAPPOPolicy.cpython-37.pyc 6KB
env_discrete.cpython-39.pyc 6KB
distributions.cpython-37.pyc 6KB
env_discrete.cpython-37.pyc 6KB
distributions.cpython-39.pyc 5KB
act.cpython-37.pyc 5KB
act.cpython-39.pyc 5KB
base_runner.cpython-37.pyc 5KB
base_runner.cpython-37.pyc 5KB
base_runner.cpython-39.pyc 5KB
draw.cpython-37.pyc 4KB
draw.cpython-39.pyc 4KB
共 144 条
- 1
- 2
资源评论
BIT龙超越
- 粉丝: 120
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功