repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
deepmind/pysc2
pysc2/lib/remote_controller.py
decorate_check_error
def decorate_check_error(error_enum): """Decorator to call `check_error` on the return value.""" def decorator(func): @functools.wraps(func) def _check_error(*args, **kwargs): return check_error(func(*args, **kwargs), error_enum) return _check_error return decorator
python
def decorate_check_error(error_enum): """Decorator to call `check_error` on the return value.""" def decorator(func): @functools.wraps(func) def _check_error(*args, **kwargs): return check_error(func(*args, **kwargs), error_enum) return _check_error return decorator
[ "def", "decorate_check_error", "(", "error_enum", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_check_error", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "check_error", ...
Decorator to call `check_error` on the return value.
[ "Decorator", "to", "call", "check_error", "on", "the", "return", "value", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L66-L73
train
Decorator to call check_error on the return value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
skip_status
def skip_status(*skipped): """Decorator to skip this call if we're in one of the skipped states.""" def decorator(func): @functools.wraps(func) def _skip_status(self, *args, **kwargs): if self.status not in skipped: return func(self, *args, **kwargs) return _skip_status return decorator
python
def skip_status(*skipped): """Decorator to skip this call if we're in one of the skipped states.""" def decorator(func): @functools.wraps(func) def _skip_status(self, *args, **kwargs): if self.status not in skipped: return func(self, *args, **kwargs) return _skip_status return decorator
[ "def", "skip_status", "(", "*", "skipped", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_skip_status", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self",...
Decorator to skip this call if we're in one of the skipped states.
[ "Decorator", "to", "skip", "this", "call", "if", "we", "re", "in", "one", "of", "the", "skipped", "states", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L76-L84
train
Decorator to skip this call if we re in one of the skipped states.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
valid_status
def valid_status(*valid): """Decorator to assert that we're in a valid state.""" def decorator(func): @functools.wraps(func) def _valid_status(self, *args, **kwargs): if self.status not in valid: raise protocol.ProtocolError( "`%s` called while in state: %s, valid: (%s)" % ( ...
python
def valid_status(*valid): """Decorator to assert that we're in a valid state.""" def decorator(func): @functools.wraps(func) def _valid_status(self, *args, **kwargs): if self.status not in valid: raise protocol.ProtocolError( "`%s` called while in state: %s, valid: (%s)" % ( ...
[ "def", "valid_status", "(", "*", "valid", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_valid_status", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self",...
Decorator to assert that we're in a valid state.
[ "Decorator", "to", "assert", "that", "we", "re", "in", "a", "valid", "state", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L87-L98
train
Decorator to assert that we re in a valid state.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
catch_game_end
def catch_game_end(func): """Decorator to handle 'Game has already ended' exceptions.""" @functools.wraps(func) def _catch_game_end(self, *args, **kwargs): """Decorator to handle 'Game has already ended' exceptions.""" prev_status = self.status try: return func(self, *args, **kwargs) except ...
python
def catch_game_end(func): """Decorator to handle 'Game has already ended' exceptions.""" @functools.wraps(func) def _catch_game_end(self, *args, **kwargs): """Decorator to handle 'Game has already ended' exceptions.""" prev_status = self.status try: return func(self, *args, **kwargs) except ...
[ "def", "catch_game_end", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_catch_game_end", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Decorator to handle 'Game has already ended' exceptions.\"\"\"", ...
Decorator to handle 'Game has already ended' exceptions.
[ "Decorator", "to", "handle", "Game", "has", "already", "ended", "exceptions", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L101-L126
train
Decorator to catch Game has already ended exceptions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController._connect
def _connect(self, host, port, proc, timeout_seconds): """Connect to the websocket, retrying as needed. Returns the socket.""" if ":" in host and not host.startswith("["): # Support ipv6 addresses. host = "[%s]" % host url = "ws://%s:%s/sc2api" % (host, port) was_running = False for i in ran...
python
def _connect(self, host, port, proc, timeout_seconds): """Connect to the websocket, retrying as needed. Returns the socket.""" if ":" in host and not host.startswith("["): # Support ipv6 addresses. host = "[%s]" % host url = "ws://%s:%s/sc2api" % (host, port) was_running = False for i in ran...
[ "def", "_connect", "(", "self", ",", "host", ",", "port", ",", "proc", ",", "timeout_seconds", ")", ":", "if", "\":\"", "in", "host", "and", "not", "host", ".", "startswith", "(", "\"[\"", ")", ":", "# Support ipv6 addresses.", "host", "=", "\"[%s]\"", "...
Connect to the websocket, retrying as needed. Returns the socket.
[ "Connect", "to", "the", "websocket", "retrying", "as", "needed", ".", "Returns", "the", "socket", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L148-L174
train
Connect to the SC2 websocket.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.save_map
def save_map(self, map_path, map_data): """Save a map into temp dir so create game can access it in multiplayer.""" return self._client.send(save_map=sc_pb.RequestSaveMap( map_path=map_path, map_data=map_data))
python
def save_map(self, map_path, map_data): """Save a map into temp dir so create game can access it in multiplayer.""" return self._client.send(save_map=sc_pb.RequestSaveMap( map_path=map_path, map_data=map_data))
[ "def", "save_map", "(", "self", ",", "map_path", ",", "map_data", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "save_map", "=", "sc_pb", ".", "RequestSaveMap", "(", "map_path", "=", "map_path", ",", "map_data", "=", "map_data", ")", ")" ...
Save a map into temp dir so create game can access it in multiplayer.
[ "Save", "a", "map", "into", "temp", "dir", "so", "create", "game", "can", "access", "it", "in", "multiplayer", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L189-L192
train
Save a map into temp dir so create game can access it in multiplayer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.data_raw
def data_raw(self): """Get the raw static data for the current game. Prefer `data` instead.""" return self._client.send(data=sc_pb.RequestData( ability_id=True, unit_type_id=True))
python
def data_raw(self): """Get the raw static data for the current game. Prefer `data` instead.""" return self._client.send(data=sc_pb.RequestData( ability_id=True, unit_type_id=True))
[ "def", "data_raw", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "data", "=", "sc_pb", ".", "RequestData", "(", "ability_id", "=", "True", ",", "unit_type_id", "=", "True", ")", ")" ]
Get the raw static data for the current game. Prefer `data` instead.
[ "Get", "the", "raw", "static", "data", "for", "the", "current", "game", ".", "Prefer", "data", "instead", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L223-L226
train
Get the raw static data for the current game. Prefer data instead.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.step
def step(self, count=1): """Step the engine forward by one (or more) step.""" return self._client.send(step=sc_pb.RequestStep(count=count))
python
def step(self, count=1): """Step the engine forward by one (or more) step.""" return self._client.send(step=sc_pb.RequestStep(count=count))
[ "def", "step", "(", "self", ",", "count", "=", "1", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "step", "=", "sc_pb", ".", "RequestStep", "(", "count", "=", "count", ")", ")" ]
Step the engine forward by one (or more) step.
[ "Step", "the", "engine", "forward", "by", "one", "(", "or", "more", ")", "step", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L240-L242
train
Step the engine forward by one step.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.actions
def actions(self, req_action): """Send a `sc_pb.RequestAction`, which may include multiple actions.""" if FLAGS.sc2_log_actions: for action in req_action.actions: sys.stderr.write(str(action)) sys.stderr.flush() return self._client.send(action=req_action)
python
def actions(self, req_action): """Send a `sc_pb.RequestAction`, which may include multiple actions.""" if FLAGS.sc2_log_actions: for action in req_action.actions: sys.stderr.write(str(action)) sys.stderr.flush() return self._client.send(action=req_action)
[ "def", "actions", "(", "self", ",", "req_action", ")", ":", "if", "FLAGS", ".", "sc2_log_actions", ":", "for", "action", "in", "req_action", ".", "actions", ":", "sys", ".", "stderr", ".", "write", "(", "str", "(", "action", ")", ")", "sys", ".", "st...
Send a `sc_pb.RequestAction`, which may include multiple actions.
[ "Send", "a", "sc_pb", ".", "RequestAction", "which", "may", "include", "multiple", "actions", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L248-L255
train
Send a sc_pb. RequestAction which may include multiple actions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.act
def act(self, action): """Send a single action. This is a shortcut for `actions`.""" if action and action.ListFields(): # Skip no-ops. return self.actions(sc_pb.RequestAction(actions=[action]))
python
def act(self, action): """Send a single action. This is a shortcut for `actions`.""" if action and action.ListFields(): # Skip no-ops. return self.actions(sc_pb.RequestAction(actions=[action]))
[ "def", "act", "(", "self", ",", "action", ")", ":", "if", "action", "and", "action", ".", "ListFields", "(", ")", ":", "# Skip no-ops.", "return", "self", ".", "actions", "(", "sc_pb", ".", "RequestAction", "(", "actions", "=", "[", "action", "]", ")",...
Send a single action. This is a shortcut for `actions`.
[ "Send", "a", "single", "action", ".", "This", "is", "a", "shortcut", "for", "actions", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L257-L260
train
Send a single action. This is a shortcut for actions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.chat
def chat(self, message): """Send chat message as a broadcast.""" if message: action_chat = sc_pb.ActionChat( channel=sc_pb.ActionChat.Broadcast, message=message) action = sc_pb.Action(action_chat=action_chat) return self.act(action)
python
def chat(self, message): """Send chat message as a broadcast.""" if message: action_chat = sc_pb.ActionChat( channel=sc_pb.ActionChat.Broadcast, message=message) action = sc_pb.Action(action_chat=action_chat) return self.act(action)
[ "def", "chat", "(", "self", ",", "message", ")", ":", "if", "message", ":", "action_chat", "=", "sc_pb", ".", "ActionChat", "(", "channel", "=", "sc_pb", ".", "ActionChat", ".", "Broadcast", ",", "message", "=", "message", ")", "action", "=", "sc_pb", ...
Send chat message as a broadcast.
[ "Send", "chat", "message", "as", "a", "broadcast", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L262-L268
train
Send chat message as a broadcast.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.save_replay
def save_replay(self): """Save a replay, returning the data.""" res = self._client.send(save_replay=sc_pb.RequestSaveReplay()) return res.data
python
def save_replay(self): """Save a replay, returning the data.""" res = self._client.send(save_replay=sc_pb.RequestSaveReplay()) return res.data
[ "def", "save_replay", "(", "self", ")", ":", "res", "=", "self", ".", "_client", ".", "send", "(", "save_replay", "=", "sc_pb", ".", "RequestSaveReplay", "(", ")", ")", "return", "res", ".", "data" ]
Save a replay, returning the data.
[ "Save", "a", "replay", "returning", "the", "data", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L278-L281
train
Save a replay returning the data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.debug
def debug(self, debug_commands): """Run a debug command.""" if isinstance(debug_commands, sc_debug.DebugCommand): debug_commands = [debug_commands] return self._client.send(debug=sc_pb.RequestDebug(debug=debug_commands))
python
def debug(self, debug_commands): """Run a debug command.""" if isinstance(debug_commands, sc_debug.DebugCommand): debug_commands = [debug_commands] return self._client.send(debug=sc_pb.RequestDebug(debug=debug_commands))
[ "def", "debug", "(", "self", ",", "debug_commands", ")", ":", "if", "isinstance", "(", "debug_commands", ",", "sc_debug", ".", "DebugCommand", ")", ":", "debug_commands", "=", "[", "debug_commands", "]", "return", "self", ".", "_client", ".", "send", "(", ...
Run a debug command.
[ "Run", "a", "debug", "command", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L285-L289
train
Run a debug command.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/remote_controller.py
RemoteController.quit
def quit(self): """Shut down the SC2 process.""" try: # Don't expect a response. self._client.write(sc_pb.Request(quit=sc_pb.RequestQuit())) except protocol.ConnectionError: pass # It's likely already (shutting) down, so continue as if it worked. finally: self.close()
python
def quit(self): """Shut down the SC2 process.""" try: # Don't expect a response. self._client.write(sc_pb.Request(quit=sc_pb.RequestQuit())) except protocol.ConnectionError: pass # It's likely already (shutting) down, so continue as if it worked. finally: self.close()
[ "def", "quit", "(", "self", ")", ":", "try", ":", "# Don't expect a response.", "self", ".", "_client", ".", "write", "(", "sc_pb", ".", "Request", "(", "quit", "=", "sc_pb", ".", "RequestQuit", "(", ")", ")", ")", "except", "protocol", ".", "ConnectionE...
Shut down the SC2 process.
[ "Shut", "down", "the", "SC2", "process", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L293-L301
train
Shut down the SC2 process.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/run_loop.py
run_loop
def run_loop(agents, env, max_frames=0, max_episodes=0): """A run loop to have agents and an environment interact.""" total_frames = 0 total_episodes = 0 start_time = time.time() observation_spec = env.observation_spec() action_spec = env.action_spec() for agent, obs_spec, act_spec in zip(agents, observa...
python
def run_loop(agents, env, max_frames=0, max_episodes=0): """A run loop to have agents and an environment interact.""" total_frames = 0 total_episodes = 0 start_time = time.time() observation_spec = env.observation_spec() action_spec = env.action_spec() for agent, obs_spec, act_spec in zip(agents, observa...
[ "def", "run_loop", "(", "agents", ",", "env", ",", "max_frames", "=", "0", ",", "max_episodes", "=", "0", ")", ":", "total_frames", "=", "0", "total_episodes", "=", "0", "start_time", "=", "time", ".", "time", "(", ")", "observation_spec", "=", "env", ...
A run loop to have agents and an environment interact.
[ "A", "run", "loop", "to", "have", "agents", "and", "an", "environment", "interact", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/run_loop.py#L23-L54
train
A run loop to have agents and an environment interact.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/lib.py
RunConfig.map_data
def map_data(self, map_name): """Return the map data for a map by name or path.""" with gfile.Open(os.path.join(self.data_dir, "Maps", map_name), "rb") as f: return f.read()
python
def map_data(self, map_name): """Return the map data for a map by name or path.""" with gfile.Open(os.path.join(self.data_dir, "Maps", map_name), "rb") as f: return f.read()
[ "def", "map_data", "(", "self", ",", "map_name", ")", ":", "with", "gfile", ".", "Open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "data_dir", ",", "\"Maps\"", ",", "map_name", ")", ",", "\"rb\"", ")", "as", "f", ":", "return", "f", ...
Return the map data for a map by name or path.
[ "Return", "the", "map", "data", "for", "a", "map", "by", "name", "or", "path", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L101-L104
train
Return the map data for a map by name or path.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/lib.py
RunConfig.replay_data
def replay_data(self, replay_path): """Return the replay data given a path to the replay.""" with gfile.Open(self.abs_replay_path(replay_path), "rb") as f: return f.read()
python
def replay_data(self, replay_path): """Return the replay data given a path to the replay.""" with gfile.Open(self.abs_replay_path(replay_path), "rb") as f: return f.read()
[ "def", "replay_data", "(", "self", ",", "replay_path", ")", ":", "with", "gfile", ".", "Open", "(", "self", ".", "abs_replay_path", "(", "replay_path", ")", ",", "\"rb\"", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Return the replay data given a path to the replay.
[ "Return", "the", "replay", "data", "given", "a", "path", "to", "the", "replay", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L110-L113
train
Return the replay data given a path to the replay.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/lib.py
RunConfig.replay_paths
def replay_paths(self, replay_dir): """A generator yielding the full path to the replays under `replay_dir`.""" replay_dir = self.abs_replay_path(replay_dir) if replay_dir.lower().endswith(".sc2replay"): yield replay_dir return for f in gfile.ListDir(replay_dir): if f.lower().endswith(...
python
def replay_paths(self, replay_dir): """A generator yielding the full path to the replays under `replay_dir`.""" replay_dir = self.abs_replay_path(replay_dir) if replay_dir.lower().endswith(".sc2replay"): yield replay_dir return for f in gfile.ListDir(replay_dir): if f.lower().endswith(...
[ "def", "replay_paths", "(", "self", ",", "replay_dir", ")", ":", "replay_dir", "=", "self", ".", "abs_replay_path", "(", "replay_dir", ")", "if", "replay_dir", ".", "lower", "(", ")", ".", "endswith", "(", "\".sc2replay\"", ")", ":", "yield", "replay_dir", ...
A generator yielding the full path to the replays under `replay_dir`.
[ "A", "generator", "yielding", "the", "full", "path", "to", "the", "replays", "under", "replay_dir", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L115-L123
train
A generator yielding the full path to the replays under replay_dir.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/lib.py
RunConfig.save_replay
def save_replay(self, replay_data, replay_dir, prefix=None): """Save a replay to a directory, returning the path to the replay. Args: replay_data: The result of controller.save_replay(), ie the binary data. replay_dir: Where to save the replay. This can be absolute or relative. prefix: Option...
python
def save_replay(self, replay_data, replay_dir, prefix=None): """Save a replay to a directory, returning the path to the replay. Args: replay_data: The result of controller.save_replay(), ie the binary data. replay_dir: Where to save the replay. This can be absolute or relative. prefix: Option...
[ "def", "save_replay", "(", "self", ",", "replay_data", ",", "replay_dir", ",", "prefix", "=", "None", ")", ":", "if", "not", "prefix", ":", "replay_filename", "=", "\"\"", "elif", "os", ".", "path", ".", "sep", "in", "prefix", ":", "raise", "ValueError",...
Save a replay to a directory, returning the path to the replay. Args: replay_data: The result of controller.save_replay(), ie the binary data. replay_dir: Where to save the replay. This can be absolute or relative. prefix: Optional prefix for the replay filename. Returns: The full path...
[ "Save", "a", "replay", "to", "a", "directory", "returning", "the", "path", "to", "the", "replay", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L125-L154
train
Save a replay to a directory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/lib.py
RunConfig.all_subclasses
def all_subclasses(cls): """An iterator over all subclasses of `cls`.""" for s in cls.__subclasses__(): yield s for c in s.all_subclasses(): yield c
python
def all_subclasses(cls): """An iterator over all subclasses of `cls`.""" for s in cls.__subclasses__(): yield s for c in s.all_subclasses(): yield c
[ "def", "all_subclasses", "(", "cls", ")", ":", "for", "s", "in", "cls", ".", "__subclasses__", "(", ")", ":", "yield", "s", "for", "c", "in", "s", ".", "all_subclasses", "(", ")", ":", "yield", "c" ]
An iterator over all subclasses of `cls`.
[ "An", "iterator", "over", "all", "subclasses", "of", "cls", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L161-L166
train
An iterator over all subclasses of cls.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/named_array.py
NamedNumpyArray._indices
def _indices(self, indices): """Turn all string indices into int indices, preserving ellipsis.""" if isinstance(indices, tuple): out = [] dim = 0 for i, index in enumerate(indices): if index is Ellipsis: out.append(index) dim = len(self.shape) - len(indices) + i ...
python
def _indices(self, indices): """Turn all string indices into int indices, preserving ellipsis.""" if isinstance(indices, tuple): out = [] dim = 0 for i, index in enumerate(indices): if index is Ellipsis: out.append(index) dim = len(self.shape) - len(indices) + i ...
[ "def", "_indices", "(", "self", ",", "indices", ")", ":", "if", "isinstance", "(", "indices", ",", "tuple", ")", ":", "out", "=", "[", "]", "dim", "=", "0", "for", "i", ",", "index", "in", "enumerate", "(", "indices", ")", ":", "if", "index", "is...
Turn all string indices into int indices, preserving ellipsis.
[ "Turn", "all", "string", "indices", "into", "int", "indices", "preserving", "ellipsis", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/named_array.py#L231-L245
train
Turn all string indices into int indices preserving ellipsis.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/named_array.py
NamedNumpyArray._get_index
def _get_index(self, dim, index): """Turn a string into a real index, otherwise return the index.""" if isinstance(index, six.string_types): try: return self._index_names[dim][index] except KeyError: raise KeyError("Name '%s' is invalid for axis %s." % (index, dim)) except Type...
python
def _get_index(self, dim, index): """Turn a string into a real index, otherwise return the index.""" if isinstance(index, six.string_types): try: return self._index_names[dim][index] except KeyError: raise KeyError("Name '%s' is invalid for axis %s." % (index, dim)) except Type...
[ "def", "_get_index", "(", "self", ",", "dim", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "six", ".", "string_types", ")", ":", "try", ":", "return", "self", ".", "_index_names", "[", "dim", "]", "[", "index", "]", "except", "KeyEr...
Turn a string into a real index, otherwise return the index.
[ "Turn", "a", "string", "into", "a", "real", "index", "otherwise", "return", "the", "index", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/named_array.py#L247-L258
train
Turn a string into a real index otherwise return the index.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.assign_to
def assign_to(self, obj): """Assign `x` and `y` to an object that has properties `x` and `y`.""" obj.x = self.x obj.y = self.y
python
def assign_to(self, obj): """Assign `x` and `y` to an object that has properties `x` and `y`.""" obj.x = self.x obj.y = self.y
[ "def", "assign_to", "(", "self", ",", "obj", ")", ":", "obj", ".", "x", "=", "self", ".", "x", "obj", ".", "y", "=", "self", ".", "y" ]
Assign `x` and `y` to an object that has properties `x` and `y`.
[ "Assign", "x", "and", "y", "to", "an", "object", "that", "has", "properties", "x", "and", "y", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L39-L42
train
Assign x and y to an object that has properties x and y.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.dist
def dist(self, other): """Distance to some other point.""" dx = self.x - other.x dy = self.y - other.y return math.sqrt(dx**2 + dy**2)
python
def dist(self, other): """Distance to some other point.""" dx = self.x - other.x dy = self.y - other.y return math.sqrt(dx**2 + dy**2)
[ "def", "dist", "(", "self", ",", "other", ")", ":", "dx", "=", "self", ".", "x", "-", "other", ".", "x", "dy", "=", "self", ".", "y", "-", "other", ".", "y", "return", "math", ".", "sqrt", "(", "dx", "**", "2", "+", "dy", "**", "2", ")" ]
Distance to some other point.
[ "Distance", "to", "some", "other", "point", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L44-L48
train
Distance to some other point.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.dist_sq
def dist_sq(self, other): """Distance squared to some other point.""" dx = self.x - other.x dy = self.y - other.y return dx**2 + dy**2
python
def dist_sq(self, other): """Distance squared to some other point.""" dx = self.x - other.x dy = self.y - other.y return dx**2 + dy**2
[ "def", "dist_sq", "(", "self", ",", "other", ")", ":", "dx", "=", "self", ".", "x", "-", "other", ".", "x", "dy", "=", "self", ".", "y", "-", "other", ".", "y", "return", "dx", "**", "2", "+", "dy", "**", "2" ]
Distance squared to some other point.
[ "Distance", "squared", "to", "some", "other", "point", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L50-L54
train
Distance squared to some other point.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.round
def round(self): """Round `x` and `y` to integers.""" return Point(int(round(self.x)), int(round(self.y)))
python
def round(self): """Round `x` and `y` to integers.""" return Point(int(round(self.x)), int(round(self.y)))
[ "def", "round", "(", "self", ")", ":", "return", "Point", "(", "int", "(", "round", "(", "self", ".", "x", ")", ")", ",", "int", "(", "round", "(", "self", ".", "y", ")", ")", ")" ]
Round `x` and `y` to integers.
[ "Round", "x", "and", "y", "to", "integers", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L56-L58
train
Round x and y to integers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.floor
def floor(self): """Round `x` and `y` down to integers.""" return Point(int(math.floor(self.x)), int(math.floor(self.y)))
python
def floor(self): """Round `x` and `y` down to integers.""" return Point(int(math.floor(self.x)), int(math.floor(self.y)))
[ "def", "floor", "(", "self", ")", ":", "return", "Point", "(", "int", "(", "math", ".", "floor", "(", "self", ".", "x", ")", ")", ",", "int", "(", "math", ".", "floor", "(", "self", ".", "y", ")", ")", ")" ]
Round `x` and `y` down to integers.
[ "Round", "x", "and", "y", "down", "to", "integers", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L60-L62
train
Round x and y down to integers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.ceil
def ceil(self): """Round `x` and `y` up to integers.""" return Point(int(math.ceil(self.x)), int(math.ceil(self.y)))
python
def ceil(self): """Round `x` and `y` up to integers.""" return Point(int(math.ceil(self.x)), int(math.ceil(self.y)))
[ "def", "ceil", "(", "self", ")", ":", "return", "Point", "(", "int", "(", "math", ".", "ceil", "(", "self", ".", "x", ")", ")", ",", "int", "(", "math", ".", "ceil", "(", "self", ".", "y", ")", ")", ")" ]
Round `x` and `y` up to integers.
[ "Round", "x", "and", "y", "up", "to", "integers", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L64-L66
train
Round x and y up to integers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Point.bound
def bound(self, p1, p2=None): """Bound this point within the rect defined by (`p1`, `p2`).""" r = Rect(p1, p2) return Point(min(max(self.x, r.l), r.r), min(max(self.y, r.t), r.b))
python
def bound(self, p1, p2=None): """Bound this point within the rect defined by (`p1`, `p2`).""" r = Rect(p1, p2) return Point(min(max(self.x, r.l), r.r), min(max(self.y, r.t), r.b))
[ "def", "bound", "(", "self", ",", "p1", ",", "p2", "=", "None", ")", ":", "r", "=", "Rect", "(", "p1", ",", "p2", ")", "return", "Point", "(", "min", "(", "max", "(", "self", ".", "x", ",", "r", ".", "l", ")", ",", "r", ".", "r", ")", "...
Bound this point within the rect defined by (`p1`, `p2`).
[ "Bound", "this", "point", "within", "the", "rect", "defined", "by", "(", "p1", "p2", ")", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L112-L115
train
Bound this point within the rect defined by p1 and p2.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Rect.contains_point
def contains_point(self, pt): """Is the point inside this rect?""" return (self.l < pt.x and self.r > pt.x and self.t < pt.y and self.b > pt.y)
python
def contains_point(self, pt): """Is the point inside this rect?""" return (self.l < pt.x and self.r > pt.x and self.t < pt.y and self.b > pt.y)
[ "def", "contains_point", "(", "self", ",", "pt", ")", ":", "return", "(", "self", ".", "l", "<", "pt", ".", "x", "and", "self", ".", "r", ">", "pt", ".", "x", "and", "self", ".", "t", "<", "pt", ".", "y", "and", "self", ".", "b", ">", "pt",...
Is the point inside this rect?
[ "Is", "the", "point", "inside", "this", "rect?" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L239-L242
train
Is the point inside this rect?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Rect.contains_circle
def contains_circle(self, pt, radius): """Is the circle completely inside this rect?""" return (self.l < pt.x - radius and self.r > pt.x + radius and self.t < pt.y - radius and self.b > pt.y + radius)
python
def contains_circle(self, pt, radius): """Is the circle completely inside this rect?""" return (self.l < pt.x - radius and self.r > pt.x + radius and self.t < pt.y - radius and self.b > pt.y + radius)
[ "def", "contains_circle", "(", "self", ",", "pt", ",", "radius", ")", ":", "return", "(", "self", ".", "l", "<", "pt", ".", "x", "-", "radius", "and", "self", ".", "r", ">", "pt", ".", "x", "+", "radius", "and", "self", ".", "t", "<", "pt", "...
Is the circle completely inside this rect?
[ "Is", "the", "circle", "completely", "inside", "this", "rect?" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L244-L247
train
Is the circle completely inside this rect?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/point.py
Rect.intersects_circle
def intersects_circle(self, pt, radius): """Does the circle intersect with this rect?""" # How this works: http://stackoverflow.com/a/402010 rect_corner = self.size / 2 # relative to the rect center circle_center = (pt - self.center).abs() # relative to the rect center # Is the circle far from th...
python
def intersects_circle(self, pt, radius): """Does the circle intersect with this rect?""" # How this works: http://stackoverflow.com/a/402010 rect_corner = self.size / 2 # relative to the rect center circle_center = (pt - self.center).abs() # relative to the rect center # Is the circle far from th...
[ "def", "intersects_circle", "(", "self", ",", "pt", ",", "radius", ")", ":", "# How this works: http://stackoverflow.com/a/402010", "rect_corner", "=", "self", ".", "size", "/", "2", "# relative to the rect center", "circle_center", "=", "(", "pt", "-", "self", ".",...
Does the circle intersect with this rect?
[ "Does", "the", "circle", "intersect", "with", "this", "rect?" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L249-L266
train
Returns True if the circle intersects with this rect.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/platforms.py
_read_execute_info
def _read_execute_info(path, parents): """Read the ExecuteInfo.txt file and return the base directory.""" path = os.path.join(path, "StarCraft II/ExecuteInfo.txt") if os.path.exists(path): with open(path, "rb") as f: # Binary because the game appends a '\0' :(. for line in f: parts = [p.strip()...
python
def _read_execute_info(path, parents): """Read the ExecuteInfo.txt file and return the base directory.""" path = os.path.join(path, "StarCraft II/ExecuteInfo.txt") if os.path.exists(path): with open(path, "rb") as f: # Binary because the game appends a '\0' :(. for line in f: parts = [p.strip()...
[ "def", "_read_execute_info", "(", "path", ",", "parents", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "\"StarCraft II/ExecuteInfo.txt\"", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "with", "open", "...
Read the ExecuteInfo.txt file and return the base directory.
[ "Read", "the", "ExecuteInfo", ".", "txt", "file", "and", "return", "the", "base", "directory", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/platforms.py#L41-L52
train
Read the ExecuteInfo. txt file and return the base directory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/platforms.py
LocalBase.start
def start(self, version=None, want_rgb=True, **kwargs): """Launch the game.""" del want_rgb # Unused if not os.path.isdir(self.data_dir): raise sc_process.SC2LaunchError( "Expected to find StarCraft II installed at '%s'. If it's not " "installed, do that and run it once so auto-de...
python
def start(self, version=None, want_rgb=True, **kwargs): """Launch the game.""" del want_rgb # Unused if not os.path.isdir(self.data_dir): raise sc_process.SC2LaunchError( "Expected to find StarCraft II installed at '%s'. If it's not " "installed, do that and run it once so auto-de...
[ "def", "start", "(", "self", ",", "version", "=", "None", ",", "want_rgb", "=", "True", ",", "*", "*", "kwargs", ")", ":", "del", "want_rgb", "# Unused", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "data_dir", ")", ":", "raise",...
Launch the game.
[ "Launch", "the", "game", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/platforms.py#L66-L97
train
Launch the game.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/host_remote_agent.py
VsAgent.create_game
def create_game(self, map_name): """Create a game for the agents to join. Args: map_name: The map to use. """ map_inst = maps.get(map_name) map_data = map_inst.data(self._run_config) if map_name not in self._saved_maps: for controller in self._controllers: controller.save_ma...
python
def create_game(self, map_name): """Create a game for the agents to join. Args: map_name: The map to use. """ map_inst = maps.get(map_name) map_data = map_inst.data(self._run_config) if map_name not in self._saved_maps: for controller in self._controllers: controller.save_ma...
[ "def", "create_game", "(", "self", ",", "map_name", ")", ":", "map_inst", "=", "maps", ".", "get", "(", "map_name", ")", "map_data", "=", "map_inst", ".", "data", "(", "self", ".", "_run_config", ")", "if", "map_name", "not", "in", "self", ".", "_saved...
Create a game for the agents to join. Args: map_name: The map to use.
[ "Create", "a", "game", "for", "the", "agents", "to", "join", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L71-L94
train
Create a game for the agents to join.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/host_remote_agent.py
VsAgent.close
def close(self): """Shutdown and free all resources.""" for controller in self._controllers: controller.quit() self._controllers = [] for process in self._processes: process.close() self._processes = [] portspicker.return_ports(self._lan_ports) self._lan_ports = []
python
def close(self): """Shutdown and free all resources.""" for controller in self._controllers: controller.quit() self._controllers = [] for process in self._processes: process.close() self._processes = [] portspicker.return_ports(self._lan_ports) self._lan_ports = []
[ "def", "close", "(", "self", ")", ":", "for", "controller", "in", "self", ".", "_controllers", ":", "controller", ".", "quit", "(", ")", "self", ".", "_controllers", "=", "[", "]", "for", "process", "in", "self", ".", "_processes", ":", "process", ".",...
Shutdown and free all resources.
[ "Shutdown", "and", "free", "all", "resources", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L111-L122
train
Shutdown and free all resources.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/host_remote_agent.py
VsBot.create_game
def create_game( self, map_name, bot_difficulty=sc_pb.VeryEasy, bot_race=sc_common.Random, bot_first=False): """Create a game, one remote agent vs the specified bot. Args: map_name: The map to use. bot_difficulty: The difficulty of the bot to play against. bot_ra...
python
def create_game( self, map_name, bot_difficulty=sc_pb.VeryEasy, bot_race=sc_common.Random, bot_first=False): """Create a game, one remote agent vs the specified bot. Args: map_name: The map to use. bot_difficulty: The difficulty of the bot to play against. bot_ra...
[ "def", "create_game", "(", "self", ",", "map_name", ",", "bot_difficulty", "=", "sc_pb", ".", "VeryEasy", ",", "bot_race", "=", "sc_common", ".", "Random", ",", "bot_first", "=", "False", ")", ":", "self", ".", "_controller", ".", "ping", "(", ")", "# Fo...
Create a game, one remote agent vs the specified bot. Args: map_name: The map to use. bot_difficulty: The difficulty of the bot to play against. bot_race: The race for the bot. bot_first: Whether the bot should be player 1 (else is player 2).
[ "Create", "a", "game", "one", "remote", "agent", "vs", "the", "specified", "bot", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L158-L196
train
Create a game for one remote agent vs the specified bot.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/host_remote_agent.py
VsBot.close
def close(self): """Shutdown and free all resources.""" if self._controller is not None: self._controller.quit() self._controller = None if self._process is not None: self._process.close() self._process = None
python
def close(self): """Shutdown and free all resources.""" if self._controller is not None: self._controller.quit() self._controller = None if self._process is not None: self._process.close() self._process = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_controller", "is", "not", "None", ":", "self", ".", "_controller", ".", "quit", "(", ")", "self", ".", "_controller", "=", "None", "if", "self", ".", "_process", "is", "not", "None", ":", ...
Shutdown and free all resources.
[ "Shutdown", "and", "free", "all", "resources", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L208-L215
train
Shutdown and free all resources.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/play_vs_agent.py
agent
def agent(): """Run the agent, connecting to a (remote) host started independently.""" agent_module, agent_name = FLAGS.agent.rsplit(".", 1) agent_cls = getattr(importlib.import_module(agent_module), agent_name) logging.info("Starting agent:") with lan_sc2_env.LanSC2Env( host=FLAGS.host, config_p...
python
def agent(): """Run the agent, connecting to a (remote) host started independently.""" agent_module, agent_name = FLAGS.agent.rsplit(".", 1) agent_cls = getattr(importlib.import_module(agent_module), agent_name) logging.info("Starting agent:") with lan_sc2_env.LanSC2Env( host=FLAGS.host, config_p...
[ "def", "agent", "(", ")", ":", "agent_module", ",", "agent_name", "=", "FLAGS", ".", "agent", ".", "rsplit", "(", "\".\"", ",", "1", ")", "agent_cls", "=", "getattr", "(", "importlib", ".", "import_module", "(", "agent_module", ")", ",", "agent_name", ")...
Run the agent, connecting to a (remote) host started independently.
[ "Run", "the", "agent", "connecting", "to", "a", "(", "remote", ")", "host", "started", "independently", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/play_vs_agent.py#L118-L143
train
Run the agent connecting to a remote host.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/play_vs_agent.py
human
def human(): """Run a host which expects one player to connect remotely.""" run_config = run_configs.get() map_inst = maps.get(FLAGS.map) if not FLAGS.rgb_screen_size or not FLAGS.rgb_minimap_size: logging.info("Use --rgb_screen_size and --rgb_minimap_size if you want rgb " "observations....
python
def human(): """Run a host which expects one player to connect remotely.""" run_config = run_configs.get() map_inst = maps.get(FLAGS.map) if not FLAGS.rgb_screen_size or not FLAGS.rgb_minimap_size: logging.info("Use --rgb_screen_size and --rgb_minimap_size if you want rgb " "observations....
[ "def", "human", "(", ")", ":", "run_config", "=", "run_configs", ".", "get", "(", ")", "map_inst", "=", "maps", ".", "get", "(", "FLAGS", ".", "map", ")", "if", "not", "FLAGS", ".", "rgb_screen_size", "or", "not", "FLAGS", ".", "rgb_minimap_size", ":",...
Run a host which expects one player to connect remotely.
[ "Run", "a", "host", "which", "expects", "one", "player", "to", "connect", "remotely", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/play_vs_agent.py#L146-L269
train
Run a host which expects one player to connect remotely.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/remote_sc2_env.py
RemoteSC2Env._connect_remote
def _connect_remote(self, host, host_port, lan_ports, race, name, map_inst, save_map, interface): """Make sure this stays synced with bin/agent_remote.py.""" # Connect! logging.info("Connecting...") self._controllers = [remote_controller.RemoteController(host, host_port)] loggi...
python
def _connect_remote(self, host, host_port, lan_ports, race, name, map_inst, save_map, interface): """Make sure this stays synced with bin/agent_remote.py.""" # Connect! logging.info("Connecting...") self._controllers = [remote_controller.RemoteController(host, host_port)] loggi...
[ "def", "_connect_remote", "(", "self", ",", "host", ",", "host_port", ",", "lan_ports", ",", "race", ",", "name", ",", "map_inst", ",", "save_map", ",", "interface", ")", ":", "# Connect!", "logging", ".", "info", "(", "\"Connecting...\"", ")", "self", "."...
Make sure this stays synced with bin/agent_remote.py.
[ "Make", "sure", "this", "stays", "synced", "with", "bin", "/", "agent_remote", ".", "py", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/remote_sc2_env.py#L189-L214
train
Connect to the remote controller.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/run_configs/__init__.py
get
def get(): """Get the config chosen by the flags.""" configs = {c.name(): c for c in lib.RunConfig.all_subclasses() if c.priority()} if not configs: raise sc_process.SC2LaunchError("No valid run_configs found.") if FLAGS.sc2_run_config is None: # Find the highest priority as default. ret...
python
def get(): """Get the config chosen by the flags.""" configs = {c.name(): c for c in lib.RunConfig.all_subclasses() if c.priority()} if not configs: raise sc_process.SC2LaunchError("No valid run_configs found.") if FLAGS.sc2_run_config is None: # Find the highest priority as default. ret...
[ "def", "get", "(", ")", ":", "configs", "=", "{", "c", ".", "name", "(", ")", ":", "c", "for", "c", "in", "lib", ".", "RunConfig", ".", "all_subclasses", "(", ")", "if", "c", ".", "priority", "(", ")", "}", "if", "not", "configs", ":", "raise",...
Get the config chosen by the flags.
[ "Get", "the", "config", "chosen", "by", "the", "flags", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/__init__.py#L31-L47
train
Get the config chosen by the flags.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/sc2_env.py
SC2Env.reset
def reset(self): """Start a new episode.""" self._episode_steps = 0 if self._episode_count: # No need to restart for the first episode. self._restart() self._episode_count += 1 logging.info("Starting episode: %s", self._episode_count) self._metrics.increment_episode() self._las...
python
def reset(self): """Start a new episode.""" self._episode_steps = 0 if self._episode_count: # No need to restart for the first episode. self._restart() self._episode_count += 1 logging.info("Starting episode: %s", self._episode_count) self._metrics.increment_episode() self._las...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_episode_steps", "=", "0", "if", "self", ".", "_episode_count", ":", "# No need to restart for the first episode.", "self", ".", "_restart", "(", ")", "self", ".", "_episode_count", "+=", "1", "logging", "."...
Start a new episode.
[ "Start", "a", "new", "episode", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/sc2_env.py#L454-L471
train
Start a new episode.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/sc2_env.py
SC2Env.step
def step(self, actions, step_mul=None): """Apply actions, step the world forward, and return observations. Args: actions: A list of actions meeting the action spec, one per agent. step_mul: If specified, use this rather than the environment's default. Returns: A tuple of TimeStep namedtu...
python
def step(self, actions, step_mul=None): """Apply actions, step the world forward, and return observations. Args: actions: A list of actions meeting the action spec, one per agent. step_mul: If specified, use this rather than the environment's default. Returns: A tuple of TimeStep namedtu...
[ "def", "step", "(", "self", ",", "actions", ",", "step_mul", "=", "None", ")", ":", "if", "self", ".", "_state", "==", "environment", ".", "StepType", ".", "LAST", ":", "return", "self", ".", "reset", "(", ")", "skip", "=", "not", "self", ".", "_en...
Apply actions, step the world forward, and return observations. Args: actions: A list of actions meeting the action spec, one per agent. step_mul: If specified, use this rather than the environment's default. Returns: A tuple of TimeStep namedtuples, one per agent.
[ "Apply", "actions", "step", "the", "world", "forward", "and", "return", "observations", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/sc2_env.py#L474-L494
train
Apply actions step the world forward and return observations.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/sc2_env.py
SC2Env.send_chat_messages
def send_chat_messages(self, messages): """Useful for logging messages into the replay.""" self._parallel.run( (c.chat, message) for c, message in zip(self._controllers, messages))
python
def send_chat_messages(self, messages): """Useful for logging messages into the replay.""" self._parallel.run( (c.chat, message) for c, message in zip(self._controllers, messages))
[ "def", "send_chat_messages", "(", "self", ",", "messages", ")", ":", "self", ".", "_parallel", ".", "run", "(", "(", "c", ".", "chat", ",", "message", ")", "for", "c", ",", "message", "in", "zip", "(", "self", ".", "_controllers", ",", "messages", ")...
Useful for logging messages into the replay.
[ "Useful", "for", "logging", "messages", "into", "the", "replay", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/sc2_env.py#L642-L645
train
Send a list of messages to the chat.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_actions.py
valid_replay
def valid_replay(info, ping): """Make sure the replay isn't corrupt, and is worth looking at.""" if (info.HasField("error") or info.base_build != ping.base_build or # different game version info.game_duration_loops < 1000 or len(info.player_info) != 2): # Probably corrupt, or just not interes...
python
def valid_replay(info, ping): """Make sure the replay isn't corrupt, and is worth looking at.""" if (info.HasField("error") or info.base_build != ping.base_build or # different game version info.game_duration_loops < 1000 or len(info.player_info) != 2): # Probably corrupt, or just not interes...
[ "def", "valid_replay", "(", "info", ",", "ping", ")", ":", "if", "(", "info", ".", "HasField", "(", "\"error\"", ")", "or", "info", ".", "base_build", "!=", "ping", ".", "base_build", "or", "# different game version", "info", ".", "game_duration_loops", "<",...
Make sure the replay isn't corrupt, and is worth looking at.
[ "Make", "sure", "the", "replay", "isn", "t", "corrupt", "and", "is", "worth", "looking", "at", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L150-L163
train
Make sure the replay isn t corrupt and is worth looking at.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_actions.py
stats_printer
def stats_printer(stats_queue): """A thread that consumes stats_queue and prints them every 10 seconds.""" proc_stats = [ProcessStats(i) for i in range(FLAGS.parallel)] print_time = start_time = time.time() width = 107 running = True while running: print_time += 10 while time.time() < print_time: ...
python
def stats_printer(stats_queue): """A thread that consumes stats_queue and prints them every 10 seconds.""" proc_stats = [ProcessStats(i) for i in range(FLAGS.parallel)] print_time = start_time = time.time() width = 107 running = True while running: print_time += 10 while time.time() < print_time: ...
[ "def", "stats_printer", "(", "stats_queue", ")", ":", "proc_stats", "=", "[", "ProcessStats", "(", "i", ")", "for", "i", "in", "range", "(", "FLAGS", ".", "parallel", ")", "]", "print_time", "=", "start_time", "=", "time", ".", "time", "(", ")", "width...
A thread that consumes stats_queue and prints them every 10 seconds.
[ "A", "thread", "that", "consumes", "stats_queue", "and", "prints", "them", "every", "10", "seconds", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L295-L323
train
A thread that consumes stats_queue and prints them every 10 seconds.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_actions.py
main
def main(unused_argv): """Dump stats about all the actions that are in use in a set of replays.""" run_config = run_configs.get() if not gfile.Exists(FLAGS.replays): sys.exit("{} doesn't exist.".format(FLAGS.replays)) stats_queue = multiprocessing.Queue() stats_thread = threading.Thread(target=stats_pri...
python
def main(unused_argv): """Dump stats about all the actions that are in use in a set of replays.""" run_config = run_configs.get() if not gfile.Exists(FLAGS.replays): sys.exit("{} doesn't exist.".format(FLAGS.replays)) stats_queue = multiprocessing.Queue() stats_thread = threading.Thread(target=stats_pri...
[ "def", "main", "(", "unused_argv", ")", ":", "run_config", "=", "run_configs", ".", "get", "(", ")", "if", "not", "gfile", ".", "Exists", "(", "FLAGS", ".", "replays", ")", ":", "sys", ".", "exit", "(", "\"{} doesn't exist.\"", ".", "format", "(", "FLA...
Dump stats about all the actions that are in use in a set of replays.
[ "Dump", "stats", "about", "all", "the", "actions", "that", "are", "in", "use", "in", "a", "set", "of", "replays", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L332-L368
train
Dump stats about all the actions that are in use in a set of replays.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_actions.py
ReplayStats.merge
def merge(self, other): """Merge another ReplayStats into this one.""" def merge_dict(a, b): for k, v in six.iteritems(b): a[k] += v self.replays += other.replays self.steps += other.steps self.camera_move += other.camera_move self.select_pt += other.select_pt self.select_rect...
python
def merge(self, other): """Merge another ReplayStats into this one.""" def merge_dict(a, b): for k, v in six.iteritems(b): a[k] += v self.replays += other.replays self.steps += other.steps self.camera_move += other.camera_move self.select_pt += other.select_pt self.select_rect...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "def", "merge_dict", "(", "a", ",", "b", ")", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "b", ")", ":", "a", "[", "k", "]", "+=", "v", "self", ".", "replays", "+=", "o...
Merge another ReplayStats into this one.
[ "Merge", "another", "ReplayStats", "into", "this", "one", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L85-L105
train
Merge another ReplayStats into this one.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_actions.py
ReplayProcessor.process_replay
def process_replay(self, controller, replay_data, map_data, player_id): """Process a single replay, updating the stats.""" self._update_stage("start_replay") controller.start_replay(sc_pb.RequestStartReplay( replay_data=replay_data, map_data=map_data, options=interface, obser...
python
def process_replay(self, controller, replay_data, map_data, player_id): """Process a single replay, updating the stats.""" self._update_stage("start_replay") controller.start_replay(sc_pb.RequestStartReplay( replay_data=replay_data, map_data=map_data, options=interface, obser...
[ "def", "process_replay", "(", "self", ",", "controller", ",", "replay_data", ",", "map_data", ",", "player_id", ")", ":", "self", ".", "_update_stage", "(", "\"start_replay\"", ")", "controller", ".", "start_replay", "(", "sc_pb", ".", "RequestStartReplay", "(",...
Process a single replay, updating the stats.
[ "Process", "a", "single", "replay", "updating", "the", "stats", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L240-L292
train
Processes a single replay and updates the stats.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/lan_sc2_env.py
tcp_server
def tcp_server(tcp_addr, settings): """Start up the tcp server, send the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) sock.bind(tcp_addr) sock.listen(1) logging.info("Waiting for connection on %s", tcp_ad...
python
def tcp_server(tcp_addr, settings): """Start up the tcp server, send the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) sock.bind(tcp_addr) sock.listen(1) logging.info("Waiting for connection on %s", tcp_ad...
[ "def", "tcp_server", "(", "tcp_addr", ",", "settings", ")", ":", "family", "=", "socket", ".", "AF_INET6", "if", "\":\"", "in", "tcp_addr", ".", "ip", "else", "socket", ".", "AF_INET", "sock", "=", "socket", ".", "socket", "(", "family", ",", "socket", ...
Start up the tcp server, send the settings.
[ "Start", "up", "the", "tcp", "server", "send", "the", "settings", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L65-L80
train
Start up the tcp server send the settings.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/lan_sc2_env.py
tcp_client
def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try:...
python
def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try:...
[ "def", "tcp_client", "(", "tcp_addr", ")", ":", "family", "=", "socket", ".", "AF_INET6", "if", "\":\"", "in", "tcp_addr", ".", "ip", "else", "socket", ".", "AF_INET", "sock", "=", "socket", ".", "socket", "(", "family", ",", "socket", ".", "SOCK_STREAM"...
Connect to the tcp server, and return the settings.
[ "Connect", "to", "the", "tcp", "server", "and", "return", "the", "settings", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L83-L106
train
Connect to the tcp server and return the settings.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/lan_sc2_env.py
read_tcp_size
def read_tcp_size(conn, size): """Read `size` number of bytes from `conn`, retrying as needed.""" chunks = [] bytes_read = 0 while bytes_read < size: chunk = conn.recv(size - bytes_read) if not chunk: if bytes_read > 0: logging.warning("Incomplete read: %s of %s.", bytes_read, size) ...
python
def read_tcp_size(conn, size): """Read `size` number of bytes from `conn`, retrying as needed.""" chunks = [] bytes_read = 0 while bytes_read < size: chunk = conn.recv(size - bytes_read) if not chunk: if bytes_read > 0: logging.warning("Incomplete read: %s of %s.", bytes_read, size) ...
[ "def", "read_tcp_size", "(", "conn", ",", "size", ")", ":", "chunks", "=", "[", "]", "bytes_read", "=", "0", "while", "bytes_read", "<", "size", ":", "chunk", "=", "conn", ".", "recv", "(", "size", "-", "bytes_read", ")", "if", "not", "chunk", ":", ...
Read `size` number of bytes from `conn`, retrying as needed.
[ "Read", "size", "number", "of", "bytes", "from", "conn", "retrying", "as", "needed", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L142-L154
train
Read size number of bytes from conn retrying as needed.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/lan_sc2_env.py
forward_ports
def forward_ports(remote_host, local_host, local_listen_ports, remote_listen_ports): """Forwards ports such that multiplayer works between machines. Args: remote_host: Where to ssh to. local_host: "127.0.0.1" or "::1". local_listen_ports: Which ports to listen on locally to forward re...
python
def forward_ports(remote_host, local_host, local_listen_ports, remote_listen_ports): """Forwards ports such that multiplayer works between machines. Args: remote_host: Where to ssh to. local_host: "127.0.0.1" or "::1". local_listen_ports: Which ports to listen on locally to forward re...
[ "def", "forward_ports", "(", "remote_host", ",", "local_host", ",", "local_listen_ports", ",", "remote_listen_ports", ")", ":", "if", "\":\"", "in", "local_host", "and", "not", "local_host", ".", "startswith", "(", "\"[\"", ")", ":", "local_host", "=", "\"[%s]\"...
Forwards ports such that multiplayer works between machines. Args: remote_host: Where to ssh to. local_host: "127.0.0.1" or "::1". local_listen_ports: Which ports to listen on locally to forward remotely. remote_listen_ports: Which ports to listen on remotely to forward locally. Returns: The s...
[ "Forwards", "ports", "such", "that", "multiplayer", "works", "between", "machines", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L163-L196
train
Forwards ports such that multiplayer works between machines.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/env/lan_sc2_env.py
LanSC2Env._launch_remote
def _launch_remote(self, host, config_port, race, name, interface): """Make sure this stays synced with bin/play_vs_agent.py.""" self._tcp_conn, settings = tcp_client(Addr(host, config_port)) self._map_name = settings["map_name"] if settings["remote"]: self._udp_sock = udp_server( Addr...
python
def _launch_remote(self, host, config_port, race, name, interface): """Make sure this stays synced with bin/play_vs_agent.py.""" self._tcp_conn, settings = tcp_client(Addr(host, config_port)) self._map_name = settings["map_name"] if settings["remote"]: self._udp_sock = udp_server( Addr...
[ "def", "_launch_remote", "(", "self", ",", "host", ",", "config_port", ",", "race", ",", "name", ",", "interface", ")", ":", "self", ".", "_tcp_conn", ",", "settings", "=", "tcp_client", "(", "Addr", "(", "host", ",", "config_port", ")", ")", "self", "...
Make sure this stays synced with bin/play_vs_agent.py.
[ "Make", "sure", "this", "stays", "synced", "with", "bin", "/", "play_vs_agent", ".", "py", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L305-L344
train
Launch remote game.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_info.py
_replay_index
def _replay_index(replay_dir): """Output information for a directory of replays.""" run_config = run_configs.get() replay_dir = run_config.abs_replay_path(replay_dir) print("Checking: ", replay_dir) with run_config.start(want_rgb=False) as controller: print("-" * 60) print(",".join(( "filenam...
python
def _replay_index(replay_dir): """Output information for a directory of replays.""" run_config = run_configs.get() replay_dir = run_config.abs_replay_path(replay_dir) print("Checking: ", replay_dir) with run_config.start(want_rgb=False) as controller: print("-" * 60) print(",".join(( "filenam...
[ "def", "_replay_index", "(", "replay_dir", ")", ":", "run_config", "=", "run_configs", ".", "get", "(", ")", "replay_dir", "=", "run_config", ".", "abs_replay_path", "(", "replay_dir", ")", "print", "(", "\"Checking: \"", ",", "replay_dir", ")", "with", "run_c...
Output information for a directory of replays.
[ "Output", "information", "for", "a", "directory", "of", "replays", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_info.py#L34-L91
train
Output information for a directory of replays.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/bin/replay_info.py
_replay_info
def _replay_info(replay_path): """Query a replay for information.""" if not replay_path.lower().endswith("sc2replay"): print("Must be a replay.") return run_config = run_configs.get() with run_config.start(want_rgb=False) as controller: info = controller.replay_info(run_config.replay_data(replay_pa...
python
def _replay_info(replay_path): """Query a replay for information.""" if not replay_path.lower().endswith("sc2replay"): print("Must be a replay.") return run_config = run_configs.get() with run_config.start(want_rgb=False) as controller: info = controller.replay_info(run_config.replay_data(replay_pa...
[ "def", "_replay_info", "(", "replay_path", ")", ":", "if", "not", "replay_path", ".", "lower", "(", ")", ".", "endswith", "(", "\"sc2replay\"", ")", ":", "print", "(", "\"Must be a replay.\"", ")", "return", "run_config", "=", "run_configs", ".", "get", "(",...
Query a replay for information.
[ "Query", "a", "replay", "for", "information", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_info.py#L94-L104
train
Query a replay for information.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/colors.py
smooth_hue_palette
def smooth_hue_palette(scale): """Takes an array of ints and returns a corresponding colored rgb array.""" # http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL # Based on http://stackoverflow.com/a/17382854 , with simplifications and # optimizations. Assumes S=1, L=0.5, meaning C=1 and m=0. # 0 stays black, ev...
python
def smooth_hue_palette(scale): """Takes an array of ints and returns a corresponding colored rgb array.""" # http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL # Based on http://stackoverflow.com/a/17382854 , with simplifications and # optimizations. Assumes S=1, L=0.5, meaning C=1 and m=0. # 0 stays black, ev...
[ "def", "smooth_hue_palette", "(", "scale", ")", ":", "# http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL", "# Based on http://stackoverflow.com/a/17382854 , with simplifications and", "# optimizations. Assumes S=1, L=0.5, meaning C=1 and m=0.", "# 0 stays black, everything else moves into a hue."...
Takes an array of ints and returns a corresponding colored rgb array.
[ "Takes", "an", "array", "of", "ints", "and", "returns", "a", "corresponding", "colored", "rgb", "array", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L78-L121
train
Takes an array of ints and returns a corresponding colored rgb array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/colors.py
piece_wise_linear
def piece_wise_linear(scale, points): """Create a palette that is piece-wise linear given some colors at points.""" assert len(points) >= 2 assert points[0][0] == 0 assert points[-1][0] == 1 assert all(i < j for i, j in zip(points[:-1], points[1:])) out = numpy.zeros((scale, 3)) p1, c1 = points[0] p2, c...
python
def piece_wise_linear(scale, points): """Create a palette that is piece-wise linear given some colors at points.""" assert len(points) >= 2 assert points[0][0] == 0 assert points[-1][0] == 1 assert all(i < j for i, j in zip(points[:-1], points[1:])) out = numpy.zeros((scale, 3)) p1, c1 = points[0] p2, c...
[ "def", "piece_wise_linear", "(", "scale", ",", "points", ")", ":", "assert", "len", "(", "points", ")", ">=", "2", "assert", "points", "[", "0", "]", "[", "0", "]", "==", "0", "assert", "points", "[", "-", "1", "]", "[", "0", "]", "==", "1", "a...
Create a palette that is piece-wise linear given some colors at points.
[ "Create", "a", "palette", "that", "is", "piece", "-", "wise", "linear", "given", "some", "colors", "at", "points", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L130-L149
train
Create a palette that is piece - wise linear given some colors at points.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/colors.py
unit_type
def unit_type(scale=None): """Returns a palette that maps unit types to rgb colors.""" # Can specify a scale to match the api or to accept unknown unit types. palette_size = scale or max(static_data.UNIT_TYPES) + 1 palette = shuffled_hue(palette_size) assert len(static_data.UNIT_TYPES) <= len(distinct_colors)...
python
def unit_type(scale=None): """Returns a palette that maps unit types to rgb colors.""" # Can specify a scale to match the api or to accept unknown unit types. palette_size = scale or max(static_data.UNIT_TYPES) + 1 palette = shuffled_hue(palette_size) assert len(static_data.UNIT_TYPES) <= len(distinct_colors)...
[ "def", "unit_type", "(", "scale", "=", "None", ")", ":", "# Can specify a scale to match the api or to accept unknown unit types.", "palette_size", "=", "scale", "or", "max", "(", "static_data", ".", "UNIT_TYPES", ")", "+", "1", "palette", "=", "shuffled_hue", "(", ...
Returns a palette that maps unit types to rgb colors.
[ "Returns", "a", "palette", "that", "maps", "unit", "types", "to", "rgb", "colors", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L205-L213
train
Returns a palette that maps unit types to rgb colors.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
with_lock
def with_lock(lock): """Make sure the lock is held while in this function.""" def decorator(func): @functools.wraps(func) def _with_lock(*args, **kwargs): with lock: return func(*args, **kwargs) return _with_lock return decorator
python
def with_lock(lock): """Make sure the lock is held while in this function.""" def decorator(func): @functools.wraps(func) def _with_lock(*args, **kwargs): with lock: return func(*args, **kwargs) return _with_lock return decorator
[ "def", "with_lock", "(", "lock", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_with_lock", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "lock", ":", "return", "func",...
Make sure the lock is held while in this function.
[ "Make", "sure", "the", "lock", "is", "held", "while", "in", "this", "function", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L60-L68
train
Make sure the lock is held while in this function.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
_get_desktop_size
def _get_desktop_size(): """Get the desktop size.""" if platform.system() == "Linux": try: xrandr_query = subprocess.check_output(["xrandr", "--query"]) sizes = re.findall(r"\bconnected primary (\d+)x(\d+)", str(xrandr_query)) if sizes[0]: return point.Point(int(sizes[0][0]), int(sizes...
python
def _get_desktop_size(): """Get the desktop size.""" if platform.system() == "Linux": try: xrandr_query = subprocess.check_output(["xrandr", "--query"]) sizes = re.findall(r"\bconnected primary (\d+)x(\d+)", str(xrandr_query)) if sizes[0]: return point.Point(int(sizes[0][0]), int(sizes...
[ "def", "_get_desktop_size", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "\"Linux\"", ":", "try", ":", "xrandr_query", "=", "subprocess", ".", "check_output", "(", "[", "\"xrandr\"", ",", "\"--query\"", "]", ")", "sizes", "=", "re", "....
Get the desktop size.
[ "Get", "the", "desktop", "size", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L216-L229
train
Get the desktop size.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
_Surface.draw_arc
def draw_arc(self, color, world_loc, world_radius, start_angle, stop_angle, thickness=1): """Draw an arc using world coordinates, radius, start and stop angles.""" center = self.world_to_surf.fwd_pt(world_loc).round() radius = max(1, int(self.world_to_surf.fwd_dist(world_radius))) rect = ...
python
def draw_arc(self, color, world_loc, world_radius, start_angle, stop_angle, thickness=1): """Draw an arc using world coordinates, radius, start and stop angles.""" center = self.world_to_surf.fwd_pt(world_loc).round() radius = max(1, int(self.world_to_surf.fwd_dist(world_radius))) rect = ...
[ "def", "draw_arc", "(", "self", ",", "color", ",", "world_loc", ",", "world_radius", ",", "start_angle", ",", "stop_angle", ",", "thickness", "=", "1", ")", ":", "center", "=", "self", ".", "world_to_surf", ".", "fwd_pt", "(", "world_loc", ")", ".", "rou...
Draw an arc using world coordinates, radius, start and stop angles.
[ "Draw", "an", "arc", "using", "world", "coordinates", "radius", "start", "and", "stop", "angles", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L141-L148
train
Draw an arc using world coordinates radius start and stop angles.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
_Surface.draw_circle
def draw_circle(self, color, world_loc, world_radius, thickness=0): """Draw a circle using world coordinates and radius.""" if world_radius > 0: center = self.world_to_surf.fwd_pt(world_loc).round() radius = max(1, int(self.world_to_surf.fwd_dist(world_radius))) pygame.draw.circle(self.surf, c...
python
def draw_circle(self, color, world_loc, world_radius, thickness=0): """Draw a circle using world coordinates and radius.""" if world_radius > 0: center = self.world_to_surf.fwd_pt(world_loc).round() radius = max(1, int(self.world_to_surf.fwd_dist(world_radius))) pygame.draw.circle(self.surf, c...
[ "def", "draw_circle", "(", "self", ",", "color", ",", "world_loc", ",", "world_radius", ",", "thickness", "=", "0", ")", ":", "if", "world_radius", ">", "0", ":", "center", "=", "self", ".", "world_to_surf", ".", "fwd_pt", "(", "world_loc", ")", ".", "...
Draw a circle using world coordinates and radius.
[ "Draw", "a", "circle", "using", "world", "coordinates", "and", "radius", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L150-L156
train
Draw a circle using world coordinates and radius.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
_Surface.draw_rect
def draw_rect(self, color, world_rect, thickness=0): """Draw a rectangle using world coordinates.""" tl = self.world_to_surf.fwd_pt(world_rect.tl).round() br = self.world_to_surf.fwd_pt(world_rect.br).round() rect = pygame.Rect(tl, br - tl) pygame.draw.rect(self.surf, color, rect, thickness)
python
def draw_rect(self, color, world_rect, thickness=0): """Draw a rectangle using world coordinates.""" tl = self.world_to_surf.fwd_pt(world_rect.tl).round() br = self.world_to_surf.fwd_pt(world_rect.br).round() rect = pygame.Rect(tl, br - tl) pygame.draw.rect(self.surf, color, rect, thickness)
[ "def", "draw_rect", "(", "self", ",", "color", ",", "world_rect", ",", "thickness", "=", "0", ")", ":", "tl", "=", "self", ".", "world_to_surf", ".", "fwd_pt", "(", "world_rect", ".", "tl", ")", ".", "round", "(", ")", "br", "=", "self", ".", "worl...
Draw a rectangle using world coordinates.
[ "Draw", "a", "rectangle", "using", "world", "coordinates", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L158-L163
train
Draw a rectangle using world coordinates.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
_Surface.blit_np_array
def blit_np_array(self, array): """Fill this surface using the contents of a numpy array.""" with sw("make_surface"): raw_surface = pygame.surfarray.make_surface(array.transpose([1, 0, 2])) with sw("draw"): pygame.transform.scale(raw_surface, self.surf.get_size(), self.surf)
python
def blit_np_array(self, array): """Fill this surface using the contents of a numpy array.""" with sw("make_surface"): raw_surface = pygame.surfarray.make_surface(array.transpose([1, 0, 2])) with sw("draw"): pygame.transform.scale(raw_surface, self.surf.get_size(), self.surf)
[ "def", "blit_np_array", "(", "self", ",", "array", ")", ":", "with", "sw", "(", "\"make_surface\"", ")", ":", "raw_surface", "=", "pygame", ".", "surfarray", ".", "make_surface", "(", "array", ".", "transpose", "(", "[", "1", ",", "0", ",", "2", "]", ...
Fill this surface using the contents of a numpy array.
[ "Fill", "this", "surface", "using", "the", "contents", "of", "a", "numpy", "array", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L165-L170
train
Fill this surface using the contents of a numpy array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
_Surface.write_screen
def write_screen(self, font, color, screen_pos, text, align="left", valign="top"): """Write to the screen in font.size relative coordinates.""" pos = point.Point(*screen_pos) * point.Point(0.75, 1) * font.get_linesize() text_surf = font.render(str(text), True, color) rect = text_surf....
python
def write_screen(self, font, color, screen_pos, text, align="left", valign="top"): """Write to the screen in font.size relative coordinates.""" pos = point.Point(*screen_pos) * point.Point(0.75, 1) * font.get_linesize() text_surf = font.render(str(text), True, color) rect = text_surf....
[ "def", "write_screen", "(", "self", ",", "font", ",", "color", ",", "screen_pos", ",", "text", ",", "align", "=", "\"left\"", ",", "valign", "=", "\"top\"", ")", ":", "pos", "=", "point", ".", "Point", "(", "*", "screen_pos", ")", "*", "point", ".", ...
Write to the screen in font.size relative coordinates.
[ "Write", "to", "the", "screen", "in", "font", ".", "size", "relative", "coordinates", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L172-L186
train
Write text to the screen in font. size relative coordinates.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
MousePos.action_spatial
def action_spatial(self, action): """Given an Action, return the right spatial action.""" if self.surf.surf_type & SurfType.FEATURE: return action.action_feature_layer elif self.surf.surf_type & SurfType.RGB: return action.action_render else: assert self.surf.surf_type & (SurfType.RGB ...
python
def action_spatial(self, action): """Given an Action, return the right spatial action.""" if self.surf.surf_type & SurfType.FEATURE: return action.action_feature_layer elif self.surf.surf_type & SurfType.RGB: return action.action_render else: assert self.surf.surf_type & (SurfType.RGB ...
[ "def", "action_spatial", "(", "self", ",", "action", ")", ":", "if", "self", ".", "surf", ".", "surf_type", "&", "SurfType", ".", "FEATURE", ":", "return", "action", ".", "action_feature_layer", "elif", "self", ".", "surf", ".", "surf_type", "&", "SurfType...
Given an Action, return the right spatial action.
[ "Given", "an", "Action", "return", "the", "right", "spatial", "action", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L201-L208
train
Given an Action return the right spatial action.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.init
def init(self, game_info, static_data): """Take the game info and the static data needed to set up the game. This must be called before render or get_actions for each game or restart. Args: game_info: A `sc_pb.ResponseGameInfo` object for this game. static_data: A `StaticData` object for this ...
python
def init(self, game_info, static_data): """Take the game info and the static data needed to set up the game. This must be called before render or get_actions for each game or restart. Args: game_info: A `sc_pb.ResponseGameInfo` object for this game. static_data: A `StaticData` object for this ...
[ "def", "init", "(", "self", ",", "game_info", ",", "static_data", ")", ":", "self", ".", "_game_info", "=", "game_info", "self", ".", "_static_data", "=", "static_data", "if", "not", "game_info", ".", "HasField", "(", "\"start_raw\"", ")", ":", "raise", "V...
Take the game info and the static data needed to set up the game. This must be called before render or get_actions for each game or restart. Args: game_info: A `sc_pb.ResponseGameInfo` object for this game. static_data: A `StaticData` object for this game. Raises: ValueError: if there i...
[ "Take", "the", "game", "info", "and", "the", "static", "data", "needed", "to", "set", "up", "the", "game", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L323-L379
train
Initialize the object with the game info and static data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.init_window
def init_window(self): """Initialize the pygame window and lay out the surfaces.""" if platform.system() == "Windows": # Enable DPI awareness on Windows to give the correct window size. ctypes.windll.user32.SetProcessDPIAware() # pytype: disable=module-attr pygame.init() if self._desktop_...
python
def init_window(self): """Initialize the pygame window and lay out the surfaces.""" if platform.system() == "Windows": # Enable DPI awareness on Windows to give the correct window size. ctypes.windll.user32.SetProcessDPIAware() # pytype: disable=module-attr pygame.init() if self._desktop_...
[ "def", "init_window", "(", "self", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "\"Windows\"", ":", "# Enable DPI awareness on Windows to give the correct window size.", "ctypes", ".", "windll", ".", "user32", ".", "SetProcessDPIAware", "(", ")", "# py...
Initialize the pygame window and lay out the surfaces.
[ "Initialize", "the", "pygame", "window", "and", "lay", "out", "the", "surfaces", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L383-L647
train
Initialize the pygame window and lay out the surfaces.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman._update_camera
def _update_camera(self, camera_center): """Update the camera transform based on the new camera center.""" self._world_tl_to_world_camera_rel.offset = ( -self._world_to_world_tl.fwd_pt(camera_center) * self._world_tl_to_world_camera_rel.scale) if self._feature_screen_px: camera_radius...
python
def _update_camera(self, camera_center): """Update the camera transform based on the new camera center.""" self._world_tl_to_world_camera_rel.offset = ( -self._world_to_world_tl.fwd_pt(camera_center) * self._world_tl_to_world_camera_rel.scale) if self._feature_screen_px: camera_radius...
[ "def", "_update_camera", "(", "self", ",", "camera_center", ")", ":", "self", ".", "_world_tl_to_world_camera_rel", ".", "offset", "=", "(", "-", "self", ".", "_world_to_world_tl", ".", "fwd_pt", "(", "camera_center", ")", "*", "self", ".", "_world_tl_to_world_c...
Update the camera transform based on the new camera center.
[ "Update", "the", "camera", "transform", "based", "on", "the", "new", "camera", "center", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L649-L662
train
Update the camera transform based on the new camera center.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.get_mouse_pos
def get_mouse_pos(self, window_pos=None): """Return a MousePos filled with the world position and surf it hit.""" window_pos = window_pos or pygame.mouse.get_pos() # +0.5 to center the point on the middle of the pixel. window_pt = point.Point(*window_pos) + 0.5 for surf in reversed(self._surfaces): ...
python
def get_mouse_pos(self, window_pos=None): """Return a MousePos filled with the world position and surf it hit.""" window_pos = window_pos or pygame.mouse.get_pos() # +0.5 to center the point on the middle of the pixel. window_pt = point.Point(*window_pos) + 0.5 for surf in reversed(self._surfaces): ...
[ "def", "get_mouse_pos", "(", "self", ",", "window_pos", "=", "None", ")", ":", "window_pos", "=", "window_pos", "or", "pygame", ".", "mouse", ".", "get_pos", "(", ")", "# +0.5 to center the point on the middle of the pixel.", "window_pt", "=", "point", ".", "Point...
Return a MousePos filled with the world position and surf it hit.
[ "Return", "a", "MousePos", "filled", "with", "the", "world", "position", "and", "surf", "it", "hit", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L669-L679
train
Return a MousePos filled with the world position and surf it hit.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.get_actions
def get_actions(self, run_config, controller): """Get actions from the UI, apply to controller, and return an ActionCmd.""" if not self._initialized: return ActionCmd.STEP for event in pygame.event.get(): ctrl = pygame.key.get_mods() & pygame.KMOD_CTRL shift = pygame.key.get_mods() & pyga...
python
def get_actions(self, run_config, controller): """Get actions from the UI, apply to controller, and return an ActionCmd.""" if not self._initialized: return ActionCmd.STEP for event in pygame.event.get(): ctrl = pygame.key.get_mods() & pygame.KMOD_CTRL shift = pygame.key.get_mods() & pyga...
[ "def", "get_actions", "(", "self", ",", "run_config", ",", "controller", ")", ":", "if", "not", "self", ".", "_initialized", ":", "return", "ActionCmd", ".", "STEP", "for", "event", "in", "pygame", ".", "event", ".", "get", "(", ")", ":", "ctrl", "=", ...
Get actions from the UI, apply to controller, and return an ActionCmd.
[ "Get", "actions", "from", "the", "UI", "apply", "to", "controller", "and", "return", "an", "ActionCmd", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L693-L817
train
Get actions from the UI apply to controller and return an ActionCmd.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.camera_action
def camera_action(self, mouse_pos): """Return a `sc_pb.Action` with the camera movement filled.""" action = sc_pb.Action() action_spatial = mouse_pos.action_spatial(action) mouse_pos.obs_pos.assign_to(action_spatial.camera_move.center_minimap) return action
python
def camera_action(self, mouse_pos): """Return a `sc_pb.Action` with the camera movement filled.""" action = sc_pb.Action() action_spatial = mouse_pos.action_spatial(action) mouse_pos.obs_pos.assign_to(action_spatial.camera_move.center_minimap) return action
[ "def", "camera_action", "(", "self", ",", "mouse_pos", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "action_spatial", "=", "mouse_pos", ".", "action_spatial", "(", "action", ")", "mouse_pos", ".", "obs_pos", ".", "assign_to", "(", "action_spati...
Return a `sc_pb.Action` with the camera movement filled.
[ "Return", "a", "sc_pb", ".", "Action", "with", "the", "camera", "movement", "filled", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L819-L824
train
Return a sc_pb. Action with the camera movement filled.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.camera_action_raw
def camera_action_raw(self, world_pos): """Return a `sc_pb.Action` with the camera movement filled.""" action = sc_pb.Action() world_pos.assign_to(action.action_raw.camera_move.center_world_space) return action
python
def camera_action_raw(self, world_pos): """Return a `sc_pb.Action` with the camera movement filled.""" action = sc_pb.Action() world_pos.assign_to(action.action_raw.camera_move.center_world_space) return action
[ "def", "camera_action_raw", "(", "self", ",", "world_pos", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "world_pos", ".", "assign_to", "(", "action", ".", "action_raw", ".", "camera_move", ".", "center_world_space", ")", "return", "action" ]
Return a `sc_pb.Action` with the camera movement filled.
[ "Return", "a", "sc_pb", ".", "Action", "with", "the", "camera", "movement", "filled", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L826-L830
train
Return a sc_pb. Action with the camera movement filled.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.select_action
def select_action(self, pos1, pos2, ctrl, shift): """Return a `sc_pb.Action` with the selection filled.""" assert pos1.surf.surf_type == pos2.surf.surf_type assert pos1.surf.world_to_obs == pos2.surf.world_to_obs action = sc_pb.Action() action_spatial = pos1.action_spatial(action) if pos1.worl...
python
def select_action(self, pos1, pos2, ctrl, shift): """Return a `sc_pb.Action` with the selection filled.""" assert pos1.surf.surf_type == pos2.surf.surf_type assert pos1.surf.world_to_obs == pos2.surf.world_to_obs action = sc_pb.Action() action_spatial = pos1.action_spatial(action) if pos1.worl...
[ "def", "select_action", "(", "self", ",", "pos1", ",", "pos2", ",", "ctrl", ",", "shift", ")", ":", "assert", "pos1", ".", "surf", ".", "surf_type", "==", "pos2", ".", "surf", ".", "surf_type", "assert", "pos1", ".", "surf", ".", "world_to_obs", "==", ...
Return a `sc_pb.Action` with the selection filled.
[ "Return", "a", "sc_pb", ".", "Action", "with", "the", "selection", "filled", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L832-L861
train
Select an action with the selection filled.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.select_idle_worker
def select_idle_worker(self, ctrl, shift): """Select an idle worker.""" action = sc_pb.Action() mod = sc_ui.ActionSelectIdleWorker if ctrl: select_worker = mod.AddAll if shift else mod.All else: select_worker = mod.Add if shift else mod.Set action.action_ui.select_idle_worker.type = ...
python
def select_idle_worker(self, ctrl, shift): """Select an idle worker.""" action = sc_pb.Action() mod = sc_ui.ActionSelectIdleWorker if ctrl: select_worker = mod.AddAll if shift else mod.All else: select_worker = mod.Add if shift else mod.Set action.action_ui.select_idle_worker.type = ...
[ "def", "select_idle_worker", "(", "self", ",", "ctrl", ",", "shift", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "mod", "=", "sc_ui", ".", "ActionSelectIdleWorker", "if", "ctrl", ":", "select_worker", "=", "mod", ".", "AddAll", "if", "shif...
Select an idle worker.
[ "Select", "an", "idle", "worker", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L863-L872
train
Select an idle worker.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.select_army
def select_army(self, shift): """Select the entire army.""" action = sc_pb.Action() action.action_ui.select_army.selection_add = shift return action
python
def select_army(self, shift): """Select the entire army.""" action = sc_pb.Action() action.action_ui.select_army.selection_add = shift return action
[ "def", "select_army", "(", "self", ",", "shift", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "action", ".", "action_ui", ".", "select_army", ".", "selection_add", "=", "shift", "return", "action" ]
Select the entire army.
[ "Select", "the", "entire", "army", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L874-L878
train
Select the entire army.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.select_warp_gates
def select_warp_gates(self, shift): """Select all warp gates.""" action = sc_pb.Action() action.action_ui.select_warp_gates.selection_add = shift return action
python
def select_warp_gates(self, shift): """Select all warp gates.""" action = sc_pb.Action() action.action_ui.select_warp_gates.selection_add = shift return action
[ "def", "select_warp_gates", "(", "self", ",", "shift", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "action", ".", "action_ui", ".", "select_warp_gates", ".", "selection_add", "=", "shift", "return", "action" ]
Select all warp gates.
[ "Select", "all", "warp", "gates", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L880-L884
train
Select all warp gates.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.select_larva
def select_larva(self): """Select all larva.""" action = sc_pb.Action() action.action_ui.select_larva.SetInParent() # Adds the empty proto field. return action
python
def select_larva(self): """Select all larva.""" action = sc_pb.Action() action.action_ui.select_larva.SetInParent() # Adds the empty proto field. return action
[ "def", "select_larva", "(", "self", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "action", ".", "action_ui", ".", "select_larva", ".", "SetInParent", "(", ")", "# Adds the empty proto field.", "return", "action" ]
Select all larva.
[ "Select", "all", "larva", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L886-L890
train
Select all larva.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.control_group
def control_group(self, control_group_id, ctrl, shift, alt): """Act on a control group, selecting, setting, etc.""" action = sc_pb.Action() select = action.action_ui.control_group mod = sc_ui.ActionControlGroup if not ctrl and not shift and not alt: select.action = mod.Recall elif ctrl an...
python
def control_group(self, control_group_id, ctrl, shift, alt): """Act on a control group, selecting, setting, etc.""" action = sc_pb.Action() select = action.action_ui.control_group mod = sc_ui.ActionControlGroup if not ctrl and not shift and not alt: select.action = mod.Recall elif ctrl an...
[ "def", "control_group", "(", "self", ",", "control_group_id", ",", "ctrl", ",", "shift", ",", "alt", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "select", "=", "action", ".", "action_ui", ".", "control_group", "mod", "=", "sc_ui", ".", "...
Act on a control group, selecting, setting, etc.
[ "Act", "on", "a", "control", "group", "selecting", "setting", "etc", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L892-L911
train
Act on a control group selecting setting etc.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.unit_action
def unit_action(self, cmd, pos, shift): """Return a `sc_pb.Action` filled with the cmd and appropriate target.""" action = sc_pb.Action() if pos: action_spatial = pos.action_spatial(action) unit_command = action_spatial.unit_command unit_command.ability_id = cmd.ability_id unit_comma...
python
def unit_action(self, cmd, pos, shift): """Return a `sc_pb.Action` filled with the cmd and appropriate target.""" action = sc_pb.Action() if pos: action_spatial = pos.action_spatial(action) unit_command = action_spatial.unit_command unit_command.ability_id = cmd.ability_id unit_comma...
[ "def", "unit_action", "(", "self", ",", "cmd", ",", "pos", ",", "shift", ")", ":", "action", "=", "sc_pb", ".", "Action", "(", ")", "if", "pos", ":", "action_spatial", "=", "pos", ".", "action_spatial", "(", "action", ")", "unit_command", "=", "action_...
Return a `sc_pb.Action` filled with the cmd and appropriate target.
[ "Return", "a", "sc_pb", ".", "Action", "filled", "with", "the", "cmd", "and", "appropriate", "target", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L913-L932
train
Return a sc_pb. Action filled with the cmd and appropriate target.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman._abilities
def _abilities(self, fn=None): """Return the list of abilities filtered by `fn`.""" out = {} for cmd in self._obs.observation.abilities: ability = _Ability(cmd, self._static_data.abilities) if not fn or fn(ability): out[ability.ability_id] = ability return list(out.values())
python
def _abilities(self, fn=None): """Return the list of abilities filtered by `fn`.""" out = {} for cmd in self._obs.observation.abilities: ability = _Ability(cmd, self._static_data.abilities) if not fn or fn(ability): out[ability.ability_id] = ability return list(out.values())
[ "def", "_abilities", "(", "self", ",", "fn", "=", "None", ")", ":", "out", "=", "{", "}", "for", "cmd", "in", "self", ".", "_obs", ".", "observation", ".", "abilities", ":", "ability", "=", "_Ability", "(", "cmd", ",", "self", ".", "_static_data", ...
Return the list of abilities filtered by `fn`.
[ "Return", "the", "list", "of", "abilities", "filtered", "by", "fn", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L934-L941
train
Return the list of abilities filtered by fn.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman._visible_units
def _visible_units(self): """A generator of visible units and their positions as `Point`s, sorted.""" # Sort the units by elevation, then owned (eg refinery) above world (ie 16) # (eg geiser), small above big, and otherwise arbitrary but stable. for u in sorted(self._obs.observation.raw_data.units, ...
python
def _visible_units(self): """A generator of visible units and their positions as `Point`s, sorted.""" # Sort the units by elevation, then owned (eg refinery) above world (ie 16) # (eg geiser), small above big, and otherwise arbitrary but stable. for u in sorted(self._obs.observation.raw_data.units, ...
[ "def", "_visible_units", "(", "self", ")", ":", "# Sort the units by elevation, then owned (eg refinery) above world (ie 16)", "# (eg geiser), small above big, and otherwise arbitrary but stable.", "for", "u", "in", "sorted", "(", "self", ".", "_obs", ".", "observation", ".", "...
A generator of visible units and their positions as `Point`s, sorted.
[ "A", "generator", "of", "visible", "units", "and", "their", "positions", "as", "Point", "s", "sorted", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L943-L949
train
A generator of visible units and their positions as Points sorted.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman._units_in_area
def _units_in_area(self, rect): """Return the list of units that intersect the rect.""" player_id = self._obs.observation.player_common.player_id return [u for u, p in self._visible_units() if rect.intersects_circle(p, u.radius) and u.owner == player_id]
python
def _units_in_area(self, rect): """Return the list of units that intersect the rect.""" player_id = self._obs.observation.player_common.player_id return [u for u, p in self._visible_units() if rect.intersects_circle(p, u.radius) and u.owner == player_id]
[ "def", "_units_in_area", "(", "self", ",", "rect", ")", ":", "player_id", "=", "self", ".", "_obs", ".", "observation", ".", "player_common", ".", "player_id", "return", "[", "u", "for", "u", ",", "p", "in", "self", ".", "_visible_units", "(", ")", "if...
Return the list of units that intersect the rect.
[ "Return", "the", "list", "of", "units", "that", "intersect", "the", "rect", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L951-L955
train
Return the list of units that intersect the rect.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.get_unit_name
def get_unit_name(self, surf, name, radius): """Get a length limited unit name for drawing units.""" key = (name, radius) if key not in self._name_lengths: max_len = surf.world_to_surf.fwd_dist(radius * 1.6) for i in range(len(name)): if self._font_small.size(name[:i + 1])[0] > max_len: ...
python
def get_unit_name(self, surf, name, radius): """Get a length limited unit name for drawing units.""" key = (name, radius) if key not in self._name_lengths: max_len = surf.world_to_surf.fwd_dist(radius * 1.6) for i in range(len(name)): if self._font_small.size(name[:i + 1])[0] > max_len: ...
[ "def", "get_unit_name", "(", "self", ",", "surf", ",", "name", ",", "radius", ")", ":", "key", "=", "(", "name", ",", "radius", ")", "if", "key", "not", "in", "self", ".", "_name_lengths", ":", "max_len", "=", "surf", ".", "world_to_surf", ".", "fwd_...
Get a length limited unit name for drawing units.
[ "Get", "a", "length", "limited", "unit", "name", "for", "drawing", "units", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L957-L968
train
Get a length limited unit name for drawing units.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_units
def draw_units(self, surf): """Draw the units and buildings.""" for u, p in self._visible_units(): if self._camera.intersects_circle(p, u.radius): fraction_damage = clamp((u.health_max - u.health) / (u.health_max or 1), 0, 1) surf.draw_circle(colors.PLAYER_A...
python
def draw_units(self, surf): """Draw the units and buildings.""" for u, p in self._visible_units(): if self._camera.intersects_circle(p, u.radius): fraction_damage = clamp((u.health_max - u.health) / (u.health_max or 1), 0, 1) surf.draw_circle(colors.PLAYER_A...
[ "def", "draw_units", "(", "self", ",", "surf", ")", ":", "for", "u", ",", "p", "in", "self", ".", "_visible_units", "(", ")", ":", "if", "self", ".", "_camera", ".", "intersects_circle", "(", "p", ",", "u", ".", "radius", ")", ":", "fraction_damage",...
Draw the units and buildings.
[ "Draw", "the", "units", "and", "buildings", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L971-L999
train
Draw the units and buildings.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_selection
def draw_selection(self, surf): """Draw the selection rectange.""" select_start = self._select_start # Cache to avoid a race condition. if select_start: mouse_pos = self.get_mouse_pos() if (mouse_pos and mouse_pos.surf.surf_type & SurfType.SCREEN and mouse_pos.surf.surf_type == select...
python
def draw_selection(self, surf): """Draw the selection rectange.""" select_start = self._select_start # Cache to avoid a race condition. if select_start: mouse_pos = self.get_mouse_pos() if (mouse_pos and mouse_pos.surf.surf_type & SurfType.SCREEN and mouse_pos.surf.surf_type == select...
[ "def", "draw_selection", "(", "self", ",", "surf", ")", ":", "select_start", "=", "self", ".", "_select_start", "# Cache to avoid a race condition.", "if", "select_start", ":", "mouse_pos", "=", "self", ".", "get_mouse_pos", "(", ")", "if", "(", "mouse_pos", "an...
Draw the selection rectange.
[ "Draw", "the", "selection", "rectange", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1002-L1010
train
Draw the selection rectange.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_build_target
def draw_build_target(self, surf): """Draw the build target.""" round_half = lambda v, cond: round(v - 0.5) + 0.5 if cond else round(v) queued_action = self._queued_action if queued_action: radius = queued_action.footprint_radius if radius: pos = self.get_mouse_pos() if pos:...
python
def draw_build_target(self, surf): """Draw the build target.""" round_half = lambda v, cond: round(v - 0.5) + 0.5 if cond else round(v) queued_action = self._queued_action if queued_action: radius = queued_action.footprint_radius if radius: pos = self.get_mouse_pos() if pos:...
[ "def", "draw_build_target", "(", "self", ",", "surf", ")", ":", "round_half", "=", "lambda", "v", ",", "cond", ":", "round", "(", "v", "-", "0.5", ")", "+", "0.5", "if", "cond", "else", "round", "(", "v", ")", "queued_action", "=", "self", ".", "_q...
Draw the build target.
[ "Draw", "the", "build", "target", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1013-L1028
train
Draw the build target.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_overlay
def draw_overlay(self, surf): """Draw the overlay describing resources.""" obs = self._obs.observation player = obs.player_common surf.write_screen( self._font_large, colors.green, (0.2, 0.2), "Minerals: %s, Vespene: %s, Food: %s / %s" % ( player.minerals, player.vespene, pla...
python
def draw_overlay(self, surf): """Draw the overlay describing resources.""" obs = self._obs.observation player = obs.player_common surf.write_screen( self._font_large, colors.green, (0.2, 0.2), "Minerals: %s, Vespene: %s, Food: %s / %s" % ( player.minerals, player.vespene, pla...
[ "def", "draw_overlay", "(", "self", ",", "surf", ")", ":", "obs", "=", "self", ".", "_obs", ".", "observation", "player", "=", "obs", ".", "player_common", "surf", ".", "write_screen", "(", "self", ".", "_font_large", ",", "colors", ".", "green", ",", ...
Draw the overlay describing resources.
[ "Draw", "the", "overlay", "describing", "resources", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1031-L1059
train
Draw the overlay describing resources.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_help
def draw_help(self, surf): """Draw the help dialog.""" if not self._help: return def write(loc, text): surf.write_screen(self._font_large, colors.black, loc, text) surf.surf.fill(colors.white * 0.8) write((1, 1), "Shortcuts:") max_len = max(len(s) for s, _ in self.shortcuts) f...
python
def draw_help(self, surf): """Draw the help dialog.""" if not self._help: return def write(loc, text): surf.write_screen(self._font_large, colors.black, loc, text) surf.surf.fill(colors.white * 0.8) write((1, 1), "Shortcuts:") max_len = max(len(s) for s, _ in self.shortcuts) f...
[ "def", "draw_help", "(", "self", ",", "surf", ")", ":", "if", "not", "self", ".", "_help", ":", "return", "def", "write", "(", "loc", ",", "text", ")", ":", "surf", ".", "write_screen", "(", "self", ".", "_font_large", ",", "colors", ".", "black", ...
Draw the help dialog.
[ "Draw", "the", "help", "dialog", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1062-L1076
train
Draw the help dialog.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_commands
def draw_commands(self, surf): """Draw the list of available commands.""" past_abilities = {act.ability for act in self._past_actions if act.ability} for y, cmd in enumerate(sorted(self._abilities( lambda c: c.name != "Smart"), key=lambda c: c.name), start=2): if self._queued_action and cmd ==...
python
def draw_commands(self, surf): """Draw the list of available commands.""" past_abilities = {act.ability for act in self._past_actions if act.ability} for y, cmd in enumerate(sorted(self._abilities( lambda c: c.name != "Smart"), key=lambda c: c.name), start=2): if self._queued_action and cmd ==...
[ "def", "draw_commands", "(", "self", ",", "surf", ")", ":", "past_abilities", "=", "{", "act", ".", "ability", "for", "act", "in", "self", ".", "_past_actions", "if", "act", ".", "ability", "}", "for", "y", ",", "cmd", "in", "enumerate", "(", "sorted",...
Draw the list of available commands.
[ "Draw", "the", "list", "of", "available", "commands", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1079-L1094
train
Draw the list of available commands.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_panel
def draw_panel(self, surf): """Draw the unit selection or build queue.""" left = -12 # How far from the right border def unit_name(unit_type): return self._static_data.units.get(unit_type, "<unknown>") def write(loc, text, color=colors.yellow): surf.write_screen(self._font_large, color, ...
python
def draw_panel(self, surf): """Draw the unit selection or build queue.""" left = -12 # How far from the right border def unit_name(unit_type): return self._static_data.units.get(unit_type, "<unknown>") def write(loc, text, color=colors.yellow): surf.write_screen(self._font_large, color, ...
[ "def", "draw_panel", "(", "self", ",", "surf", ")", ":", "left", "=", "-", "12", "# How far from the right border", "def", "unit_name", "(", "unit_type", ")", ":", "return", "self", ".", "_static_data", ".", "units", ".", "get", "(", "unit_type", ",", "\"<...
Draw the unit selection or build queue.
[ "Draw", "the", "unit", "selection", "or", "build", "queue", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1097-L1163
train
Draw the unit selection or build queue.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_actions
def draw_actions(self): """Draw the actions so that they can be inspected for accuracy.""" now = time.time() for act in self._past_actions: if act.pos and now < act.deadline: remain = (act.deadline - now) / (act.deadline - act.time) if isinstance(act.pos, point.Point): size =...
python
def draw_actions(self): """Draw the actions so that they can be inspected for accuracy.""" now = time.time() for act in self._past_actions: if act.pos and now < act.deadline: remain = (act.deadline - now) / (act.deadline - act.time) if isinstance(act.pos, point.Point): size =...
[ "def", "draw_actions", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "for", "act", "in", "self", ".", "_past_actions", ":", "if", "act", ".", "pos", "and", "now", "<", "act", ".", "deadline", ":", "remain", "=", "(", "act", "....
Draw the actions so that they can be inspected for accuracy.
[ "Draw", "the", "actions", "so", "that", "they", "can", "be", "inspected", "for", "accuracy", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1166-L1177
train
Draw the actions so that they can be inspected for accuracy.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.prepare_actions
def prepare_actions(self, obs): """Keep a list of the past actions so they can be drawn.""" now = time.time() while self._past_actions and self._past_actions[0].deadline < now: self._past_actions.pop(0) def add_act(ability_id, color, pos, timeout=1): if ability_id: ability = self._s...
python
def prepare_actions(self, obs): """Keep a list of the past actions so they can be drawn.""" now = time.time() while self._past_actions and self._past_actions[0].deadline < now: self._past_actions.pop(0) def add_act(ability_id, color, pos, timeout=1): if ability_id: ability = self._s...
[ "def", "prepare_actions", "(", "self", ",", "obs", ")", ":", "now", "=", "time", ".", "time", "(", ")", "while", "self", ".", "_past_actions", "and", "self", ".", "_past_actions", "[", "0", "]", ".", "deadline", "<", "now", ":", "self", ".", "_past_a...
Keep a list of the past actions so they can be drawn.
[ "Keep", "a", "list", "of", "the", "past", "actions", "so", "they", "can", "be", "drawn", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1180-L1252
train
Prepare the list of past actions so they can be drawn.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_base_map
def draw_base_map(self, surf): """Draw the base map.""" hmap_feature = features.SCREEN_FEATURES.height_map hmap = hmap_feature.unpack(self._obs.observation) if not hmap.any(): hmap = hmap + 100 # pylint: disable=g-no-augmented-assignment hmap_color = hmap_feature.color(hmap) creep_featur...
python
def draw_base_map(self, surf): """Draw the base map.""" hmap_feature = features.SCREEN_FEATURES.height_map hmap = hmap_feature.unpack(self._obs.observation) if not hmap.any(): hmap = hmap + 100 # pylint: disable=g-no-augmented-assignment hmap_color = hmap_feature.color(hmap) creep_featur...
[ "def", "draw_base_map", "(", "self", ",", "surf", ")", ":", "hmap_feature", "=", "features", ".", "SCREEN_FEATURES", ".", "height_map", "hmap", "=", "hmap_feature", ".", "unpack", "(", "self", ".", "_obs", ".", "observation", ")", "if", "not", "hmap", ".",...
Draw the base map.
[ "Draw", "the", "base", "map", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1255-L1284
train
Draw the base map.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_mini_map
def draw_mini_map(self, surf): """Draw the minimap.""" if (self._render_rgb and self._obs.observation.HasField("render_data") and self._obs.observation.render_data.HasField("minimap")): # Draw the rendered version. surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.obs...
python
def draw_mini_map(self, surf): """Draw the minimap.""" if (self._render_rgb and self._obs.observation.HasField("render_data") and self._obs.observation.render_data.HasField("minimap")): # Draw the rendered version. surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.obs...
[ "def", "draw_mini_map", "(", "self", ",", "surf", ")", ":", "if", "(", "self", ".", "_render_rgb", "and", "self", ".", "_obs", ".", "observation", ".", "HasField", "(", "\"render_data\"", ")", "and", "self", ".", "_obs", ".", "observation", ".", "render_...
Draw the minimap.
[ "Draw", "the", "minimap", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1287-L1334
train
Draw the minimap.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_rendered_map
def draw_rendered_map(self, surf): """Draw the rendered pixels.""" surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.observation.render_data.map))
python
def draw_rendered_map(self, surf): """Draw the rendered pixels.""" surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.observation.render_data.map))
[ "def", "draw_rendered_map", "(", "self", ",", "surf", ")", ":", "surf", ".", "blit_np_array", "(", "features", ".", "Feature", ".", "unpack_rgb_image", "(", "self", ".", "_obs", ".", "observation", ".", "render_data", ".", "map", ")", ")" ]
Draw the rendered pixels.
[ "Draw", "the", "rendered", "pixels", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1346-L1349
train
Draw the rendered pixels.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_screen
def draw_screen(self, surf): """Draw the screen area.""" # surf.fill(colors.black) if (self._render_rgb and self._obs.observation.HasField("render_data") and self._obs.observation.render_data.HasField("map")): self.draw_rendered_map(surf) else: self.draw_base_map(surf) self.dra...
python
def draw_screen(self, surf): """Draw the screen area.""" # surf.fill(colors.black) if (self._render_rgb and self._obs.observation.HasField("render_data") and self._obs.observation.render_data.HasField("map")): self.draw_rendered_map(surf) else: self.draw_base_map(surf) self.dra...
[ "def", "draw_screen", "(", "self", ",", "surf", ")", ":", "# surf.fill(colors.black)", "if", "(", "self", ".", "_render_rgb", "and", "self", ".", "_obs", ".", "observation", ".", "HasField", "(", "\"render_data\"", ")", "and", "self", ".", "_obs", ".", "ob...
Draw the screen area.
[ "Draw", "the", "screen", "area", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1351-L1364
train
Draw the screen area.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
deepmind/pysc2
pysc2/lib/renderer_human.py
RendererHuman.draw_feature_layer
def draw_feature_layer(self, surf, feature): """Draw a feature layer.""" layer = feature.unpack(self._obs.observation) if layer is not None: surf.blit_np_array(feature.color(layer)) else: # Ignore layers that aren't in this version of SC2. surf.surf.fill(colors.black)
python
def draw_feature_layer(self, surf, feature): """Draw a feature layer.""" layer = feature.unpack(self._obs.observation) if layer is not None: surf.blit_np_array(feature.color(layer)) else: # Ignore layers that aren't in this version of SC2. surf.surf.fill(colors.black)
[ "def", "draw_feature_layer", "(", "self", ",", "surf", ",", "feature", ")", ":", "layer", "=", "feature", ".", "unpack", "(", "self", ".", "_obs", ".", "observation", ")", "if", "layer", "is", "not", "None", ":", "surf", ".", "blit_np_array", "(", "fea...
Draw a feature layer.
[ "Draw", "a", "feature", "layer", "." ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1367-L1373
train
Draw a feature layer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...