opendilab / GoBigger

[ICLR 2023] Come & try Decision-Intelligence version of "Agar"! Gobigger could also help you with multi-agent decision intelligence study.
https://gobigger.readthedocs.io/en/latest/
Apache License 2.0
460 stars 34 forks source link

c环境初始化问题 #29

Closed ZeyanZhuang closed 2 years ago

ZeyanZhuang commented 2 years ago

GoBigger C 环境无法初始化食物球、克隆球的位置和大小,是 BUG 还是和 Python 环境初始化的方式不一样呢?

mingzhang96 commented 2 years ago

@ZeyanZhuang 麻烦提供一下config和启动环境的代码?我们这边测试了是正常的

Jingho commented 2 years ago

我也遇到了类似的问题,食物的最大数量是4,在cpp的环境中,reset后看到的食物数量的2000,这是我测试用的代码以及log。

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

server_default_config = dict(
    team_num=2, 
    player_num_per_team=2, 
    map_width=200,
    map_height=200,
    match_time=6,
    state_tick_per_second=10, # frame
    action_tick_per_second=5, # frame
    collision_detection_type='precision',
    save_video=False,
    save_quality='high', # ['high', 'low']
    save_path='',
    save_bin=False, # save bin to go-explore
    load_bin=False,
    load_bin_path='',
    load_bin_frame_num = 'all',
    jump_to_frame_file = '',
    manager_settings=dict(
        # food setting
        food_manager=dict(
            num_init=2, # initial number
            num_min=2, # Minimum number
            num_max=4, # Maximum number
            refresh_time=2, # Time interval (seconds) for refreshing food in the map
            refresh_num=3, # The number of refreshed foods in the map each time
            ball_settings=dict( # The specific parameter description can be viewed in the ball module
                radius_min=2,
                radius_max=2,
            ),
        ),
        # thorns setting
        thorns_manager=dict(
            num_init=1, # initial number
            num_min=1, # Minimum number
            num_max=2, # Maximum number
            refresh_time=2, # Time interval (seconds) for refreshing thorns in the map
            refresh_num=2, # The number of refreshed  thorns in the map each time
            ball_settings=dict( # The specific parameter description can be viewed in the ball module
                radius_min=12, 
                radius_max=20, 
                vel_max=100,
                eat_spore_vel_init=10, 
                eat_spore_vel_zero_time=1,
            )
        ),
        # player setting
        player_manager=dict(
            ball_settings=dict(  # The specific parameter description can be viewed in the ball module
                acc_max=100, 
                vel_max=25,
                radius_min=10,
                radius_max=300,
                radius_init=10,
                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=0.00005, 
                given_acc_weight=10,
            )
        ),
        # spore setting
        spore_manager=dict(
            ball_settings=dict( # The specific parameter description can be viewed in the ball module
                radius_min=3, 
                radius_max=3, 
                vel_init=250,
                vel_zero_time=0.3, 
                spore_radius_init=20, 
            )
        )   
    ),
    custom_init=dict(
        food=[], # only position and radius
        thorns=[], # only position and radius
        spore=[], # only position and radius
        clone=[], # only position and radius and player and team
    ),
    obs_settings=dict(
        with_spatial=True,
        with_speed=False,
        with_all_vision=False,
    ),
)

server = Server(cfg=server_default_config)
render = EnvRender(server.map_width, server.map_height)
server.set_render(render)
server.reset()
global_state, screen_data_players = server.obs()
for k, v in screen_data_players.items():
    overlap = v['overlap']
    for name, data in overlap.items():
        print(f'Player {k} \t {name} \t num: {len(data)}')
server.close()

Player 0 food num: 2000 Player 0 thorns num: 15 Player 0 spore num: 0 Player 0 clone num: 4 Player 1 food num: 2000 Player 1 thorns num: 15 Player 1 spore num: 0 Player 1 clone num: 4 Player 2 food num: 2000 Player 2 thorns num: 15 Player 2 spore num: 0 Player 2 clone num: 4 Player 3 food num: 2000 Player 3 thorns num: 15 Player 3 spore num: 0 Player 3 clone num: 4

mingzhang96 commented 2 years ago

@Jingho 这个问题已经在这个commit 修复了,是由于config没有同步到c++端导致的。但是由于一些奇怪的原因,需要地图内的总球数(包括各种球)大于(4+总玩家数*4) @ZeyanZhuang C++暂时不支持直接从custom_init这个参数来初始化,但可以通过jump_to_frame_file这个参数来初始化