Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(nyz): add basic distar policy collect(ci skip) #393

Merged
merged 2 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dizoo/distar/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .distar_env import DIStarEnv
from .meta import *
from .static_data import BEGIN_ACTIONS, ACTION_RACE_MASK, SELECTED_UNITS_MASK
from .static_data import BEGIN_ACTIONS, ACTION_RACE_MASK, SELECTED_UNITS_MASK, ACTIONS
from .stat import Stat
from .fake_data import get_fake_rl_trajectory, fake_rl_data_batch_with_last
10 changes: 5 additions & 5 deletions dizoo/distar/envs/fake_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import torch

from ding.utils.data import default_collate
from .meta import MAX_DELAY, MAX_ENTITY_NUM, NUM_ACTIONS, ENTITY_TYPE_NUM, NUM_UPGRADES, NUM_CUMULATIVE_STAT_ACTIONS, \
from .meta import MAX_DELAY, MAX_ENTITY_NUM, NUM_ACTIONS, NUM_UNIT_TYPES, NUM_UPGRADES, NUM_CUMULATIVE_STAT_ACTIONS, \
NUM_BEGINNING_ORDER_ACTIONS, NUM_UNIT_MIX_ABILITIES, NUM_QUEUE_ACTION, NUM_BUFFS, NUM_ADDON, MAX_SELECTED_UNITS_NUM

H, W = 152, 160
Expand All @@ -28,7 +28,7 @@ def spatial_info():

def entity_info():
data = {
'unit_type': torch.randint(0, ENTITY_TYPE_NUM, size=(MAX_ENTITY_NUM, ), dtype=torch.float),
'unit_type': torch.randint(0, NUM_UNIT_TYPES, size=(MAX_ENTITY_NUM, ), dtype=torch.float),
'alliance': torch.randint(0, 5, size=(MAX_ENTITY_NUM, ), dtype=torch.float),
'cargo_space_taken': torch.randint(0, 9, size=(MAX_ENTITY_NUM, ), dtype=torch.float),
'build_progress': torch.rand(MAX_ENTITY_NUM),
Expand Down Expand Up @@ -74,7 +74,7 @@ def scalar_info():
'away_race': torch.randint(0, 4, size=(), dtype=torch.float),
'agent_statistics': torch.rand(10),
'time': torch.randint(0, 100, size=(), dtype=torch.float),
'unit_counts_bow': torch.randint(0, 10, size=(ENTITY_TYPE_NUM, ), dtype=torch.float),
'unit_counts_bow': torch.randint(0, 10, size=(NUM_UNIT_TYPES, ), dtype=torch.float),
'beginning_build_order': torch.randint(0, 20, size=(20, ), dtype=torch.float),
'cumulative_stat': torch.randint(0, 2, size=(NUM_CUMULATIVE_STAT_ACTIONS, ), dtype=torch.float),
'last_delay': torch.randint(0, MAX_DELAY, size=(), dtype=torch.float),
Expand All @@ -83,8 +83,8 @@ def scalar_info():
'upgrades': torch.randint(0, 2, size=(NUM_UPGRADES, ), dtype=torch.float),
'beginning_order': torch.randint(0, NUM_BEGINNING_ORDER_ACTIONS, size=(20, ), dtype=torch.float),
'bo_location': torch.randint(0, 100 * 100, size=(20, ), dtype=torch.float),
'unit_type_bool': torch.randint(0, 2, size=(ENTITY_TYPE_NUM, ), dtype=torch.float),
'enemy_unit_type_bool': torch.randint(0, 2, size=(ENTITY_TYPE_NUM, ), dtype=torch.float),
'unit_type_bool': torch.randint(0, 2, size=(NUM_UNIT_TYPES, ), dtype=torch.float),
'enemy_unit_type_bool': torch.randint(0, 2, size=(NUM_UNIT_TYPES, ), dtype=torch.float),
'unit_order_type': torch.randint(0, 2, size=(NUM_UNIT_MIX_ABILITIES, ), dtype=torch.float)
}
return data
Expand Down
3 changes: 1 addition & 2 deletions dizoo/distar/envs/meta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MAX_DELAY = 128
MAX_ENTITY_NUM = 512
MAX_SELECTED_UNITS_NUM = 64
ENTITY_TYPE_NUM = 260
NUM_UNIT_TYPES = 260
NUM_ACTIONS = 327
NUM_UPGRADES = 90
NUM_CUMULATIVE_STAT_ACTIONS = 167
Expand All @@ -10,4 +10,3 @@
NUM_QUEUE_ACTION = 49
NUM_BUFFS = 50
NUM_ADDON = 9
MAX_SELECTED_UNITS_NUM = 64
Loading