Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/YiwenAI/openrl into main
Browse files Browse the repository at this point in the history
  • Loading branch information
YiwenAI committed Jun 20, 2023
2 parents bdc761d + 708a1f5 commit 4c51fcd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/smac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation guide for Linux:

- `pip install pysc2`
- Download `StarCraftII.zip` from [Tsinghua Cloud](https://cloud.tsinghua.edu.cn/d/da76bbb842f34d109b80/?p=%2Fresearch%2FRL%2Fenv%2FSMAC&mode=list).
- Download `StarCraftII.zip` from [Tsinghua Cloud](https://cloud.tsinghua.edu.cn/d/da76bbb842f34d109b80/?p=%2Fresearch%2FRL%2Fenv%2FSMAC&mode=list) or from [Google Drive](https://drive.google.com/drive/folders/1umnlFotrXdEnmTUqfzGoJfJ7kAKf-eKO).
- unzip `StarCraftII.zip` to `~/StarCraftII/`: `unzip StarCraftII.zip -d ~/`
- If something is wrong with protobuf, you can do this: `pip install protobuf==3.20.3`

Expand Down
26 changes: 2 additions & 24 deletions examples/smac/smac_env/smac_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

""""""

from functools import reduce

import gymnasium as gym
import numpy as np
from gymnasium import spaces
Expand All @@ -30,28 +28,13 @@ class SMACEnv(gym.Env):

def __init__(self, cfg):
self.env = StarCraft2Env(cfg)
# print(self.env.observation_space[0])
# exit()
# policy_obs_dim = reduce(
# lambda a, b: a + b,
# [
# reduce(lambda a, b: a * b, x) if isinstance(x, list) else x
# for x in self.env.observation_space[0]
# ],
# )

policy_obs_dim = self.env.observation_space[0][0]

policy_obs = spaces.Box(
low=-np.inf, high=+np.inf, shape=(policy_obs_dim,), dtype=np.float32
)

# critic_obs_dim = reduce(
# lambda a, b: a + b,
# [
# reduce(lambda a, b: a * b, x) if isinstance(x, list) else x
# for x in self.env.share_observation_space[0]
# ],
# )
critic_obs_dim = self.env.share_observation_space[0][0]

critic_obs = spaces.Box(
Expand All @@ -72,12 +55,7 @@ def reset(self, seed=None, **kwargs):
if seed is not None:
self.env.seed(seed)
local_obs, global_state, available_actions = self.env.reset()
# global_state = np.concatenate(global_state, -1)[None, :].repeat(
# self.agent_num, 0
# )
# print("local_obs", local_obs)
# print("global_state", global_state)
# exit()

return {"policy": local_obs, "critic": global_state}, {
"available_actions": available_actions
}
Expand Down

0 comments on commit 4c51fcd

Please sign in to comment.