partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
UMAP.fit_transform
Fit X into an embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) If the metric is 'precomputed' X must be a square distance matrix. Otherwise it contains a sample per row. ...
umap/umap_.py
def fit_transform(self, X, y=None): """Fit X into an embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) If the metric is 'precomputed' X must be a square distance mat...
def fit_transform(self, X, y=None): """Fit X into an embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) If the metric is 'precomputed' X must be a square distance mat...
[ "Fit", "X", "into", "an", "embedded", "space", "and", "return", "that", "transformed", "output", "." ]
lmcinnes/umap
python
https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L1568-L1590
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "self", ".", "fit", "(", "X", ",", "y", ")", "return", "self", ".", "embedding_" ]
bbb01c03ba49f7bff8f77fd662d00e50d6686c77
train
UMAP.transform
Transform X into the existing embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) New data to be transformed. Returns ------- X_new : array, shape (n_samples, n_components) Emb...
umap/umap_.py
def transform(self, X): """Transform X into the existing embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) New data to be transformed. Returns ------- X_new : array, shape (n_sam...
def transform(self, X): """Transform X into the existing embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) New data to be transformed. Returns ------- X_new : array, shape (n_sam...
[ "Transform", "X", "into", "the", "existing", "embedded", "space", "and", "return", "that", "transformed", "output", "." ]
lmcinnes/umap
python
https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L1592-L1712
[ "def", "transform", "(", "self", ",", "X", ")", ":", "# If we fit just a single instance then error", "if", "self", ".", "embedding_", ".", "shape", "[", "0", "]", "==", "1", ":", "raise", "ValueError", "(", "'Transform unavailable when model was fit with'", "'only ...
bbb01c03ba49f7bff8f77fd662d00e50d6686c77
train
make_sparse_nn_descent
Create a numba accelerated version of nearest neighbor descent specialised for the given distance metric and metric arguments on sparse matrix data provided in CSR ind, indptr and data format. Numba doesn't support higher order functions directly, but we can instead JIT compile the version of NN-descent...
umap/sparse.py
def make_sparse_nn_descent(sparse_dist, dist_args): """Create a numba accelerated version of nearest neighbor descent specialised for the given distance metric and metric arguments on sparse matrix data provided in CSR ind, indptr and data format. Numba doesn't support higher order functions directly, b...
def make_sparse_nn_descent(sparse_dist, dist_args): """Create a numba accelerated version of nearest neighbor descent specialised for the given distance metric and metric arguments on sparse matrix data provided in CSR ind, indptr and data format. Numba doesn't support higher order functions directly, b...
[ "Create", "a", "numba", "accelerated", "version", "of", "nearest", "neighbor", "descent", "specialised", "for", "the", "given", "distance", "metric", "and", "metric", "arguments", "on", "sparse", "matrix", "data", "provided", "in", "CSR", "ind", "indptr", "and",...
lmcinnes/umap
python
https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/sparse.py#L152-L283
[ "def", "make_sparse_nn_descent", "(", "sparse_dist", ",", "dist_args", ")", ":", "@", "numba", ".", "njit", "(", "parallel", "=", "True", ")", "def", "nn_descent", "(", "inds", ",", "indptr", ",", "data", ",", "n_vertices", ",", "n_neighbors", ",", "rng_st...
bbb01c03ba49f7bff8f77fd662d00e50d6686c77
train
interface_options
Get an InterfaceOptions for the config.
pysc2/bin/benchmark_observe.py
def interface_options(score=False, raw=False, features=None, rgb=None): """Get an InterfaceOptions for the config.""" interface = sc_pb.InterfaceOptions() interface.score = score interface.raw = raw if features: interface.feature_layer.width = 24 interface.feature_layer.resolution.x = features int...
def interface_options(score=False, raw=False, features=None, rgb=None): """Get an InterfaceOptions for the config.""" interface = sc_pb.InterfaceOptions() interface.score = score interface.raw = raw if features: interface.feature_layer.width = 24 interface.feature_layer.resolution.x = features int...
[ "Get", "an", "InterfaceOptions", "for", "the", "config", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/benchmark_observe.py#L39-L55
[ "def", "interface_options", "(", "score", "=", "False", ",", "raw", "=", "False", ",", "features", "=", "None", ",", "rgb", "=", "None", ")", ":", "interface", "=", "sc_pb", ".", "InterfaceOptions", "(", ")", "interface", ".", "score", "=", "score", "i...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
DEFINE_point
Registers a flag whose value parses as a point.
pysc2/lib/point_flag.py
def DEFINE_point(name, default, help): # pylint: disable=invalid-name,redefined-builtin """Registers a flag whose value parses as a point.""" flags.DEFINE(PointParser(), name, default, help)
def DEFINE_point(name, default, help): # pylint: disable=invalid-name,redefined-builtin """Registers a flag whose value parses as a point.""" flags.DEFINE(PointParser(), name, default, help)
[ "Registers", "a", "flag", "whose", "value", "parses", "as", "a", "point", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point_flag.py#L56-L58
[ "def", "DEFINE_point", "(", "name", ",", "default", ",", "help", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "flags", ".", "DEFINE", "(", "PointParser", "(", ")", ",", "name", ",", "default", ",", "help", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
spatial
Choose the action space for the action proto.
pysc2/lib/actions.py
def spatial(action, action_space): """Choose the action space for the action proto.""" if action_space == ActionSpace.FEATURES: return action.action_feature_layer elif action_space == ActionSpace.RGB: return action.action_render else: raise ValueError("Unexpected value for action_space: %s" % action...
def spatial(action, action_space): """Choose the action space for the action proto.""" if action_space == ActionSpace.FEATURES: return action.action_feature_layer elif action_space == ActionSpace.RGB: return action.action_render else: raise ValueError("Unexpected value for action_space: %s" % action...
[ "Choose", "the", "action", "space", "for", "the", "action", "proto", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L36-L43
[ "def", "spatial", "(", "action", ",", "action_space", ")", ":", "if", "action_space", "==", "ActionSpace", ".", "FEATURES", ":", "return", "action", ".", "action_feature_layer", "elif", "action_space", "==", "ActionSpace", ".", "RGB", ":", "return", "action", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
move_camera
Move the camera.
pysc2/lib/actions.py
def move_camera(action, action_space, minimap): """Move the camera.""" minimap.assign_to(spatial(action, action_space).camera_move.center_minimap)
def move_camera(action, action_space, minimap): """Move the camera.""" minimap.assign_to(spatial(action, action_space).camera_move.center_minimap)
[ "Move", "the", "camera", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L50-L52
[ "def", "move_camera", "(", "action", ",", "action_space", ",", "minimap", ")", ":", "minimap", ".", "assign_to", "(", "spatial", "(", "action", ",", "action_space", ")", ".", "camera_move", ".", "center_minimap", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
select_point
Select a unit at a point.
pysc2/lib/actions.py
def select_point(action, action_space, select_point_act, screen): """Select a unit at a point.""" select = spatial(action, action_space).unit_selection_point screen.assign_to(select.selection_screen_coord) select.type = select_point_act
def select_point(action, action_space, select_point_act, screen): """Select a unit at a point.""" select = spatial(action, action_space).unit_selection_point screen.assign_to(select.selection_screen_coord) select.type = select_point_act
[ "Select", "a", "unit", "at", "a", "point", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L55-L59
[ "def", "select_point", "(", "action", ",", "action_space", ",", "select_point_act", ",", "screen", ")", ":", "select", "=", "spatial", "(", "action", ",", "action_space", ")", ".", "unit_selection_point", "screen", ".", "assign_to", "(", "select", ".", "select...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
select_rect
Select units within a rectangle.
pysc2/lib/actions.py
def select_rect(action, action_space, select_add, screen, screen2): """Select units within a rectangle.""" select = spatial(action, action_space).unit_selection_rect out_rect = select.selection_screen_coord.add() screen_rect = point.Rect(screen, screen2) screen_rect.tl.assign_to(out_rect.p0) screen_rect.br....
def select_rect(action, action_space, select_add, screen, screen2): """Select units within a rectangle.""" select = spatial(action, action_space).unit_selection_rect out_rect = select.selection_screen_coord.add() screen_rect = point.Rect(screen, screen2) screen_rect.tl.assign_to(out_rect.p0) screen_rect.br....
[ "Select", "units", "within", "a", "rectangle", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L62-L69
[ "def", "select_rect", "(", "action", ",", "action_space", ",", "select_add", ",", "screen", ",", "screen2", ")", ":", "select", "=", "spatial", "(", "action", ",", "action_space", ")", ".", "unit_selection_rect", "out_rect", "=", "select", ".", "selection_scre...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
select_idle_worker
Select an idle worker.
pysc2/lib/actions.py
def select_idle_worker(action, action_space, select_worker): """Select an idle worker.""" del action_space action.action_ui.select_idle_worker.type = select_worker
def select_idle_worker(action, action_space, select_worker): """Select an idle worker.""" del action_space action.action_ui.select_idle_worker.type = select_worker
[ "Select", "an", "idle", "worker", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L72-L75
[ "def", "select_idle_worker", "(", "action", ",", "action_space", ",", "select_worker", ")", ":", "del", "action_space", "action", ".", "action_ui", ".", "select_idle_worker", ".", "type", "=", "select_worker" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
select_army
Select the entire army.
pysc2/lib/actions.py
def select_army(action, action_space, select_add): """Select the entire army.""" del action_space action.action_ui.select_army.selection_add = select_add
def select_army(action, action_space, select_add): """Select the entire army.""" del action_space action.action_ui.select_army.selection_add = select_add
[ "Select", "the", "entire", "army", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L78-L81
[ "def", "select_army", "(", "action", ",", "action_space", ",", "select_add", ")", ":", "del", "action_space", "action", ".", "action_ui", ".", "select_army", ".", "selection_add", "=", "select_add" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
select_warp_gates
Select all warp gates.
pysc2/lib/actions.py
def select_warp_gates(action, action_space, select_add): """Select all warp gates.""" del action_space action.action_ui.select_warp_gates.selection_add = select_add
def select_warp_gates(action, action_space, select_add): """Select all warp gates.""" del action_space action.action_ui.select_warp_gates.selection_add = select_add
[ "Select", "all", "warp", "gates", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L84-L87
[ "def", "select_warp_gates", "(", "action", ",", "action_space", ",", "select_add", ")", ":", "del", "action_space", "action", ".", "action_ui", ".", "select_warp_gates", ".", "selection_add", "=", "select_add" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
select_unit
Select a specific unit from the multi-unit selection.
pysc2/lib/actions.py
def select_unit(action, action_space, select_unit_act, select_unit_id): """Select a specific unit from the multi-unit selection.""" del action_space select = action.action_ui.multi_panel select.type = select_unit_act select.unit_index = select_unit_id
def select_unit(action, action_space, select_unit_act, select_unit_id): """Select a specific unit from the multi-unit selection.""" del action_space select = action.action_ui.multi_panel select.type = select_unit_act select.unit_index = select_unit_id
[ "Select", "a", "specific", "unit", "from", "the", "multi", "-", "unit", "selection", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L96-L101
[ "def", "select_unit", "(", "action", ",", "action_space", ",", "select_unit_act", ",", "select_unit_id", ")", ":", "del", "action_space", "select", "=", "action", ".", "action_ui", ".", "multi_panel", "select", ".", "type", "=", "select_unit_act", "select", ".",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
control_group
Act on a control group, selecting, setting, etc.
pysc2/lib/actions.py
def control_group(action, action_space, control_group_act, control_group_id): """Act on a control group, selecting, setting, etc.""" del action_space select = action.action_ui.control_group select.action = control_group_act select.control_group_index = control_group_id
def control_group(action, action_space, control_group_act, control_group_id): """Act on a control group, selecting, setting, etc.""" del action_space select = action.action_ui.control_group select.action = control_group_act select.control_group_index = control_group_id
[ "Act", "on", "a", "control", "group", "selecting", "setting", "etc", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L104-L109
[ "def", "control_group", "(", "action", ",", "action_space", ",", "control_group_act", ",", "control_group_id", ")", ":", "del", "action_space", "select", "=", "action", ".", "action_ui", ".", "control_group", "select", ".", "action", "=", "control_group_act", "sel...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
unload
Unload a unit from a transport/bunker/nydus/etc.
pysc2/lib/actions.py
def unload(action, action_space, unload_id): """Unload a unit from a transport/bunker/nydus/etc.""" del action_space action.action_ui.cargo_panel.unit_index = unload_id
def unload(action, action_space, unload_id): """Unload a unit from a transport/bunker/nydus/etc.""" del action_space action.action_ui.cargo_panel.unit_index = unload_id
[ "Unload", "a", "unit", "from", "a", "transport", "/", "bunker", "/", "nydus", "/", "etc", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L112-L115
[ "def", "unload", "(", "action", ",", "action_space", ",", "unload_id", ")", ":", "del", "action_space", "action", ".", "action_ui", ".", "cargo_panel", ".", "unit_index", "=", "unload_id" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
build_queue
Cancel a unit in the build queue.
pysc2/lib/actions.py
def build_queue(action, action_space, build_queue_id): """Cancel a unit in the build queue.""" del action_space action.action_ui.production_panel.unit_index = build_queue_id
def build_queue(action, action_space, build_queue_id): """Cancel a unit in the build queue.""" del action_space action.action_ui.production_panel.unit_index = build_queue_id
[ "Cancel", "a", "unit", "in", "the", "build", "queue", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L118-L121
[ "def", "build_queue", "(", "action", ",", "action_space", ",", "build_queue_id", ")", ":", "del", "action_space", "action", ".", "action_ui", ".", "production_panel", ".", "unit_index", "=", "build_queue_id" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
cmd_quick
Do a quick command like 'Stop' or 'Stim'.
pysc2/lib/actions.py
def cmd_quick(action, action_space, ability_id, queued): """Do a quick command like 'Stop' or 'Stim'.""" action_cmd = spatial(action, action_space).unit_command action_cmd.ability_id = ability_id action_cmd.queue_command = queued
def cmd_quick(action, action_space, ability_id, queued): """Do a quick command like 'Stop' or 'Stim'.""" action_cmd = spatial(action, action_space).unit_command action_cmd.ability_id = ability_id action_cmd.queue_command = queued
[ "Do", "a", "quick", "command", "like", "Stop", "or", "Stim", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L124-L128
[ "def", "cmd_quick", "(", "action", ",", "action_space", ",", "ability_id", ",", "queued", ")", ":", "action_cmd", "=", "spatial", "(", "action", ",", "action_space", ")", ".", "unit_command", "action_cmd", ".", "ability_id", "=", "ability_id", "action_cmd", "....
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
cmd_screen
Do a command that needs a point on the screen.
pysc2/lib/actions.py
def cmd_screen(action, action_space, ability_id, queued, screen): """Do a command that needs a point on the screen.""" action_cmd = spatial(action, action_space).unit_command action_cmd.ability_id = ability_id action_cmd.queue_command = queued screen.assign_to(action_cmd.target_screen_coord)
def cmd_screen(action, action_space, ability_id, queued, screen): """Do a command that needs a point on the screen.""" action_cmd = spatial(action, action_space).unit_command action_cmd.ability_id = ability_id action_cmd.queue_command = queued screen.assign_to(action_cmd.target_screen_coord)
[ "Do", "a", "command", "that", "needs", "a", "point", "on", "the", "screen", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L131-L136
[ "def", "cmd_screen", "(", "action", ",", "action_space", ",", "ability_id", ",", "queued", ",", "screen", ")", ":", "action_cmd", "=", "spatial", "(", "action", ",", "action_space", ")", ".", "unit_command", "action_cmd", ".", "ability_id", "=", "ability_id", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
cmd_minimap
Do a command that needs a point on the minimap.
pysc2/lib/actions.py
def cmd_minimap(action, action_space, ability_id, queued, minimap): """Do a command that needs a point on the minimap.""" action_cmd = spatial(action, action_space).unit_command action_cmd.ability_id = ability_id action_cmd.queue_command = queued minimap.assign_to(action_cmd.target_minimap_coord)
def cmd_minimap(action, action_space, ability_id, queued, minimap): """Do a command that needs a point on the minimap.""" action_cmd = spatial(action, action_space).unit_command action_cmd.ability_id = ability_id action_cmd.queue_command = queued minimap.assign_to(action_cmd.target_minimap_coord)
[ "Do", "a", "command", "that", "needs", "a", "point", "on", "the", "minimap", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L139-L144
[ "def", "cmd_minimap", "(", "action", ",", "action_space", ",", "ability_id", ",", "queued", ",", "minimap", ")", ":", "action_cmd", "=", "spatial", "(", "action", ",", "action_space", ")", ".", "unit_command", "action_cmd", ".", "ability_id", "=", "ability_id"...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
autocast
Toggle autocast.
pysc2/lib/actions.py
def autocast(action, action_space, ability_id): """Toggle autocast.""" del action_space action.action_ui.toggle_autocast.ability_id = ability_id
def autocast(action, action_space, ability_id): """Toggle autocast.""" del action_space action.action_ui.toggle_autocast.ability_id = ability_id
[ "Toggle", "autocast", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L147-L150
[ "def", "autocast", "(", "action", ",", "action_space", ",", "ability_id", ")", ":", "del", "action_space", "action", ".", "action_ui", ".", "toggle_autocast", ".", "ability_id", "=", "ability_id" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
ArgumentType.enum
Create an ArgumentType where you choose one of a set of known values.
pysc2/lib/actions.py
def enum(cls, options, values): """Create an ArgumentType where you choose one of a set of known values.""" names, real = zip(*options) del names # unused def factory(i, name): return cls(i, name, (len(real),), lambda a: real[a[0]], values) return factory
def enum(cls, options, values): """Create an ArgumentType where you choose one of a set of known values.""" names, real = zip(*options) del names # unused def factory(i, name): return cls(i, name, (len(real),), lambda a: real[a[0]], values) return factory
[ "Create", "an", "ArgumentType", "where", "you", "choose", "one", "of", "a", "set", "of", "known", "values", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L175-L182
[ "def", "enum", "(", "cls", ",", "options", ",", "values", ")", ":", "names", ",", "real", "=", "zip", "(", "*", "options", ")", "del", "names", "# unused", "def", "factory", "(", "i", ",", "name", ")", ":", "return", "cls", "(", "i", ",", "name",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
ArgumentType.scalar
Create an ArgumentType with a single scalar in range(value).
pysc2/lib/actions.py
def scalar(cls, value): """Create an ArgumentType with a single scalar in range(value).""" return lambda i, name: cls(i, name, (value,), lambda a: a[0], None)
def scalar(cls, value): """Create an ArgumentType with a single scalar in range(value).""" return lambda i, name: cls(i, name, (value,), lambda a: a[0], None)
[ "Create", "an", "ArgumentType", "with", "a", "single", "scalar", "in", "range", "(", "value", ")", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L185-L187
[ "def", "scalar", "(", "cls", ",", "value", ")", ":", "return", "lambda", "i", ",", "name", ":", "cls", "(", "i", ",", "name", ",", "(", "value", ",", ")", ",", "lambda", "a", ":", "a", "[", "0", "]", ",", "None", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
ArgumentType.point
Create an ArgumentType that is represented by a point.Point.
pysc2/lib/actions.py
def point(cls): # No range because it's unknown at this time. """Create an ArgumentType that is represented by a point.Point.""" def factory(i, name): return cls(i, name, (0, 0), lambda a: point.Point(*a).floor(), None) return factory
def point(cls): # No range because it's unknown at this time. """Create an ArgumentType that is represented by a point.Point.""" def factory(i, name): return cls(i, name, (0, 0), lambda a: point.Point(*a).floor(), None) return factory
[ "Create", "an", "ArgumentType", "that", "is", "represented", "by", "a", "point", ".", "Point", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L190-L194
[ "def", "point", "(", "cls", ")", ":", "# No range because it's unknown at this time.", "def", "factory", "(", "i", ",", "name", ")", ":", "return", "cls", "(", "i", ",", "name", ",", "(", "0", ",", "0", ")", ",", "lambda", "a", ":", "point", ".", "Po...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Arguments.types
Create an Arguments of the possible Types.
pysc2/lib/actions.py
def types(cls, **kwargs): """Create an Arguments of the possible Types.""" named = {name: factory(Arguments._fields.index(name), name) for name, factory in six.iteritems(kwargs)} return cls(**named)
def types(cls, **kwargs): """Create an Arguments of the possible Types.""" named = {name: factory(Arguments._fields.index(name), name) for name, factory in six.iteritems(kwargs)} return cls(**named)
[ "Create", "an", "Arguments", "of", "the", "possible", "Types", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L229-L233
[ "def", "types", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "named", "=", "{", "name", ":", "factory", "(", "Arguments", ".", "_fields", ".", "index", "(", "name", ")", ",", "name", ")", "for", "name", ",", "factory", "in", "six", ".", "iterit...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Function.ui_func
Define a function representing a ui action.
pysc2/lib/actions.py
def ui_func(cls, id_, name, function_type, avail_fn=always): """Define a function representing a ui action.""" return cls(id_, name, 0, 0, function_type, FUNCTION_TYPES[function_type], avail_fn)
def ui_func(cls, id_, name, function_type, avail_fn=always): """Define a function representing a ui action.""" return cls(id_, name, 0, 0, function_type, FUNCTION_TYPES[function_type], avail_fn)
[ "Define", "a", "function", "representing", "a", "ui", "action", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L366-L369
[ "def", "ui_func", "(", "cls", ",", "id_", ",", "name", ",", "function_type", ",", "avail_fn", "=", "always", ")", ":", "return", "cls", "(", "id_", ",", "name", ",", "0", ",", "0", ",", "function_type", ",", "FUNCTION_TYPES", "[", "function_type", "]",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Function.ability
Define a function represented as a game ability.
pysc2/lib/actions.py
def ability(cls, id_, name, function_type, ability_id, general_id=0): """Define a function represented as a game ability.""" assert function_type in ABILITY_FUNCTIONS return cls(id_, name, ability_id, general_id, function_type, FUNCTION_TYPES[function_type], None)
def ability(cls, id_, name, function_type, ability_id, general_id=0): """Define a function represented as a game ability.""" assert function_type in ABILITY_FUNCTIONS return cls(id_, name, ability_id, general_id, function_type, FUNCTION_TYPES[function_type], None)
[ "Define", "a", "function", "represented", "as", "a", "game", "ability", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L372-L376
[ "def", "ability", "(", "cls", ",", "id_", ",", "name", ",", "function_type", ",", "ability_id", ",", "general_id", "=", "0", ")", ":", "assert", "function_type", "in", "ABILITY_FUNCTIONS", "return", "cls", "(", "id_", ",", "name", ",", "ability_id", ",", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Function.str
String version. Set space=True to line them all up nicely.
pysc2/lib/actions.py
def str(self, space=False): """String version. Set space=True to line them all up nicely.""" return "%s/%s (%s)" % (str(int(self.id)).rjust(space and 4), self.name.ljust(space and 50), "; ".join(str(a) for a in self.args))
def str(self, space=False): """String version. Set space=True to line them all up nicely.""" return "%s/%s (%s)" % (str(int(self.id)).rjust(space and 4), self.name.ljust(space and 50), "; ".join(str(a) for a in self.args))
[ "String", "version", ".", "Set", "space", "=", "True", "to", "line", "them", "all", "up", "nicely", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L396-L400
[ "def", "str", "(", "self", ",", "space", "=", "False", ")", ":", "return", "\"%s/%s (%s)\"", "%", "(", "str", "(", "int", "(", "self", ".", "id", ")", ")", ".", "rjust", "(", "space", "and", "4", ")", ",", "self", ".", "name", ".", "ljust", "("...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
FunctionCall.init_with_validation
Return a `FunctionCall` given some validation for the function and args. Args: function: A function name or id, to be converted into a function id enum. arguments: An iterable of function arguments. Arguments that are enum types can be passed by name. Arguments that only take one value (ie ...
pysc2/lib/actions.py
def init_with_validation(cls, function, arguments): """Return a `FunctionCall` given some validation for the function and args. Args: function: A function name or id, to be converted into a function id enum. arguments: An iterable of function arguments. Arguments that are enum types can b...
def init_with_validation(cls, function, arguments): """Return a `FunctionCall` given some validation for the function and args. Args: function: A function name or id, to be converted into a function id enum. arguments: An iterable of function arguments. Arguments that are enum types can b...
[ "Return", "a", "FunctionCall", "given", "some", "validation", "for", "the", "function", "and", "args", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L1039-L1077
[ "def", "init_with_validation", "(", "cls", ",", "function", ",", "arguments", ")", ":", "func", "=", "FUNCTIONS", "[", "function", "]", "args", "=", "[", "]", "for", "arg", ",", "arg_type", "in", "zip", "(", "arguments", ",", "func", ".", "args", ")", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
FunctionCall.all_arguments
Helper function for creating `FunctionCall`s with `Arguments`. Args: function: The value to store for the action function. arguments: The values to store for the arguments of the action. Can either be an `Arguments` object, a `dict`, or an iterable. If a `dict` or an iterable is provide...
pysc2/lib/actions.py
def all_arguments(cls, function, arguments): """Helper function for creating `FunctionCall`s with `Arguments`. Args: function: The value to store for the action function. arguments: The values to store for the arguments of the action. Can either be an `Arguments` object, a `dict`, or an ite...
def all_arguments(cls, function, arguments): """Helper function for creating `FunctionCall`s with `Arguments`. Args: function: The value to store for the action function. arguments: The values to store for the arguments of the action. Can either be an `Arguments` object, a `dict`, or an ite...
[ "Helper", "function", "for", "creating", "FunctionCall", "s", "with", "Arguments", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/actions.py#L1080-L1097
[ "def", "all_arguments", "(", "cls", ",", "function", ",", "arguments", ")", ":", "if", "isinstance", "(", "arguments", ",", "dict", ")", ":", "arguments", "=", "Arguments", "(", "*", "*", "arguments", ")", "elif", "not", "isinstance", "(", "arguments", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
main
Print the valid actions.
pysc2/bin/valid_actions.py
def main(unused_argv): """Print the valid actions.""" feats = features.Features( # Actually irrelevant whether it's feature or rgb size. features.AgentInterfaceFormat( feature_dimensions=features.Dimensions( screen=FLAGS.screen_size, minimap=FLAGS.minimap_size))) ...
def main(unused_argv): """Print the valid actions.""" feats = features.Features( # Actually irrelevant whether it's feature or rgb size. features.AgentInterfaceFormat( feature_dimensions=features.Dimensions( screen=FLAGS.screen_size, minimap=FLAGS.minimap_size))) ...
[ "Print", "the", "valid", "actions", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/valid_actions.py#L34-L56
[ "def", "main", "(", "unused_argv", ")", ":", "feats", "=", "features", ".", "Features", "(", "# Actually irrelevant whether it's feature or rgb size.", "features", ".", "AgentInterfaceFormat", "(", "feature_dimensions", "=", "features", ".", "Dimensions", "(", "screen",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
pick_unused_ports
Reserves and returns a list of `num_ports` unused ports.
pysc2/lib/portspicker.py
def pick_unused_ports(num_ports, retry_interval_secs=3, retry_attempts=5): """Reserves and returns a list of `num_ports` unused ports.""" ports = set() for _ in range(retry_attempts): ports.update( portpicker.pick_unused_port() for _ in range(num_ports - len(ports))) ports.discard(None) # portpic...
def pick_unused_ports(num_ports, retry_interval_secs=3, retry_attempts=5): """Reserves and returns a list of `num_ports` unused ports.""" ports = set() for _ in range(retry_attempts): ports.update( portpicker.pick_unused_port() for _ in range(num_ports - len(ports))) ports.discard(None) # portpic...
[ "Reserves", "and", "returns", "a", "list", "of", "num_ports", "unused", "ports", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/portspicker.py#L24-L40
[ "def", "pick_unused_ports", "(", "num_ports", ",", "retry_interval_secs", "=", "3", ",", "retry_attempts", "=", "5", ")", ":", "ports", "=", "set", "(", ")", "for", "_", "in", "range", "(", "retry_attempts", ")", ":", "ports", ".", "update", "(", "portpi...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
pick_contiguous_unused_ports
Reserves and returns a list of `num_ports` contiguous unused ports.
pysc2/lib/portspicker.py
def pick_contiguous_unused_ports( num_ports, retry_interval_secs=3, retry_attempts=5): """Reserves and returns a list of `num_ports` contiguous unused ports.""" for _ in range(retry_attempts): start_port = portpicker.pick_unused_port() if start_port is not None: ports = [start_port + p for...
def pick_contiguous_unused_ports( num_ports, retry_interval_secs=3, retry_attempts=5): """Reserves and returns a list of `num_ports` contiguous unused ports.""" for _ in range(retry_attempts): start_port = portpicker.pick_unused_port() if start_port is not None: ports = [start_port + p for...
[ "Reserves", "and", "returns", "a", "list", "of", "num_ports", "contiguous", "unused", "ports", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/portspicker.py#L43-L59
[ "def", "pick_contiguous_unused_ports", "(", "num_ports", ",", "retry_interval_secs", "=", "3", ",", "retry_attempts", "=", "5", ")", ":", "for", "_", "in", "range", "(", "retry_attempts", ")", ":", "start_port", "=", "portpicker", ".", "pick_unused_port", "(", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
run_thread
Run one thread worth of the environment with agents.
pysc2/bin/agent.py
def run_thread(agent_classes, players, map_name, visualize): """Run one thread worth of the environment with agents.""" with sc2_env.SC2Env( map_name=map_name, players=players, agent_interface_format=sc2_env.parse_agent_interface_format( feature_screen=FLAGS.feature_screen_size, ...
def run_thread(agent_classes, players, map_name, visualize): """Run one thread worth of the environment with agents.""" with sc2_env.SC2Env( map_name=map_name, players=players, agent_interface_format=sc2_env.parse_agent_interface_format( feature_screen=FLAGS.feature_screen_size, ...
[ "Run", "one", "thread", "worth", "of", "the", "environment", "with", "agents", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/agent.py#L83-L103
[ "def", "run_thread", "(", "agent_classes", ",", "players", ",", "map_name", ",", "visualize", ")", ":", "with", "sc2_env", ".", "SC2Env", "(", "map_name", "=", "map_name", ",", "players", "=", "players", ",", "agent_interface_format", "=", "sc2_env", ".", "p...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
main
Run an agent.
pysc2/bin/agent.py
def main(unused_argv): """Run an agent.""" stopwatch.sw.enabled = FLAGS.profile or FLAGS.trace stopwatch.sw.trace = FLAGS.trace map_inst = maps.get(FLAGS.map) agent_classes = [] players = [] agent_module, agent_name = FLAGS.agent.rsplit(".", 1) agent_cls = getattr(importlib.import_module(agent_module...
def main(unused_argv): """Run an agent.""" stopwatch.sw.enabled = FLAGS.profile or FLAGS.trace stopwatch.sw.trace = FLAGS.trace map_inst = maps.get(FLAGS.map) agent_classes = [] players = [] agent_module, agent_name = FLAGS.agent.rsplit(".", 1) agent_cls = getattr(importlib.import_module(agent_module...
[ "Run", "an", "agent", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/agent.py#L106-L146
[ "def", "main", "(", "unused_argv", ")", ":", "stopwatch", ".", "sw", ".", "enabled", "=", "FLAGS", ".", "profile", "or", "FLAGS", ".", "trace", "stopwatch", ".", "sw", ".", "trace", "=", "FLAGS", ".", "trace", "map_inst", "=", "maps", ".", "get", "("...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
check_error
Raise if the result has an error, otherwise return the result.
pysc2/lib/remote_controller.py
def check_error(res, error_enum): """Raise if the result has an error, otherwise return the result.""" if res.HasField("error"): enum_name = error_enum.DESCRIPTOR.full_name error_name = error_enum.Name(res.error) details = getattr(res, "error_details", "<none>") raise RequestError("%s.%s: '%s'" % (e...
def check_error(res, error_enum): """Raise if the result has an error, otherwise return the result.""" if res.HasField("error"): enum_name = error_enum.DESCRIPTOR.full_name error_name = error_enum.Name(res.error) details = getattr(res, "error_details", "<none>") raise RequestError("%s.%s: '%s'" % (e...
[ "Raise", "if", "the", "result", "has", "an", "error", "otherwise", "return", "the", "result", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L56-L63
[ "def", "check_error", "(", "res", ",", "error_enum", ")", ":", "if", "res", ".", "HasField", "(", "\"error\"", ")", ":", "enum_name", "=", "error_enum", ".", "DESCRIPTOR", ".", "full_name", "error_name", "=", "error_enum", ".", "Name", "(", "res", ".", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
decorate_check_error
Decorator to call `check_error` on the return value.
pysc2/lib/remote_controller.py
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): """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
[ "Decorator", "to", "call", "check_error", "on", "the", "return", "value", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L66-L73
[ "def", "decorate_check_error", "(", "error_enum", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_check_error", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "check_error", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
skip_status
Decorator to skip this call if we're in one of the skipped states.
pysc2/lib/remote_controller.py
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): """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
[ "Decorator", "to", "skip", "this", "call", "if", "we", "re", "in", "one", "of", "the", "skipped", "states", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L76-L84
[ "def", "skip_status", "(", "*", "skipped", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_skip_status", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
valid_status
Decorator to assert that we're in a valid state.
pysc2/lib/remote_controller.py
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): """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)" % ( ...
[ "Decorator", "to", "assert", "that", "we", "re", "in", "a", "valid", "state", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L87-L98
[ "def", "valid_status", "(", "*", "valid", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_valid_status", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
catch_game_end
Decorator to handle 'Game has already ended' exceptions.
pysc2/lib/remote_controller.py
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): """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 ...
[ "Decorator", "to", "handle", "Game", "has", "already", "ended", "exceptions", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L101-L126
[ "def", "catch_game_end", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_catch_game_end", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Decorator to handle 'Game has already ended' exceptions.\"\"\"", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController._connect
Connect to the websocket, retrying as needed. Returns the socket.
pysc2/lib/remote_controller.py
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): """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...
[ "Connect", "to", "the", "websocket", "retrying", "as", "needed", ".", "Returns", "the", "socket", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L148-L174
[ "def", "_connect", "(", "self", ",", "host", ",", "port", ",", "proc", ",", "timeout_seconds", ")", ":", "if", "\":\"", "in", "host", "and", "not", "host", ".", "startswith", "(", "\"[\"", ")", ":", "# Support ipv6 addresses.", "host", "=", "\"[%s]\"", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.save_map
Save a map into temp dir so create game can access it in multiplayer.
pysc2/lib/remote_controller.py
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): """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))
[ "Save", "a", "map", "into", "temp", "dir", "so", "create", "game", "can", "access", "it", "in", "multiplayer", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L189-L192
[ "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", ")", ")" ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.data_raw
Get the raw static data for the current game. Prefer `data` instead.
pysc2/lib/remote_controller.py
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): """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))
[ "Get", "the", "raw", "static", "data", "for", "the", "current", "game", ".", "Prefer", "data", "instead", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L223-L226
[ "def", "data_raw", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "data", "=", "sc_pb", ".", "RequestData", "(", "ability_id", "=", "True", ",", "unit_type_id", "=", "True", ")", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.step
Step the engine forward by one (or more) step.
pysc2/lib/remote_controller.py
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): """Step the engine forward by one (or more) step.""" return self._client.send(step=sc_pb.RequestStep(count=count))
[ "Step", "the", "engine", "forward", "by", "one", "(", "or", "more", ")", "step", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L240-L242
[ "def", "step", "(", "self", ",", "count", "=", "1", ")", ":", "return", "self", ".", "_client", ".", "send", "(", "step", "=", "sc_pb", ".", "RequestStep", "(", "count", "=", "count", ")", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.actions
Send a `sc_pb.RequestAction`, which may include multiple actions.
pysc2/lib/remote_controller.py
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): """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)
[ "Send", "a", "sc_pb", ".", "RequestAction", "which", "may", "include", "multiple", "actions", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L248-L255
[ "def", "actions", "(", "self", ",", "req_action", ")", ":", "if", "FLAGS", ".", "sc2_log_actions", ":", "for", "action", "in", "req_action", ".", "actions", ":", "sys", ".", "stderr", ".", "write", "(", "str", "(", "action", ")", ")", "sys", ".", "st...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.act
Send a single action. This is a shortcut for `actions`.
pysc2/lib/remote_controller.py
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): """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]))
[ "Send", "a", "single", "action", ".", "This", "is", "a", "shortcut", "for", "actions", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L257-L260
[ "def", "act", "(", "self", ",", "action", ")", ":", "if", "action", "and", "action", ".", "ListFields", "(", ")", ":", "# Skip no-ops.", "return", "self", ".", "actions", "(", "sc_pb", ".", "RequestAction", "(", "actions", "=", "[", "action", "]", ")",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.chat
Send chat message as a broadcast.
pysc2/lib/remote_controller.py
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): """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)
[ "Send", "chat", "message", "as", "a", "broadcast", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L262-L268
[ "def", "chat", "(", "self", ",", "message", ")", ":", "if", "message", ":", "action_chat", "=", "sc_pb", ".", "ActionChat", "(", "channel", "=", "sc_pb", ".", "ActionChat", ".", "Broadcast", ",", "message", "=", "message", ")", "action", "=", "sc_pb", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.save_replay
Save a replay, returning the data.
pysc2/lib/remote_controller.py
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): """Save a replay, returning the data.""" res = self._client.send(save_replay=sc_pb.RequestSaveReplay()) return res.data
[ "Save", "a", "replay", "returning", "the", "data", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L278-L281
[ "def", "save_replay", "(", "self", ")", ":", "res", "=", "self", ".", "_client", ".", "send", "(", "save_replay", "=", "sc_pb", ".", "RequestSaveReplay", "(", ")", ")", "return", "res", ".", "data" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.debug
Run a debug command.
pysc2/lib/remote_controller.py
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): """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))
[ "Run", "a", "debug", "command", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L285-L289
[ "def", "debug", "(", "self", ",", "debug_commands", ")", ":", "if", "isinstance", "(", "debug_commands", ",", "sc_debug", ".", "DebugCommand", ")", ":", "debug_commands", "=", "[", "debug_commands", "]", "return", "self", ".", "_client", ".", "send", "(", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteController.quit
Shut down the SC2 process.
pysc2/lib/remote_controller.py
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): """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()
[ "Shut", "down", "the", "SC2", "process", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L293-L301
[ "def", "quit", "(", "self", ")", ":", "try", ":", "# Don't expect a response.", "self", ".", "_client", ".", "write", "(", "sc_pb", ".", "Request", "(", "quit", "=", "sc_pb", ".", "RequestQuit", "(", ")", ")", ")", "except", "protocol", ".", "ConnectionE...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
run_loop
A run loop to have agents and an environment interact.
pysc2/env/run_loop.py
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): """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...
[ "A", "run", "loop", "to", "have", "agents", "and", "an", "environment", "interact", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/run_loop.py#L23-L54
[ "def", "run_loop", "(", "agents", ",", "env", ",", "max_frames", "=", "0", ",", "max_episodes", "=", "0", ")", ":", "total_frames", "=", "0", "total_episodes", "=", "0", "start_time", "=", "time", ".", "time", "(", ")", "observation_spec", "=", "env", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RunConfig.map_data
Return the map data for a map by name or path.
pysc2/run_configs/lib.py
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): """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()
[ "Return", "the", "map", "data", "for", "a", "map", "by", "name", "or", "path", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L101-L104
[ "def", "map_data", "(", "self", ",", "map_name", ")", ":", "with", "gfile", ".", "Open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "data_dir", ",", "\"Maps\"", ",", "map_name", ")", ",", "\"rb\"", ")", "as", "f", ":", "return", "f", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RunConfig.replay_data
Return the replay data given a path to the replay.
pysc2/run_configs/lib.py
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): """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()
[ "Return", "the", "replay", "data", "given", "a", "path", "to", "the", "replay", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L110-L113
[ "def", "replay_data", "(", "self", ",", "replay_path", ")", ":", "with", "gfile", ".", "Open", "(", "self", ".", "abs_replay_path", "(", "replay_path", ")", ",", "\"rb\"", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RunConfig.replay_paths
A generator yielding the full path to the replays under `replay_dir`.
pysc2/run_configs/lib.py
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): """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(...
[ "A", "generator", "yielding", "the", "full", "path", "to", "the", "replays", "under", "replay_dir", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L115-L123
[ "def", "replay_paths", "(", "self", ",", "replay_dir", ")", ":", "replay_dir", "=", "self", ".", "abs_replay_path", "(", "replay_dir", ")", "if", "replay_dir", ".", "lower", "(", ")", ".", "endswith", "(", "\".sc2replay\"", ")", ":", "yield", "replay_dir", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RunConfig.save_replay
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...
pysc2/run_configs/lib.py
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): """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...
[ "Save", "a", "replay", "to", "a", "directory", "returning", "the", "path", "to", "the", "replay", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L125-L154
[ "def", "save_replay", "(", "self", ",", "replay_data", ",", "replay_dir", ",", "prefix", "=", "None", ")", ":", "if", "not", "prefix", ":", "replay_filename", "=", "\"\"", "elif", "os", ".", "path", ".", "sep", "in", "prefix", ":", "raise", "ValueError",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RunConfig.all_subclasses
An iterator over all subclasses of `cls`.
pysc2/run_configs/lib.py
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): """An iterator over all subclasses of `cls`.""" for s in cls.__subclasses__(): yield s for c in s.all_subclasses(): yield c
[ "An", "iterator", "over", "all", "subclasses", "of", "cls", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/lib.py#L161-L166
[ "def", "all_subclasses", "(", "cls", ")", ":", "for", "s", "in", "cls", ".", "__subclasses__", "(", ")", ":", "yield", "s", "for", "c", "in", "s", ".", "all_subclasses", "(", ")", ":", "yield", "c" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
NamedNumpyArray._indices
Turn all string indices into int indices, preserving ellipsis.
pysc2/lib/named_array.py
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): """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 ...
[ "Turn", "all", "string", "indices", "into", "int", "indices", "preserving", "ellipsis", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/named_array.py#L231-L245
[ "def", "_indices", "(", "self", ",", "indices", ")", ":", "if", "isinstance", "(", "indices", ",", "tuple", ")", ":", "out", "=", "[", "]", "dim", "=", "0", "for", "i", ",", "index", "in", "enumerate", "(", "indices", ")", ":", "if", "index", "is...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
NamedNumpyArray._get_index
Turn a string into a real index, otherwise return the index.
pysc2/lib/named_array.py
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): """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...
[ "Turn", "a", "string", "into", "a", "real", "index", "otherwise", "return", "the", "index", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/named_array.py#L247-L258
[ "def", "_get_index", "(", "self", ",", "dim", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "six", ".", "string_types", ")", ":", "try", ":", "return", "self", ".", "_index_names", "[", "dim", "]", "[", "index", "]", "except", "KeyEr...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.assign_to
Assign `x` and `y` to an object that has properties `x` and `y`.
pysc2/lib/point.py
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): """Assign `x` and `y` to an object that has properties `x` and `y`.""" obj.x = self.x obj.y = self.y
[ "Assign", "x", "and", "y", "to", "an", "object", "that", "has", "properties", "x", "and", "y", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L39-L42
[ "def", "assign_to", "(", "self", ",", "obj", ")", ":", "obj", ".", "x", "=", "self", ".", "x", "obj", ".", "y", "=", "self", ".", "y" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.dist
Distance to some other point.
pysc2/lib/point.py
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): """Distance to some other point.""" dx = self.x - other.x dy = self.y - other.y return math.sqrt(dx**2 + dy**2)
[ "Distance", "to", "some", "other", "point", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L44-L48
[ "def", "dist", "(", "self", ",", "other", ")", ":", "dx", "=", "self", ".", "x", "-", "other", ".", "x", "dy", "=", "self", ".", "y", "-", "other", ".", "y", "return", "math", ".", "sqrt", "(", "dx", "**", "2", "+", "dy", "**", "2", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.dist_sq
Distance squared to some other point.
pysc2/lib/point.py
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): """Distance squared to some other point.""" dx = self.x - other.x dy = self.y - other.y return dx**2 + dy**2
[ "Distance", "squared", "to", "some", "other", "point", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L50-L54
[ "def", "dist_sq", "(", "self", ",", "other", ")", ":", "dx", "=", "self", ".", "x", "-", "other", ".", "x", "dy", "=", "self", ".", "y", "-", "other", ".", "y", "return", "dx", "**", "2", "+", "dy", "**", "2" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.round
Round `x` and `y` to integers.
pysc2/lib/point.py
def round(self): """Round `x` and `y` to integers.""" return Point(int(round(self.x)), int(round(self.y)))
def round(self): """Round `x` and `y` to integers.""" return Point(int(round(self.x)), int(round(self.y)))
[ "Round", "x", "and", "y", "to", "integers", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L56-L58
[ "def", "round", "(", "self", ")", ":", "return", "Point", "(", "int", "(", "round", "(", "self", ".", "x", ")", ")", ",", "int", "(", "round", "(", "self", ".", "y", ")", ")", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.floor
Round `x` and `y` down to integers.
pysc2/lib/point.py
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): """Round `x` and `y` down to integers.""" return Point(int(math.floor(self.x)), int(math.floor(self.y)))
[ "Round", "x", "and", "y", "down", "to", "integers", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L60-L62
[ "def", "floor", "(", "self", ")", ":", "return", "Point", "(", "int", "(", "math", ".", "floor", "(", "self", ".", "x", ")", ")", ",", "int", "(", "math", ".", "floor", "(", "self", ".", "y", ")", ")", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.ceil
Round `x` and `y` up to integers.
pysc2/lib/point.py
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): """Round `x` and `y` up to integers.""" return Point(int(math.ceil(self.x)), int(math.ceil(self.y)))
[ "Round", "x", "and", "y", "up", "to", "integers", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L64-L66
[ "def", "ceil", "(", "self", ")", ":", "return", "Point", "(", "int", "(", "math", ".", "ceil", "(", "self", ".", "x", ")", ")", ",", "int", "(", "math", ".", "ceil", "(", "self", ".", "y", ")", ")", ")" ]
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Point.bound
Bound this point within the rect defined by (`p1`, `p2`).
pysc2/lib/point.py
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): """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))
[ "Bound", "this", "point", "within", "the", "rect", "defined", "by", "(", "p1", "p2", ")", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L112-L115
[ "def", "bound", "(", "self", ",", "p1", ",", "p2", "=", "None", ")", ":", "r", "=", "Rect", "(", "p1", ",", "p2", ")", "return", "Point", "(", "min", "(", "max", "(", "self", ".", "x", ",", "r", ".", "l", ")", ",", "r", ".", "r", ")", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Rect.contains_point
Is the point inside this rect?
pysc2/lib/point.py
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): """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)
[ "Is", "the", "point", "inside", "this", "rect?" ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L239-L242
[ "def", "contains_point", "(", "self", ",", "pt", ")", ":", "return", "(", "self", ".", "l", "<", "pt", ".", "x", "and", "self", ".", "r", ">", "pt", ".", "x", "and", "self", ".", "t", "<", "pt", ".", "y", "and", "self", ".", "b", ">", "pt",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Rect.contains_circle
Is the circle completely inside this rect?
pysc2/lib/point.py
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): """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)
[ "Is", "the", "circle", "completely", "inside", "this", "rect?" ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L244-L247
[ "def", "contains_circle", "(", "self", ",", "pt", ",", "radius", ")", ":", "return", "(", "self", ".", "l", "<", "pt", ".", "x", "-", "radius", "and", "self", ".", "r", ">", "pt", ".", "x", "+", "radius", "and", "self", ".", "t", "<", "pt", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
Rect.intersects_circle
Does the circle intersect with this rect?
pysc2/lib/point.py
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): """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...
[ "Does", "the", "circle", "intersect", "with", "this", "rect?" ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/point.py#L249-L266
[ "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", ".",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_read_execute_info
Read the ExecuteInfo.txt file and return the base directory.
pysc2/run_configs/platforms.py
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): """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()...
[ "Read", "the", "ExecuteInfo", ".", "txt", "file", "and", "return", "the", "base", "directory", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/platforms.py#L41-L52
[ "def", "_read_execute_info", "(", "path", ",", "parents", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "\"StarCraft II/ExecuteInfo.txt\"", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "with", "open", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
LocalBase.start
Launch the game.
pysc2/run_configs/platforms.py
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): """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...
[ "Launch", "the", "game", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/platforms.py#L66-L97
[ "def", "start", "(", "self", ",", "version", "=", "None", ",", "want_rgb", "=", "True", ",", "*", "*", "kwargs", ")", ":", "del", "want_rgb", "# Unused", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "data_dir", ")", ":", "raise",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
VsAgent.create_game
Create a game for the agents to join. Args: map_name: The map to use.
pysc2/env/host_remote_agent.py
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): """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...
[ "Create", "a", "game", "for", "the", "agents", "to", "join", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L71-L94
[ "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...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
VsAgent.close
Shutdown and free all resources.
pysc2/env/host_remote_agent.py
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): """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 = []
[ "Shutdown", "and", "free", "all", "resources", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L111-L122
[ "def", "close", "(", "self", ")", ":", "for", "controller", "in", "self", ".", "_controllers", ":", "controller", ".", "quit", "(", ")", "self", ".", "_controllers", "=", "[", "]", "for", "process", "in", "self", ".", "_processes", ":", "process", ".",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
VsBot.create_game
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).
pysc2/env/host_remote_agent.py
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): """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...
[ "Create", "a", "game", "one", "remote", "agent", "vs", "the", "specified", "bot", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L158-L196
[ "def", "create_game", "(", "self", ",", "map_name", ",", "bot_difficulty", "=", "sc_pb", ".", "VeryEasy", ",", "bot_race", "=", "sc_common", ".", "Random", ",", "bot_first", "=", "False", ")", ":", "self", ".", "_controller", ".", "ping", "(", ")", "# Fo...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
VsBot.close
Shutdown and free all resources.
pysc2/env/host_remote_agent.py
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): """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
[ "Shutdown", "and", "free", "all", "resources", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/host_remote_agent.py#L208-L215
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_controller", "is", "not", "None", ":", "self", ".", "_controller", ".", "quit", "(", ")", "self", ".", "_controller", "=", "None", "if", "self", ".", "_process", "is", "not", "None", ":", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
agent
Run the agent, connecting to a (remote) host started independently.
pysc2/bin/play_vs_agent.py
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(): """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...
[ "Run", "the", "agent", "connecting", "to", "a", "(", "remote", ")", "host", "started", "independently", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/play_vs_agent.py#L118-L143
[ "def", "agent", "(", ")", ":", "agent_module", ",", "agent_name", "=", "FLAGS", ".", "agent", ".", "rsplit", "(", "\".\"", ",", "1", ")", "agent_cls", "=", "getattr", "(", "importlib", ".", "import_module", "(", "agent_module", ")", ",", "agent_name", ")...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
human
Run a host which expects one player to connect remotely.
pysc2/bin/play_vs_agent.py
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 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....
[ "Run", "a", "host", "which", "expects", "one", "player", "to", "connect", "remotely", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/play_vs_agent.py#L146-L269
[ "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", ":",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
RemoteSC2Env._connect_remote
Make sure this stays synced with bin/agent_remote.py.
pysc2/env/remote_sc2_env.py
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): """Make sure this stays synced with bin/agent_remote.py.""" # Connect! logging.info("Connecting...") self._controllers = [remote_controller.RemoteController(host, host_port)] loggi...
[ "Make", "sure", "this", "stays", "synced", "with", "bin", "/", "agent_remote", ".", "py", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/remote_sc2_env.py#L189-L214
[ "def", "_connect_remote", "(", "self", ",", "host", ",", "host_port", ",", "lan_ports", ",", "race", ",", "name", ",", "map_inst", ",", "save_map", ",", "interface", ")", ":", "# Connect!", "logging", ".", "info", "(", "\"Connecting...\"", ")", "self", "."...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
get
Get the config chosen by the flags.
pysc2/run_configs/__init__.py
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(): """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...
[ "Get", "the", "config", "chosen", "by", "the", "flags", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/run_configs/__init__.py#L31-L47
[ "def", "get", "(", ")", ":", "configs", "=", "{", "c", ".", "name", "(", ")", ":", "c", "for", "c", "in", "lib", ".", "RunConfig", ".", "all_subclasses", "(", ")", "if", "c", ".", "priority", "(", ")", "}", "if", "not", "configs", ":", "raise",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
SC2Env.reset
Start a new episode.
pysc2/env/sc2_env.py
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): """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...
[ "Start", "a", "new", "episode", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/sc2_env.py#L454-L471
[ "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", "."...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
SC2Env.step
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.
pysc2/env/sc2_env.py
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): """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...
[ "Apply", "actions", "step", "the", "world", "forward", "and", "return", "observations", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/sc2_env.py#L474-L494
[ "def", "step", "(", "self", ",", "actions", ",", "step_mul", "=", "None", ")", ":", "if", "self", ".", "_state", "==", "environment", ".", "StepType", ".", "LAST", ":", "return", "self", ".", "reset", "(", ")", "skip", "=", "not", "self", ".", "_en...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
SC2Env.send_chat_messages
Useful for logging messages into the replay.
pysc2/env/sc2_env.py
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): """Useful for logging messages into the replay.""" self._parallel.run( (c.chat, message) for c, message in zip(self._controllers, messages))
[ "Useful", "for", "logging", "messages", "into", "the", "replay", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/sc2_env.py#L642-L645
[ "def", "send_chat_messages", "(", "self", ",", "messages", ")", ":", "self", ".", "_parallel", ".", "run", "(", "(", "c", ".", "chat", ",", "message", ")", "for", "c", ",", "message", "in", "zip", "(", "self", ".", "_controllers", ",", "messages", ")...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
valid_replay
Make sure the replay isn't corrupt, and is worth looking at.
pysc2/bin/replay_actions.py
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): """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...
[ "Make", "sure", "the", "replay", "isn", "t", "corrupt", "and", "is", "worth", "looking", "at", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L150-L163
[ "def", "valid_replay", "(", "info", ",", "ping", ")", ":", "if", "(", "info", ".", "HasField", "(", "\"error\"", ")", "or", "info", ".", "base_build", "!=", "ping", ".", "base_build", "or", "# different game version", "info", ".", "game_duration_loops", "<",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
stats_printer
A thread that consumes stats_queue and prints them every 10 seconds.
pysc2/bin/replay_actions.py
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): """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: ...
[ "A", "thread", "that", "consumes", "stats_queue", "and", "prints", "them", "every", "10", "seconds", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L295-L323
[ "def", "stats_printer", "(", "stats_queue", ")", ":", "proc_stats", "=", "[", "ProcessStats", "(", "i", ")", "for", "i", "in", "range", "(", "FLAGS", ".", "parallel", ")", "]", "print_time", "=", "start_time", "=", "time", ".", "time", "(", ")", "width...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
main
Dump stats about all the actions that are in use in a set of replays.
pysc2/bin/replay_actions.py
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): """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...
[ "Dump", "stats", "about", "all", "the", "actions", "that", "are", "in", "use", "in", "a", "set", "of", "replays", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L332-L368
[ "def", "main", "(", "unused_argv", ")", ":", "run_config", "=", "run_configs", ".", "get", "(", ")", "if", "not", "gfile", ".", "Exists", "(", "FLAGS", ".", "replays", ")", ":", "sys", ".", "exit", "(", "\"{} doesn't exist.\"", ".", "format", "(", "FLA...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
ReplayStats.merge
Merge another ReplayStats into this one.
pysc2/bin/replay_actions.py
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): """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...
[ "Merge", "another", "ReplayStats", "into", "this", "one", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L85-L105
[ "def", "merge", "(", "self", ",", "other", ")", ":", "def", "merge_dict", "(", "a", ",", "b", ")", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "b", ")", ":", "a", "[", "k", "]", "+=", "v", "self", ".", "replays", "+=", "o...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
ReplayProcessor.process_replay
Process a single replay, updating the stats.
pysc2/bin/replay_actions.py
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): """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...
[ "Process", "a", "single", "replay", "updating", "the", "stats", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_actions.py#L240-L292
[ "def", "process_replay", "(", "self", ",", "controller", ",", "replay_data", ",", "map_data", ",", "player_id", ")", ":", "self", ".", "_update_stage", "(", "\"start_replay\"", ")", "controller", ".", "start_replay", "(", "sc_pb", ".", "RequestStartReplay", "(",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
tcp_server
Start up the tcp server, send the settings.
pysc2/env/lan_sc2_env.py
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): """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...
[ "Start", "up", "the", "tcp", "server", "send", "the", "settings", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L65-L80
[ "def", "tcp_server", "(", "tcp_addr", ",", "settings", ")", ":", "family", "=", "socket", ".", "AF_INET6", "if", "\":\"", "in", "tcp_addr", ".", "ip", "else", "socket", ".", "AF_INET", "sock", "=", "socket", ".", "socket", "(", "family", ",", "socket", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
tcp_client
Connect to the tcp server, and return the settings.
pysc2/env/lan_sc2_env.py
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): """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:...
[ "Connect", "to", "the", "tcp", "server", "and", "return", "the", "settings", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L83-L106
[ "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"...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
read_tcp_size
Read `size` number of bytes from `conn`, retrying as needed.
pysc2/env/lan_sc2_env.py
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): """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) ...
[ "Read", "size", "number", "of", "bytes", "from", "conn", "retrying", "as", "needed", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L142-L154
[ "def", "read_tcp_size", "(", "conn", ",", "size", ")", ":", "chunks", "=", "[", "]", "bytes_read", "=", "0", "while", "bytes_read", "<", "size", ":", "chunk", "=", "conn", ".", "recv", "(", "size", "-", "bytes_read", ")", "if", "not", "chunk", ":", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
forward_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 remotely. remote_listen_ports: Which ports to listen on remotely to forward locally. Returns: The s...
pysc2/env/lan_sc2_env.py
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): """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...
[ "Forwards", "ports", "such", "that", "multiplayer", "works", "between", "machines", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L163-L196
[ "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]\"...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
LanSC2Env._launch_remote
Make sure this stays synced with bin/play_vs_agent.py.
pysc2/env/lan_sc2_env.py
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): """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...
[ "Make", "sure", "this", "stays", "synced", "with", "bin", "/", "play_vs_agent", ".", "py", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L305-L344
[ "def", "_launch_remote", "(", "self", ",", "host", ",", "config_port", ",", "race", ",", "name", ",", "interface", ")", ":", "self", ".", "_tcp_conn", ",", "settings", "=", "tcp_client", "(", "Addr", "(", "host", ",", "config_port", ")", ")", "self", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_replay_index
Output information for a directory of replays.
pysc2/bin/replay_info.py
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): """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...
[ "Output", "information", "for", "a", "directory", "of", "replays", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_info.py#L34-L91
[ "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...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_replay_info
Query a replay for information.
pysc2/bin/replay_info.py
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): """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...
[ "Query", "a", "replay", "for", "information", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_info.py#L94-L104
[ "def", "_replay_info", "(", "replay_path", ")", ":", "if", "not", "replay_path", ".", "lower", "(", ")", ".", "endswith", "(", "\"sc2replay\"", ")", ":", "print", "(", "\"Must be a replay.\"", ")", "return", "run_config", "=", "run_configs", ".", "get", "(",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
smooth_hue_palette
Takes an array of ints and returns a corresponding colored rgb array.
pysc2/lib/colors.py
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): """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...
[ "Takes", "an", "array", "of", "ints", "and", "returns", "a", "corresponding", "colored", "rgb", "array", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L78-L121
[ "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."...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
piece_wise_linear
Create a palette that is piece-wise linear given some colors at points.
pysc2/lib/colors.py
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): """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...
[ "Create", "a", "palette", "that", "is", "piece", "-", "wise", "linear", "given", "some", "colors", "at", "points", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L130-L149
[ "def", "piece_wise_linear", "(", "scale", ",", "points", ")", ":", "assert", "len", "(", "points", ")", ">=", "2", "assert", "points", "[", "0", "]", "[", "0", "]", "==", "0", "assert", "points", "[", "-", "1", "]", "[", "0", "]", "==", "1", "a...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
unit_type
Returns a palette that maps unit types to rgb colors.
pysc2/lib/colors.py
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): """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)...
[ "Returns", "a", "palette", "that", "maps", "unit", "types", "to", "rgb", "colors", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L205-L213
[ "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", "(", ...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
with_lock
Make sure the lock is held while in this function.
pysc2/lib/renderer_human.py
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): """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
[ "Make", "sure", "the", "lock", "is", "held", "while", "in", "this", "function", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L60-L68
[ "def", "with_lock", "(", "lock", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "_with_lock", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "lock", ":", "return", "func",...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_get_desktop_size
Get the desktop size.
pysc2/lib/renderer_human.py
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(): """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...
[ "Get", "the", "desktop", "size", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L216-L229
[ "def", "_get_desktop_size", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "\"Linux\"", ":", "try", ":", "xrandr_query", "=", "subprocess", ".", "check_output", "(", "[", "\"xrandr\"", ",", "\"--query\"", "]", ")", "sizes", "=", "re", "....
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_Surface.draw_arc
Draw an arc using world coordinates, radius, start and stop angles.
pysc2/lib/renderer_human.py
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): """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 = ...
[ "Draw", "an", "arc", "using", "world", "coordinates", "radius", "start", "and", "stop", "angles", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L141-L148
[ "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...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_Surface.draw_circle
Draw a circle using world coordinates and radius.
pysc2/lib/renderer_human.py
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): """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...
[ "Draw", "a", "circle", "using", "world", "coordinates", "and", "radius", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L150-L156
[ "def", "draw_circle", "(", "self", ",", "color", ",", "world_loc", ",", "world_radius", ",", "thickness", "=", "0", ")", ":", "if", "world_radius", ">", "0", ":", "center", "=", "self", ".", "world_to_surf", ".", "fwd_pt", "(", "world_loc", ")", ".", "...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897
train
_Surface.draw_rect
Draw a rectangle using world coordinates.
pysc2/lib/renderer_human.py
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): """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)
[ "Draw", "a", "rectangle", "using", "world", "coordinates", "." ]
deepmind/pysc2
python
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L158-L163
[ "def", "draw_rect", "(", "self", ",", "color", ",", "world_rect", ",", "thickness", "=", "0", ")", ":", "tl", "=", "self", ".", "world_to_surf", ".", "fwd_pt", "(", "world_rect", ".", "tl", ")", ".", "round", "(", ")", "br", "=", "self", ".", "worl...
df4cc4b00f07a2242be9ba153d4a7f4ad2017897