-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:opendilab/GoBigger
- Loading branch information
Showing
43 changed files
with
1,257 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Derived Environments and Action Spaces | ||
################ | ||
|
||
Overview | ||
======================= | ||
|
||
On the basis of the GoBigger environment, considering the complexity of large-scale environment training and | ||
algorithm verification for specific tasks, we provide some small environments under specific conditions, | ||
as well as advanced serialization actions to facilitate training and algorithm design. | ||
|
||
|
||
small environment | ||
======================= | ||
|
||
We provide the initialization method of the small environment by providing config. | ||
|
||
|
||
* The clone fits the ball, the clone holds the ball (2f2s) | ||
|
||
There are only two teams in this small environment, and there are two players in each team. | ||
There will also be food summed thorn balls in the same scale in the map. In this map, the blue A ball | ||
only needs to split to the right, while the blue B ball needs to eat the small ball split by the blue A ball | ||
and move down, and eat the yellow A by splitting (or moving). ball. | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/2f2s.png | ||
:width: 300 | ||
:align: center | ||
|
||
|
||
* Measured increase (2f2s_v2) | ||
|
||
This small environment is the v2 version of 2f2s. In this map, the blue A ball only needs to split | ||
to the right, while the blue B ball remains stationary to eat the yellow A ball. | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/2f2s_v2.png | ||
:width: 300 | ||
:align: center | ||
|
||
|
||
* Measured increase (2f2s_v3) | ||
|
||
This small environment is the v3 version of 2f2s. In this map, the blue A ball needs to split between | ||
the yellow ball and the blue B ball and spore the center, while the blue B ball moves down to eat the yellow A ball. | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/2f2s_v3.png | ||
:width: 300 | ||
:align: center | ||
|
||
|
||
Advanced Serialization Actions | ||
======================= | ||
|
||
Please check ``gobigger/hyper/tests`` to get more details on serialization actions. | ||
|
||
|
||
* Straight line | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/straight_merge.gif | ||
:width: 362 | ||
:align: center | ||
|
||
|
||
* Four point ball | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/quarter_merge.gif | ||
:width: 362 | ||
:align: center | ||
|
||
|
||
* Eights | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/eighth_merge.gif | ||
:width: 338 | ||
:align: center |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
衍生环境和动作空间 | ||
################ | ||
|
||
总览 | ||
====================== | ||
|
||
在 GoBigger 环境的基础上,考虑到大环境训练的复杂度以及针对特定任务的算法验证,我们提供了部分特定条件下的小环境,以及高级序列化动作来方便 | ||
大家进行训练和算法设计。 | ||
|
||
|
||
小环境 | ||
====================== | ||
|
||
我们通过提供config的方式来提供小环境的初始化方式。 | ||
|
||
|
||
* 分身合球,分身持球(2f2s) | ||
|
||
这个小环境中只有两只队伍,每支队伍中有两个玩家。地图中同时还会存在相同比例的食物求和荆棘球。在本地图中,蓝色A球 | ||
只需要向右边进行分裂,同时蓝色B球需要吃掉蓝色A球分裂出来的小球并向下移动,通过分裂(或移动)的方式吃掉黄色A球。 | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/2f2s.png | ||
:width: 300 | ||
:align: center | ||
|
||
|
||
* 测涨(2f2s_v2) | ||
|
||
这个小环境是2f2s的v2版本。在本地图中,蓝色A球只需要向右边进行分裂,同时蓝色B球保持不动即可吃掉黄色A球。 | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/2f2s_v2.png | ||
:width: 300 | ||
:align: center | ||
|
||
|
||
* 测涨(2f2s_v3) | ||
|
||
这个小环境是2f2s的v3版本。在本地图中,蓝色A球需要向黄色球和蓝色B球之间进行分裂并向中心吐孢子,同时蓝色B球 | ||
向下移动即可吃掉黄色A球。 | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/2f2s_v3.png | ||
:width: 300 | ||
:align: center | ||
|
||
|
||
高级序列化动作 | ||
====================== | ||
|
||
请查看 ``gobigger/hyper/tests`` 目录下的测试文件来使用高级序列化动作。 | ||
|
||
|
||
* 直线合球 | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/straight_merge.gif | ||
:width: 362 | ||
:align: center | ||
|
||
|
||
* 四分合球 | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/quarter_merge.gif | ||
:width: 362 | ||
:align: center | ||
|
||
|
||
* 八分合球 | ||
|
||
.. only:: html | ||
|
||
.. figure:: images/eighth_merge.gif | ||
:width: 338 | ||
:align: center |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import os | ||
import random | ||
import logging | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import logging | ||
import pytest | ||
import uuid | ||
from pygame.math import Vector2 | ||
import pygame | ||
import numpy as np | ||
import cv2 | ||
import argparse | ||
import time | ||
import importlib | ||
|
||
from gobigger.utils import Border | ||
from gobigger.server import Server | ||
from gobigger.render import RealtimeRender, RealtimePartialRender, EnvRender | ||
from gobigger.agents import BotAgent | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
def play_by_config(config_name): | ||
config_module = importlib.import_module('gobigger.hyper.configs.config_{}'.format(config_name)) | ||
config = config_module.server_default_config | ||
server = Server(config) | ||
server.reset() | ||
render = RealtimeRender(server.map_width, server.map_height) | ||
server.set_render(render) | ||
human_team_name = '0' | ||
human_team_player_name = [] | ||
bot_agents = [] | ||
for player in server.player_manager.get_players(): | ||
if player.team_name != human_team_name: | ||
bot_agents.append(BotAgent(player.name)) | ||
else: | ||
human_team_player_name.append(player.name) | ||
fps_real = 0 | ||
t1 = time.time() | ||
clock = pygame.time.Clock() | ||
fps_set = server.state_tick_per_second | ||
for i in range(100000): | ||
obs = server.obs() | ||
# actions_bot = {bot_agent.name: bot_agent.step(obs[1][bot_agent.name]) for bot_agent in bot_agents} | ||
actions_bot = {bot_agent.name: [None, None, -1] for bot_agent in bot_agents} | ||
actions = {player_name: [None, None, -1] for player_name in human_team_player_name} | ||
x, y = None, None | ||
action_type = -1 | ||
# ================ control by keyboard =============== | ||
for event in pygame.event.get(): | ||
if event.type == pygame.KEYDOWN: | ||
x1, y1, x2, y2 = None, None, None, None | ||
action_type1 = -1 | ||
action_type2 = -1 | ||
if event.key == pygame.K_UP: | ||
x1, y1 = 0, -1 | ||
if event.key == pygame.K_DOWN: | ||
x1, y1 = 0, 1 | ||
if event.key == pygame.K_LEFT: | ||
x1, y1 = -1, 0 | ||
if event.key == pygame.K_RIGHT: | ||
x1, y1 = 1, 0 | ||
if event.key == pygame.K_LEFTBRACKET: # Spores | ||
action_type1 = 0 | ||
if event.key == pygame.K_RIGHTBRACKET: # Splite | ||
action_type1 = 1 | ||
if event.key == pygame.K_BACKSLASH: # Stop moving | ||
action_type1 = 2 | ||
if event.key == pygame.K_w: | ||
x2, y2 = 0, -1 | ||
if event.key == pygame.K_s: | ||
x2, y2 = 0, 1 | ||
if event.key == pygame.K_a: | ||
x2, y2 = -1, 0 | ||
if event.key == pygame.K_d: | ||
x2, y2 = 1, 0 | ||
if event.key == pygame.K_1: # Spores | ||
action_type2 = 0 | ||
if event.key == pygame.K_2: # Splite | ||
action_type2 = 1 | ||
if event.key == pygame.K_3: # Stop moving | ||
action_type2 = 2 | ||
actions = { | ||
human_team_player_name[0]: [x1, y1, action_type1], | ||
human_team_player_name[1]: [x2, y2, action_type2], | ||
} | ||
if server.last_time < server.match_time: | ||
actions.update(actions_bot) | ||
print(actions) | ||
server.step_state_tick(actions=actions) | ||
if actions is not None and x is not None and y is not None: | ||
render.fill(server, direction=Vector2(x, y), fps=fps_real, last_time=server.last_time) | ||
else: | ||
render.fill(server, direction=None, fps=fps_real, last_time=server.last_time) | ||
render.show() | ||
if i % server.state_tick_per_second == 0: | ||
t2 = time.time() | ||
fps_real = server.state_tick_per_second/(t2-t1) | ||
t1 = time.time() | ||
else: | ||
logging.debug('Game Over') | ||
break | ||
clock.tick(fps_set) | ||
render.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-c', '--config', type=str, default='2f2s') | ||
args = parser.parse_args() | ||
|
||
play_by_config(args.config) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .actions import StraightMergeHyperAction, QuarterMergeHyperAction, EighthMergeHyperAction |
Oops, something went wrong.