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

add cheat for env render #30

Closed mingzhang96 closed 2 years ago

mingzhang96 commented 2 years ago

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.

codecov[bot] commented 2 years ago

Codecov Report

Merging #30 (4fca1f6) into main (f2a7dc1) will increase coverage by 0.31%. The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
+ Coverage   87.48%   87.79%   +0.31%     
==========================================
  Files          63       63              
  Lines        3915     3949      +34     
==========================================
+ Hits         3425     3467      +42     
+ Misses        490      482       -8     
Flag Coverage Δ
unittests 87.79% <94.44%> (+0.31%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gobigger/server/server_default_config.py 100.00% <ø> (ø)
gobigger/render/env_render.py 85.49% <90.90%> (+0.34%) :arrow_up:
gobigger/render/test/test_env_render.py 100.00% <100.00%> (ø)
gobigger/hyper/actions.py 54.03% <0.00%> (ø)
gobigger/agents/bot_agent.py 80.11% <0.00%> (+1.16%) :arrow_up:
gobigger/server/server.py 71.47% <0.00%> (+2.74%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f2a7dc1...4fca1f6. Read the comment docs.