oxwhirl/smac

The order of Env feedback

Joseph-Chen-Jh opened this issue · 3 comments

If I'm running a 2s3z env, the env returns 5 observations at each time step. It is true that the first two correspond to 2 stalkers and the last three are zealots? And how about other heterogeneous scenarios?

@Joseph-Chen-Jh You might want to check "init_unit(self)" in smac/env/starcraft2/starcraft2.py, ally_units are sorted with key=attrgetter("unit_type", "pos.x", "pos.y"), so the observation of ally in 2s3z will be in the order of "s, s, z, z, z". Observation of enemy units can also be found here, and i think it might be unordered. You can also print state vector and check the "unit_type_bits" to verify it.

Thanks for your answer! Bytheway, is there any way to see the meaning of each element of obs and states? The distances, health and shields are obvious, but the others are hard to identify.

You can still find it in smac/env/starcraft2/starcraft2.py in get_obs_agent and get_state_dict. As for the obs, checking get_obs_enemy_feats_size, get_obs_ally_feats_size, and get_obs_own_feats_size might be helpful.

Let us take enemy_obs enemy_feats(shape=(5, 4+2+2)) as an example(map=2s3z, unit_type_bits=2, shield_bits_enemy=1). enemy_feats[i] denotes the obs of the i^th enemy from the current agent's view. enemy_feats[i][0:4] means whether the agent can attack the enemy, distance, relative X, relative Y, respectively. enemy_feats[i][4:6] are the values of health and shield. enemy_feats[i][6:8] is 2-dim one-hot vector that represents the i^th enemy's type (s/z).

You can find the meaning of ally_obs, own_obs, and state as well. You are welcome to contact me by email if you have any other questions.