OpenDILab Multi-Agent Environment

Overview

Go-Bigger: Multi-Agent Decision Intelligence Environment

PyPI Anaconda-Server Badge Read the Docs Read the Docs unit_test codecov

GoBigger Doc (中文版)

Ongoing

  • 2021.11.13 We are holding a competition —— Go-Bigger: Multi-Agent Decision Intelligence Environment. Come and make your agents in the game!

GoBigger is a simple and efficient agar-like game engine and provides various interfaces for game AI development. The game is similar to Agar, which is a massively multiplayer online action game created by Brazilian developer Matheus Valadares. In GoBigger, players control one or more circular balls in a map. The goal is to gain as much size as possible by eating food balls and other balls smaller than the player's balls while avoiding larger ones which can eat the player's balls. Each player starts with one ball, but players can split a ball into two when it reaches a sufficient size, allowing them to control multiple balls.

Introduction

GoBigger allows users to interact with the multi-agent environment easily within the basic rules. Through the given interface, users can simply get the observation in game and apply their operations for their agents.

Basic Rules

In order to understand the rules in the game, GoBigger provides a few concepts as following:

  • Match: GoBigger will allow serveral agents (4 by default) to join in a match. There are many different units in a match, such as food balls, thorns balls, spore balls and player balls. Each agent should gain more size by eating other balls to get a higher rank when this match ends.
  • Agent: Each agent control a team including serveral players (3 by default). Teamwork is important for a agent to play against other agents.
  • Player: Each player starts with one ball. In order to improve the operability of the game, GoBigger provides serveral operation for a player ball, including split, eject and stop.
  • Ball: GoBigger provides 4 kinds of balls in a match.
    • Food Ball: Food balls are the neutral resources in the game. If a player ball eat a food ball, the food ball’s size will be parsed to the player ball.
    • Thorn Ball: If a player ball eat a thorns ball, the thorns ball’s size will be parsed to the player ball. But at the same time, the player ball will explode and will be splited into several pieces (10 by default).
    • Spore Ball: Spore balls are ejected by the player balls.
    • Player Ball: Player balls are the balls you can control in the game. You can change its moving direction. In addition, it can eat other balls smaller than itself by covering others’ center.

For more details, please refer to what-is-gobigger.

Observation Space

GoBigger also provide a wealth of observable information, and the observation space can be devided into two part. Here is the brief description of the observation space. For more details, please refer to observation-space.

Global State

Global state provides information related to the whole match, such as the map size, the total time and the last time of the match, and the leaderboard within team name and score.

Player State

Player state should be like:

{
    player_name: {
        'feature_layers': list(numpy.ndarray), # features of player
        'rectangle': [left_top_x, left_top_y, right_bottom_x, right_bottom_y], # the vision's position in the map
        'overlap': {
            'food': [[position.x, position.y, radius], ...], 
            'thorns': [[position.x, position.y, radius], ...],
            'spore': [[position.x, position.y, radius], ...],
            'clone': [[[position.x, position.y, radius, player_name, team_name], ...],     
        }, # all balls' info in vision
        'team_name': team_name, # the team which this player belongs to 
    }
}

We define that feature_layers in player_state represents the feature of this player. feature_layers has several channels, and each channel gives the info of food balls, or spore balls, or thorns balls, or player balls in its vision. For example, in a match we have 4 teams and 3 players for each team, then we get feature_layers as a list, and the length of this list should be 15, including 12 player channel, 1 food ball channel , 1 spore ball channel and 1 thorns ball channel.

Since getting feature_layers costs much time, GoBigger also provides player state without feature_layers when you add use_spatial=False in your render. More details here.

Action Space

In fact, a ball can only move, eject, split, and stop in a match, thus the action space simply includes:

  • Moving direction for the player balls.
  • Split: Players can split a ball into two when it reaches a sufficient size.
  • Eject: Player balls can eject spore on your moving direction.
  • Stop: Stop player balls and gather together together.

More details in action-space.

Getting Started

Installation

Prerequisites

We test GoBigger within the following system:

  • Centos 7.6
  • Windows 10
  • MacOS Catalina 10.15

And we recommend that your python version is 3.6.

Get and install GoBigger

You can simply install GoBigger from PyPI with the following command:

pip install gobigger

If you use Anaconda or Miniconda, you can install GoBigger through the following command:

conda install -c opendilab gobigger

You can also install with newest version through GitHub. First get and download the official repository with the following command line.

git clone https://github.com/opendilab/GoBigger.git

Then you can install from source:

# install for use
# Note: use `--user` option to install the related packages in the user own directory(e.g.: ~/.local)
pip install . --user
     
# install for development(if you want to modify GoBigger)
pip install -e . --user

Launch a game environment

After installation, you can launch your game environment easily according the following code:

import random
from gobigger.server import Server
from gobigger.render import EnvRender

server = Server()
render = EnvRender(server.map_width, server.map_height)
server.set_render(render)
server.start()
player_names = server.get_player_names_with_team()
# get [[team1_player1, team1_player2], [team2_player1, team2_player2], ...]
for i in range(10000):
    actions = {player_name: [random.uniform(-1, 1), random.uniform(-1, 1), -1] \
               for team in player_names for player_name in team}
    if not server.step(actions):
        global_state, screen_data_players = server.obs()
    else:
        print('finish game!')
        break
server.close()

We also build a simple env following gym.Env. For more details, you can refer to gobigger_env.py.

Real-time Interaction with game

GoBigger allow users to play game on their personal computer in real-time. Serveral modes are supported for users to explore this game.

Single Player

If you want to play real-time game on your PC on your own, you can launch a game with the following code:

python -m gobigger.bin.play --player-num 1 --vision-type full

In this mode, up arrow & down arrow & left arrow & rigth arrow allows your balls move, Q means eject spore on your moving direction, W means split your balls, and E means stop all your balls and gather them together.

Double Players

If you want to play real-time game on your PC with your friends, you can launch a game with the following code:

python -m gobigger.bin.play --player-num 2 --vision-type full

In this mode, player1 use up arrow & down arrow & left arrow & rigth arrow allows the balls move, [ means eject spore on your moving direction, ] means split your balls, and \ means stop all your balls and gather them together. player2 use W & S & A & D allows the balls move, 1 means eject spore on your moving direction, 2 means split your balls, and 3 means stop all your balls and gather them together.

Single Players with partial vision

If you want to play real-time game on your PC with only partial vision, you can launch a game with the following code:

python -m gobigger.bin.play --player-num 1 --vision-type partial

Your vision depends on all your balls’ positions and their size.

Single Players against bots

If you want to play against a bot, you can launch a game with the following code:

python -m gobigger.bin.play --vs-bot

You can also add more bots in your game. Try to win the game with more bots!

python -m gobigger.bin.play --vs-bot --team-num 4

High-level Operations in GoBigger

Eject towards the center

Surround others by splitting

Eat food balls quickly

Concentrate size

Resources

For more details, please refer to GoBigger Doc (中文版).

License

GoBigger released under the Apache 2.0 license.

Comments
  • pygame.error: Text has zero width

    pygame.error: Text has zero width

    python3.6 -m gobigger.bin.play --player-num 1 --vision-type full pygame 2.0.3 (SDL 2.0.16, Python 3.6.8) Hello from the pygame community. https://www.pygame.org/contribute.html DEBUG:root:{'team_num': 1, 'player_num_per_team': 1, 'map_width': 1000, 'map_height': 1000, 'match_time': 600, 'state_tick_per_second': 20, 'action_tick_per_second': 5, 'collision_detection_type': 'precision', 'save_video': False, 'save_quality': 'high', 'save_path': '', 'manager_settings': {'food_manager': {'num_init': 2000, 'num_min': 2000, 'num_max': 2500, 'refresh_time': 2, 'refresh_num': 30, 'ball_settings': {'radius_min': 2, 'radius_max': 2}}, 'thorns_manager': {'num_init': 15, 'num_min': 15, 'num_max': 20, 'refresh_time': 2, 'refresh_num': 2, 'ball_settings': {'radius_min': 12, 'radius_max': 20, 'vel_max': 100, 'eat_spore_vel_init': 10, 'eat_spore_vel_zero_time': 1}}, 'player_manager': {'ball_settings': {'acc_max': 100, 'vel_max': 25, 'radius_min': 3, 'radius_max': 300, 'radius_init': 3, 'part_num_max': 16, 'on_thorns_part_num': 10, 'on_thorns_part_radius_max': 20, 'split_radius_min': 10, 'eject_radius_min': 10, 'recombine_age': 20, 'split_vel_init': 30, 'split_vel_zero_time': 1, 'stop_zero_time': 1, 'size_decay_rate': 5e-05, 'given_acc_weight': 10}}, 'spore_manager': {'ball_settings': {'radius_min': 3, 'radius_max': 3, 'vel_init': 250, 'vel_zero_time': 0.3, 'spore_radius_init': 20}}}, 'custom_init': {'food': [], 'thorns': [], 'spore': [], 'clone': []}, 'obs_settings': {'with_spatial': True, 'with_speed': False, 'with_all_vision': False}} Traceback (most recent call last): File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/bin/play.py", line 305, in play_control_by_keyboard() File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/bin/play.py", line 71, in play_control_by_keyboard render.fill(server, direction=None, fps=fps_real, last_time=server.last_time) File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/render/realtime_render.py", line 33, in fill player_num_per_team=1) File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/render/env_render.py", line 219, in render_all_balls_colorful txt = font.render('{}'.format(chr(int(ball.owner)%player_num_per_team+65)), True, WHITE) pygame.error: Text has zero width

    opened by wduo 5
  • Why team num >= 7 is not allowed in Real-time Interaction mode?

    Why team num >= 7 is not allowed in Real-time Interaction mode?

    Hey, I set --team-num 7 and it give me the following error:

    Traceback (most recent call last):
      File "/home/zhou/miniconda3/envs/gobigger/lib/python3.6/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/home/zhou/miniconda3/envs/gobigger/lib/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/zhou/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/bin/play.py", line 311, in <module>
        play_control_by_keyboard_vs_bot(team_num=args.team_num)
      File "/home/zhou/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/bin/play.py", line 289, in play_control_by_keyboard_vs_bot
        render.fill(server, direction=None, fps=fps_real, last_time=server.last_time)
      File "/home/zhou/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/render/realtime_render.py", line 33, in fill
        player_num_per_team=1)
      File "/home/zhou/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/render/env_render.py", line 314, in render_all_balls_colorful
        pygame.draw.circle(screen, PLAYER_COLORS[int(ball.team_name)][0], ball.position, ball.radius)
    IndexError: list index out of range
    

    and it works fine with team num smaller than 7, what's wrong?

    bug 
    opened by SimZhou 4
  • engine update

    engine update

    • [x] 精简的action space,仅保留move, eject, split三个动作
    • [x] 更真实的引擎,使碰撞相关的计算更方便,并可以总结出一套可量化的移动规则
    • [x] 更快的环境step速度,从整体结构上进行优化
    • [x] 新模式:为每个玩家的每个分身球提供单独的动作
    • [x] 文档更新
    opened by mingzhang96 1
  • Is there any related benchmarks?

    Is there any related benchmarks?

    I knew there was a competition on this environment, so I wonder if there are some benchmark results using latest algorithms, or papers experimented on this environment such that comparisons can be made, thanks!

    opened by GEYOUR 1
  • add density in cfg

    add density in cfg

    说明

    config 中添加了 match_ratio 字段。表示比赛setting的配置比例。默认是1.0。这个值将会乘到manager里涉及到球球数量的参数和地图大小上,来保证等比例对场景进行缩放。例如如果这个值设为0.5,则地图宽高会乘以 math.sqrt(0.5) 来保证面积为原来的0.5倍,然后地图内球球的数量会乘以0.5。

    使用

    server = Server(cfg=dict(match_ratio=1.0))
    
    opened by mingzhang96 1
  • add owner for spore

    add owner for spore

    携带孢子球所属玩家信息 我们为每个孢子球赋予了他被哪个玩家吐出的信息。例如,某个孢子球被id为1的玩家吐出,那么这个孢子球会携带一个 owner 属性,并且值为1.

    举个简单的例子,如果你在 obs_settings 中设置了 with_spore_owner=True,那么在你得到的孢子球信息中将会包含 owner 字段。如下所示:

    [position.x, position.y, radius, owner]
    

    当然,如果你同时设置了 with_speed=True,孢子球信息将会变成如下所示:

    [position.x, position.y, radius, vel.x, vel.y, owner]
    
    opened by mingzhang96 1
  • 0.2.0

    0.2.0

    1. Add owner for spore in overlap #37
    2. Add match_ratio in config to control density #38
    3. allow ball to move over border with center 允许球球跨过地图边界,但是球心不能跨过;allow vision over border 玩家的视野可以跨过地图边界,并且始终是正方形,地图外补零表示 #39
    4. engine update #41
    5. add different config #45
    6. add direction for each cloneball #46
    7. add new replayer for .pb files #47
    8. add more config & udpate doc #51
    opened by mingzhang96 1
  • bug fix

    bug fix

    1. In gobigger/balls/clone_ball.py, self.radius + ball.radius may smaller than d.
    2. In gobigger/players/human_player.py, self.get_clone_num() may equal 0.
    opened by mingzhang96 1
  • add cheat for env render

    add cheat for env render

    Get global vision + player's local vision

    In many scenarios, using some cheat information (such as removing the fog of war) can effectively help the algorithm converge. Therefore, on the basis of obtaining the global vision, we have added a mode of obtaining the global vision and the player's local vision at the same time. Get it by specifying cheat=True. Note that in this mode, the setting of with_all_vision will have no effect, because the global vision information will always be returned. For example, assuming there are 2 teams in a game with 1 player in each team, the player_state obtained will be as follows:

    .. code-block::python

    {
        'all': {
            'feature_layers': list(numpy.ndarray),
            'rectangle': None,
            'overlap': {
                'food': [{'position': position, 'radius': radius}, ...],
                'thorns': [{'position': position, 'radius': radius}, ...],
                'spore': [{'position': position, 'radius': radius}, ...],
                'clone': [{'position': position, 'radius': radius, 'player': player_name, 'team': team_name}, ...],
            },
            'team_name': '',
        }
        '0': {
            'feature_layers': list(numpy.ndarray),
            'rectangle': None,
            'overlap': {
                'food': [{'position': position, 'radius': radius}, ...],
                'thorns': [{'position': position, 'radius': radius}, ...],
                'spore': [{'position': position, 'radius': radius}, ...],
                'clone': [{'position': position, 'radius': radius, 'player': player_name, 'team': team_name}, ...],
            },
            'team_name': team_name,
        },
        '1': {
            'feature_layers': list(numpy.ndarray),
            'rectangle': None,
            'overlap': {
                'food': [{'position': position, 'radius': radius}, ...],
                'thorns': [{'position': position, 'radius': radius}, ...],
                'spore': [{'position': position, 'radius': radius}, ...],
                'clone': [{'position': position, 'radius': radius, 'player': player_name, 'team': team_name}, ...],
            },
            'team_name': team_name,
        },
    }
    

    Note that the global view information is placed under the all field, where the team_name is set to empty. The rest of the player information remains the same.

    opened by mingzhang96 1
  • add reload game for server

    add reload game for server

    Now you can reload a game at any frame number!

    Try to use this feature in your config for server:

    save_bin=False, # Whether to save the information of the game
    load_bin=False, # Whether to load the information of a game at the start of the game
    load_bin_path='', # The file path to load the information of a game at the start of the game
    load_bin_frame_num ='all', # can be int (representing the action frame number to load), or 'all' (representing loading all frames)
    
    documentation enhancement 
    opened by mingzhang96 1
Releases(v0.2.0)
Owner
OpenDILab
Open sourced Decision Intelligence (DI)
OpenDILab
Multi-Glimpse Network With Python

Multi-Glimpse Network Multi-Glimpse Network: A Robust and Efficient Classification Architecture based on Recurrent Downsampled Attention arXiv Require

9 May 10, 2022
Tensorboard for pytorch (and chainer, mxnet, numpy, ...)

tensorboardX Write TensorBoard events with simple function call. The current release (v2.3) is tested on anaconda3, with PyTorch 1.8.1 / torchvision 0

Tzu-Wei Huang 7.5k Dec 28, 2022
🛰️ List of earth observation companies and job sites

Earth Observation Companies & Jobs source Portals & Jobs Geospatial Geospatial jobs newsletter: ~biweekly newsletter with geospatial jobs by Ali Ahmad

Dahn 64 Dec 27, 2022
[ICCV'21] Official implementation for the paper Social NCE: Contrastive Learning of Socially-aware Motion Representations

CrowdNav with Social-NCE This is an official implementation for the paper Social NCE: Contrastive Learning of Socially-aware Motion Representations by

VITA lab at EPFL 125 Dec 23, 2022
PyTorch code for EMNLP 2021 paper: Don't be Contradicted with Anything! CI-ToD: Towards Benchmarking Consistency for Task-oriented Dialogue System

PyTorch code for EMNLP 2021 paper: Don't be Contradicted with Anything! CI-ToD: Towards Benchmarking Consistency for Task-oriented Dialogue System

Libo Qin 25 Sep 06, 2022
Reference PyTorch implementation of "End-to-end optimized image compression with competition of prior distributions"

PyTorch reference implementation of "End-to-end optimized image compression with competition of prior distributions" by Benoit Brummer and Christophe

Benoit Brummer 6 Jun 16, 2022
Objax Apache-2Objax (🥉19 · ⭐ 580) - Objax is a machine learning framework that provides an Object.. Apache-2 jax

Objax Tutorials | Install | Documentation | Philosophy This is not an officially supported Google product. Objax is an open source machine learning fr

Google 729 Jan 02, 2023
Pseudo-mask Matters in Weakly-supervised Semantic Segmentation

Pseudo-mask Matters in Weakly-supervised Semantic Segmentation By Yi Li, Zhanghui Kuang, Liyang Liu, Yimin Chen, Wayne Zhang SenseTime, Tsinghua Unive

33 Oct 14, 2022
Official implementation of "Not only Look, but also Listen: Learning Multimodal Violence Detection under Weak Supervision" ECCV2020

XDVioDet Official implementation of "Not only Look, but also Listen: Learning Multimodal Violence Detection under Weak Supervision" ECCV2020. The proj

peng 64 Dec 12, 2022
The fundamental package for scientific computing with Python.

NumPy is the fundamental package needed for scientific computing with Python. Website: https://www.numpy.org Documentation: https://numpy.org/doc Mail

NumPy 22.4k Jan 09, 2023
Repo for EchoVPR: Echo State Networks for Visual Place Recognition

EchoVPR Repo for EchoVPR: Echo State Networks for Visual Place Recognition Currently under development Dirs: data: pre-collected hidden representation

Anil Ozdemir 4 Oct 04, 2022
MINOS: Multimodal Indoor Simulator

MINOS Simulator MINOS is a simulator designed to support the development of multisensory models for goal-directed navigation in complex indoor environ

194 Dec 27, 2022
An Implementation of Transformer in Transformer in TensorFlow for image classification, attention inside local patches

Transformer-in-Transformer An Implementation of the Transformer in Transformer paper by Han et al. for image classification, attention inside local pa

Rishit Dagli 40 Jul 25, 2022
Computer Vision is an elective course of MSAI, SCSE, NTU, Singapore

[AI6122] Computer Vision is an elective course of MSAI, SCSE, NTU, Singapore. The repository corresponds to the AI6122 of Semester 1, AY2021-2022, starting from 08/2021. The instructor of this course

HT. Li 5 Sep 12, 2022
An extremely simple, intuitive, hardware-friendly, and well-performing network structure for LiDAR semantic segmentation on 2D range image. IROS21

FIDNet_SemanticKITTI Motivation Implementing complicated network modules with only one or two points improvement on hardware is tedious. So here we pr

YimingZhao 54 Dec 12, 2022
Pytorch reimplementation of PSM-Net: "Pyramid Stereo Matching Network"

This is a Pytorch Lightning version PSMNet which is based on JiaRenChang/PSMNet. use python main.py to start training. PSM-Net Pytorch reimplementatio

XIAOTIAN LIU 1 Nov 25, 2021
An implementation for `Text2Event: Controllable Sequence-to-Structure Generation for End-to-end Event Extraction`

Text2Event An implementation for Text2Event: Controllable Sequence-to-Structure Generation for End-to-end Event Extraction Please contact Yaojie Lu (@

Roger 153 Jan 07, 2023
Implement some metaheuristics and cost functions

Metaheuristics This repot implement some metaheuristics and cost functions. Metaheuristics JAYA Implement Jaya optimizer without constraints. Cost fun

Adri1G 1 Mar 23, 2022
Use unsupervised and supervised learning to predict stocks

AIAlpha: Multilayer neural network architecture for stock return prediction This project is meant to be an advanced implementation of stacked neural n

Vivek Palaniappan 1.5k Dec 26, 2022
QICK: Quantum Instrumentation Control Kit

QICK: Quantum Instrumentation Control Kit The QICK is a kit of firmware and software to use the Xilinx RFSoC to control quantum systems. It consists o

81 Dec 15, 2022