Skip to content

Commit

Permalink
Update to the latest protos. This is needed to support more feature l…
Browse files Browse the repository at this point in the history
…ayers, effect data, and observer actions.

PiperOrigin-RevId: 171136110
  • Loading branch information
tewalds committed Oct 12, 2017
1 parent 4a8b918 commit e9d1293
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
5 changes: 3 additions & 2 deletions pysc2/bin/gen_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from absl import app
from absl import flags
from s2clientprotocol import common_pb2 as sc_common
from s2clientprotocol import data_pb2 as sc_data
from s2clientprotocol import sc2api_pb2 as sc_pb

Expand All @@ -43,9 +44,9 @@ def get_data():
create = sc_pb.RequestCreateGame(local_map=sc_pb.LocalMap(
map_path=m.path, map_data=m.data(run_config)))
create.player_setup.add(type=sc_pb.Participant)
create.player_setup.add(type=sc_pb.Computer, race=sc_pb.Random,
create.player_setup.add(type=sc_pb.Computer, race=sc_common.Random,
difficulty=sc_pb.VeryEasy)
join = sc_pb.RequestJoinGame(race=sc_pb.Random,
join = sc_pb.RequestJoinGame(race=sc_common.Random,
options=sc_pb.InterfaceOptions(raw=True))

controller.create_game(create)
Expand Down
6 changes: 4 additions & 2 deletions pysc2/bin/replay_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from absl import app
from absl import flags
from pysc2.lib import gfile
from s2clientprotocol import common_pb2 as sc_common
from s2clientprotocol import sc2api_pb2 as sc_pb

FLAGS = flags.FLAGS
Expand Down Expand Up @@ -204,8 +205,9 @@ def run(self):
if valid_replay(info, ping):
self.stats.replay_stats.maps[info.map_name] += 1
for player_info in info.player_info:
self.stats.replay_stats.races[
sc_pb.Race.Name(player_info.player_info.race_actual)] += 1
race_name = sc_common.Race.Name(
player_info.player_info.race_actual)
self.stats.replay_stats.races[race_name] += 1
map_data = None
if info.local_map_path:
self._update_stage("open map file")
Expand Down
5 changes: 3 additions & 2 deletions pysc2/bin/replay_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from absl import app
from pysc2.lib import gfile
from s2clientprotocol import common_pb2 as sc_common
from s2clientprotocol import sc2api_pb2 as sc_pb


Expand Down Expand Up @@ -65,12 +66,12 @@ def _replay_index(replay_dir):
info.game_duration_loops,
len(info.player_info),
sc_pb.Result.Name(info.player_info[0].player_result.result),
sc_pb.Race.Name(info.player_info[0].player_info.race_actual),
sc_common.Race.Name(info.player_info[0].player_info.race_actual),
info.player_info[0].player_apm,
]
if len(info.player_info) >= 2:
out += [
sc_pb.Race.Name(info.player_info[1].player_info.race_actual),
sc_common.Race.Name(info.player_info[1].player_info.race_actual),
info.player_info[1].player_apm,
]
print(u",".join(str(s) for s in out))
Expand Down
9 changes: 5 additions & 4 deletions pysc2/env/sc2_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from pysc2.lib import run_parallel
from pysc2.lib import stopwatch

from s2clientprotocol import common_pb2 as sc_common
from s2clientprotocol import sc2api_pb2 as sc_pb

sw = stopwatch.sw
Expand All @@ -41,10 +42,10 @@
}

races = {
"R": sc_pb.Random,
"P": sc_pb.Protoss,
"T": sc_pb.Terran,
"Z": sc_pb.Zerg,
"R": sc_common.Random,
"P": sc_common.Protoss,
"T": sc_common.Terran,
"Z": sc_common.Zerg,
}

difficulties = {
Expand Down
5 changes: 3 additions & 2 deletions pysc2/tests/maps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pysc2.tests import utils

from absl.testing import absltest as basetest
from s2clientprotocol import common_pb2 as sc_common
from s2clientprotocol import sc2api_pb2 as sc_pb


Expand Down Expand Up @@ -58,9 +59,9 @@ def test_load_random_map(self):
create = sc_pb.RequestCreateGame(local_map=sc_pb.LocalMap(
map_path=m.path, map_data=m.data(run_config)))
create.player_setup.add(type=sc_pb.Participant)
create.player_setup.add(type=sc_pb.Computer, race=sc_pb.Random,
create.player_setup.add(type=sc_pb.Computer, race=sc_common.Random,
difficulty=sc_pb.VeryEasy)
join = sc_pb.RequestJoinGame(race=sc_pb.Random,
join = sc_pb.RequestJoinGame(race=sc_common.Random,
options=sc_pb.InterfaceOptions(raw=True))

controller.create_game(create)
Expand Down
5 changes: 3 additions & 2 deletions pysc2/tests/replay_obs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from pysc2.tests import utils

from absl.testing import absltest as basetest
from s2clientprotocol import common_pb2 as sc_common
from s2clientprotocol import sc2api_pb2 as sc_pb

# TODO(tewalds): define unit types in static data?
Expand Down Expand Up @@ -156,10 +157,10 @@ def create_game(self):
create.player_setup.add(type=sc_pb.Participant)
create.player_setup.add(
type=sc_pb.Computer,
race=sc_pb.Terran,
race=sc_common.Terran,
difficulty=sc_pb.VeryEasy)
join = sc_pb.RequestJoinGame(
race=sc_pb.Terran,
race=sc_common.Terran,
options=self._config.interface)

self._controller.create_game(create)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'portpicker',
'protobuf>=2.6',
'pygame',
's2clientprotocol==1.1',
's2clientprotocol>=1.2',
'six',
'websocket-client',
],
Expand Down

0 comments on commit e9d1293

Please sign in to comment.