sc2ai 0.0.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/data/sc2ai/protocol/common.proto +1 -1
- data/data/sc2ai/protocol/data.proto +4 -1
- data/data/sc2ai/protocol/debug.proto +5 -1
- data/data/sc2ai/protocol/error.proto +2 -1
- data/data/sc2ai/protocol/query.proto +1 -1
- data/data/sc2ai/protocol/raw.proto +9 -7
- data/data/sc2ai/protocol/sc2api.proto +21 -7
- data/data/sc2ai/protocol/score.proto +2 -1
- data/data/sc2ai/protocol/spatial.proto +2 -1
- data/data/sc2ai/protocol/ui.proto +5 -2
- data/lib/docker_build/Dockerfile.ruby +5 -3
- data/lib/sc2ai/api/ability_id.rb +6 -1
- data/lib/sc2ai/api/data.rb +15 -0
- data/lib/sc2ai/api/tech_tree.rb +1 -1
- data/lib/sc2ai/api/tech_tree_data.rb +54 -3
- data/lib/sc2ai/cli/cli.rb +1 -1
- data/lib/sc2ai/connection.rb +1 -1
- data/lib/sc2ai/local_play/client_manager.rb +2 -0
- data/lib/sc2ai/local_play/match.rb +0 -11
- data/lib/sc2ai/overrides/async/process/child.rb +1 -1
- data/lib/sc2ai/paths.rb +1 -1
- data/lib/sc2ai/player/debug.rb +36 -2
- data/lib/sc2ai/player/{geometry.rb → geo.rb} +41 -5
- data/lib/sc2ai/player/units.rb +32 -2
- data/lib/sc2ai/player.rb +8 -48
- data/lib/sc2ai/ports.rb +0 -1
- data/lib/sc2ai/protocol/_meta_documentation.rb +249 -4
- data/lib/sc2ai/protocol/common_pb.rb +2 -23
- data/lib/sc2ai/protocol/data_pb.rb +2 -23
- data/lib/sc2ai/protocol/debug_pb.rb +2 -24
- data/lib/sc2ai/protocol/error_pb.rb +2 -23
- data/lib/sc2ai/protocol/extensions/color.rb +1 -1
- data/lib/sc2ai/protocol/extensions/point_2_d.rb +4 -0
- data/lib/sc2ai/protocol/extensions/position.rb +1 -1
- data/lib/sc2ai/protocol/extensions/unit.rb +45 -4
- data/lib/sc2ai/protocol/extensions/unit_type_data.rb +8 -0
- data/lib/sc2ai/protocol/query_pb.rb +2 -24
- data/lib/sc2ai/protocol/raw_pb.rb +2 -24
- data/lib/sc2ai/protocol/sc2api_pb.rb +2 -31
- data/lib/sc2ai/protocol/score_pb.rb +2 -23
- data/lib/sc2ai/protocol/spatial_pb.rb +2 -24
- data/lib/sc2ai/protocol/ui_pb.rb +2 -23
- data/lib/sc2ai/unit_group/action_ext.rb +2 -2
- data/lib/sc2ai/unit_group/filter_ext.rb +36 -1
- data/lib/sc2ai/version.rb +1 -1
- data/lib/sc2ai.rb +0 -7
- data/lib/templates/new/.ladderignore +15 -5
- data/lib/templates/new/api/raw.proto +1 -1
- data/lib/templates/new/api/ui.proto +1 -1
- data/lib/templates/new/my_bot.rb.tt +1 -1
- data/sig/minaswan.rbs +10323 -0
- data/sig/sc2ai.rbs +1170 -980
- metadata +52 -25
- data/lib/sc2ai/data.rb +0 -101
- data/lib/sc2ai/protocol/extensions/unit_type.rb +0 -9
@@ -7,32 +7,10 @@ require 'google/protobuf'
|
|
7
7
|
require 'sc2ai/protocol/common_pb'
|
8
8
|
|
9
9
|
|
10
|
-
descriptor_data = "\n\x1csc2ai/protocol/spatial.proto\x12\x03\x41pi\x1a\x1bsc2ai/protocol/common.proto\"
|
10
|
+
descriptor_data = "\n\x1csc2ai/protocol/spatial.proto\x12\x03\x41pi\x1a\x1bsc2ai/protocol/common.proto\"\x9c\x01\n\x17ObservationFeatureLayer\x12(\n\x07renders\x18\x01 \x01(\x0b\x32\x12.Api.FeatureLayersH\x00\x88\x01\x01\x12\x37\n\x0fminimap_renders\x18\x02 \x01(\x0b\x32\x19.Api.FeatureLayersMinimapH\x01\x88\x01\x01\x42\n\n\x08_rendersB\x12\n\x10_minimap_renders\"\xa7\x0c\n\rFeatureLayers\x12\'\n\nheight_map\x18\x01 \x01(\x0b\x32\x0e.Api.ImageDataH\x00\x88\x01\x01\x12+\n\x0evisibility_map\x18\x02 \x01(\x0b\x32\x0e.Api.ImageDataH\x01\x88\x01\x01\x12\"\n\x05\x63reep\x18\x03 \x01(\x0b\x32\x0e.Api.ImageDataH\x02\x88\x01\x01\x12\"\n\x05power\x18\x04 \x01(\x0b\x32\x0e.Api.ImageDataH\x03\x88\x01\x01\x12&\n\tplayer_id\x18\x05 \x01(\x0b\x32\x0e.Api.ImageDataH\x04\x88\x01\x01\x12&\n\tunit_type\x18\x06 \x01(\x0b\x32\x0e.Api.ImageDataH\x05\x88\x01\x01\x12%\n\x08selected\x18\x07 \x01(\x0b\x32\x0e.Api.ImageDataH\x06\x88\x01\x01\x12,\n\x0funit_hit_points\x18\x08 \x01(\x0b\x32\x0e.Api.ImageDataH\x07\x88\x01\x01\x12\x32\n\x15unit_hit_points_ratio\x18\x11 \x01(\x0b\x32\x0e.Api.ImageDataH\x08\x88\x01\x01\x12(\n\x0bunit_energy\x18\t \x01(\x0b\x32\x0e.Api.ImageDataH\t\x88\x01\x01\x12.\n\x11unit_energy_ratio\x18\x12 \x01(\x0b\x32\x0e.Api.ImageDataH\n\x88\x01\x01\x12)\n\x0cunit_shields\x18\n \x01(\x0b\x32\x0e.Api.ImageDataH\x0b\x88\x01\x01\x12/\n\x12unit_shields_ratio\x18\x13 \x01(\x0b\x32\x0e.Api.ImageDataH\x0c\x88\x01\x01\x12,\n\x0fplayer_relative\x18\x0b \x01(\x0b\x32\x0e.Api.ImageDataH\r\x88\x01\x01\x12,\n\x0funit_density_aa\x18\x0e \x01(\x0b\x32\x0e.Api.ImageDataH\x0e\x88\x01\x01\x12)\n\x0cunit_density\x18\x0f \x01(\x0b\x32\x0e.Api.ImageDataH\x0f\x88\x01\x01\x12$\n\x07\x65\x66\x66\x65\x63ts\x18\x14 \x01(\x0b\x32\x0e.Api.ImageDataH\x10\x88\x01\x01\x12+\n\x0ehallucinations\x18\x15 \x01(\x0b\x32\x0e.Api.ImageDataH\x11\x88\x01\x01\x12$\n\x07\x63loaked\x18\x16 \x01(\x0b\x32\x0e.Api.ImageDataH\x12\x88\x01\x01\x12!\n\x04\x62lip\x18\x17 \x01(\x0b\x32\x0e.Api.ImageDataH\x13\x88\x01\x01\x12\"\n\x05\x62uffs\x18\x18 \x01(\x0b\x32\x0e.Api.ImageDataH\x14\x88\x01\x01\x12*\n\rbuff_duration\x18\x1a \x01(\x0b\x32\x0e.Api.ImageDataH\x15\x88\x01\x01\x12#\n\x06\x61\x63tive\x18\x19 \x01(\x0b\x32\x0e.Api.ImageDataH\x16\x88\x01\x01\x12+\n\x0e\x62uild_progress\x18\x1b \x01(\x0b\x32\x0e.Api.ImageDataH\x17\x88\x01\x01\x12&\n\tbuildable\x18\x1c \x01(\x0b\x32\x0e.Api.ImageDataH\x18\x88\x01\x01\x12%\n\x08pathable\x18\x1d \x01(\x0b\x32\x0e.Api.ImageDataH\x19\x88\x01\x01\x12(\n\x0bplaceholder\x18\x1e \x01(\x0b\x32\x0e.Api.ImageDataH\x1a\x88\x01\x01\x42\r\n\x0b_height_mapB\x11\n\x0f_visibility_mapB\x08\n\x06_creepB\x08\n\x06_powerB\x0c\n\n_player_idB\x0c\n\n_unit_typeB\x0b\n\t_selectedB\x12\n\x10_unit_hit_pointsB\x18\n\x16_unit_hit_points_ratioB\x0e\n\x0c_unit_energyB\x14\n\x12_unit_energy_ratioB\x0f\n\r_unit_shieldsB\x15\n\x13_unit_shields_ratioB\x12\n\x10_player_relativeB\x12\n\x10_unit_density_aaB\x0f\n\r_unit_densityB\n\n\x08_effectsB\x11\n\x0f_hallucinationsB\n\n\x08_cloakedB\x07\n\x05_blipB\x08\n\x06_buffsB\x10\n\x0e_buff_durationB\t\n\x07_activeB\x11\n\x0f_build_progressB\x0c\n\n_buildableB\x0b\n\t_pathableB\x0e\n\x0c_placeholder\"\xe8\x04\n\x14\x46\x65\x61tureLayersMinimap\x12\'\n\nheight_map\x18\x01 \x01(\x0b\x32\x0e.Api.ImageDataH\x00\x88\x01\x01\x12+\n\x0evisibility_map\x18\x02 \x01(\x0b\x32\x0e.Api.ImageDataH\x01\x88\x01\x01\x12\"\n\x05\x63reep\x18\x03 \x01(\x0b\x32\x0e.Api.ImageDataH\x02\x88\x01\x01\x12#\n\x06\x63\x61mera\x18\x04 \x01(\x0b\x32\x0e.Api.ImageDataH\x03\x88\x01\x01\x12&\n\tplayer_id\x18\x05 \x01(\x0b\x32\x0e.Api.ImageDataH\x04\x88\x01\x01\x12,\n\x0fplayer_relative\x18\x06 \x01(\x0b\x32\x0e.Api.ImageDataH\x05\x88\x01\x01\x12%\n\x08selected\x18\x07 \x01(\x0b\x32\x0e.Api.ImageDataH\x06\x88\x01\x01\x12#\n\x06\x61lerts\x18\t \x01(\x0b\x32\x0e.Api.ImageDataH\x07\x88\x01\x01\x12&\n\tbuildable\x18\n \x01(\x0b\x32\x0e.Api.ImageDataH\x08\x88\x01\x01\x12%\n\x08pathable\x18\x0b \x01(\x0b\x32\x0e.Api.ImageDataH\t\x88\x01\x01\x12&\n\tunit_type\x18\x08 \x01(\x0b\x32\x0e.Api.ImageDataH\n\x88\x01\x01\x42\r\n\x0b_height_mapB\x11\n\x0f_visibility_mapB\x08\n\x06_creepB\t\n\x07_cameraB\x0c\n\n_player_idB\x12\n\x10_player_relativeB\x0b\n\t_selectedB\t\n\x07_alertsB\x0c\n\n_buildableB\x0b\n\t_pathableB\x0c\n\n_unit_type\"o\n\x11ObservationRender\x12 \n\x03map\x18\x01 \x01(\x0b\x32\x0e.Api.ImageDataH\x00\x88\x01\x01\x12$\n\x07minimap\x18\x02 \x01(\x0b\x32\x0e.Api.ImageDataH\x01\x88\x01\x01\x42\x06\n\x04_mapB\n\n\x08_minimap\"\x8f\x02\n\rActionSpatial\x12\x35\n\x0cunit_command\x18\x01 \x01(\x0b\x32\x1d.Api.ActionSpatialUnitCommandH\x00\x12\x33\n\x0b\x63\x61mera_move\x18\x02 \x01(\x0b\x32\x1c.Api.ActionSpatialCameraMoveH\x00\x12\x44\n\x14unit_selection_point\x18\x03 \x01(\x0b\x32$.Api.ActionSpatialUnitSelectionPointH\x00\x12\x42\n\x13unit_selection_rect\x18\x04 \x01(\x0b\x32#.Api.ActionSpatialUnitSelectionRectH\x00\x42\x08\n\x06\x61\x63tion\"\xd3\x01\n\x18\x41\x63tionSpatialUnitCommand\x12\x17\n\nability_id\x18\x01 \x01(\x05H\x01\x88\x01\x01\x12*\n\x13target_screen_coord\x18\x02 \x01(\x0b\x32\x0b.Api.PointIH\x00\x12+\n\x14target_minimap_coord\x18\x03 \x01(\x0b\x32\x0b.Api.PointIH\x00\x12\x1a\n\rqueue_command\x18\x04 \x01(\x08H\x02\x88\x01\x01\x42\x08\n\x06targetB\r\n\x0b_ability_idB\x10\n\x0e_queue_command\"V\n\x17\x41\x63tionSpatialCameraMove\x12(\n\x0e\x63\x65nter_minimap\x18\x01 \x01(\x0b\x32\x0b.Api.PointIH\x00\x88\x01\x01\x42\x11\n\x0f_center_minimap\"\xa4\x02\n\x1f\x41\x63tionSpatialUnitSelectionPoint\x12\x30\n\x16selection_screen_coord\x18\x01 \x01(\x0b\x32\x0b.Api.PointIH\x00\x88\x01\x01\x12<\n\x04type\x18\x02 \x01(\x0e\x32).Api.ActionSpatialUnitSelectionPoint.TypeH\x01\x88\x01\x01\"m\n\x04Type\x12\x30\n,EnumActionSpatialUnitSelectionPointTypeUnset\x10\x00\x12\n\n\x06Select\x10\x01\x12\n\n\x06Toggle\x10\x02\x12\x0b\n\x07\x41llType\x10\x03\x12\x0e\n\nAddAllType\x10\x04\x42\x19\n\x17_selection_screen_coordB\x07\n\x05_type\"\x7f\n\x1e\x41\x63tionSpatialUnitSelectionRect\x12/\n\x16selection_screen_coord\x18\x01 \x03(\x0b\x32\x0f.Api.RectangleI\x12\x1a\n\rselection_add\x18\x02 \x01(\x08H\x00\x88\x01\x01\x42\x10\n\x0e_selection_addb\x06proto3"
|
11
11
|
|
12
12
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
|
-
|
14
|
-
begin
|
15
|
-
pool.add_serialized_file(descriptor_data)
|
16
|
-
rescue TypeError
|
17
|
-
# Compatibility code: will be removed in the next major version.
|
18
|
-
require 'google/protobuf/descriptor_pb'
|
19
|
-
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
20
|
-
parsed.clear_dependency
|
21
|
-
serialized = parsed.class.encode(parsed)
|
22
|
-
file = pool.add_serialized_file(serialized)
|
23
|
-
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
24
|
-
imports = [
|
25
|
-
["Api.ImageData", "sc2ai/protocol/common.proto"],
|
26
|
-
]
|
27
|
-
imports.each do |type_name, expected_filename|
|
28
|
-
import_file = pool.lookup(type_name).file_descriptor
|
29
|
-
if import_file.name != expected_filename
|
30
|
-
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
warn "Each proto file must use a consistent fully-qualified name."
|
34
|
-
warn "This will become an error in the next major version."
|
35
|
-
end
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
36
14
|
|
37
15
|
module Api
|
38
16
|
ObservationFeatureLayer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Api.ObservationFeatureLayer").msgclass
|
data/lib/sc2ai/protocol/ui_pb.rb
CHANGED
@@ -5,31 +5,10 @@
|
|
5
5
|
require 'google/protobuf'
|
6
6
|
|
7
7
|
|
8
|
-
descriptor_data = "\n\x17sc2ai/protocol/ui.proto\x12\x03\x41pi\"\xcf\x01\n\rObservationUI\x12!\n\x06groups\x18\x01 \x03(\x0b\x32\x11.Api.ControlGroup\x12\"\n\x06single\x18\x02 \x01(\x0b\x32\x10.Api.SinglePanelH\x00\x12 \n\x05multi\x18\x03 \x01(\x0b\x32\x0f.Api.MultiPanelH\x00\x12 \n\x05\x63\x61rgo\x18\x04 \x01(\x0b\x32\x0f.Api.CargoPanelH\x00\x12*\n\nproduction\x18\x05 \x01(\x0b\x32\x14.Api.ProductionPanelH\x00\x42\x07\n\x05panel\"
|
8
|
+
descriptor_data = "\n\x17sc2ai/protocol/ui.proto\x12\x03\x41pi\"\xcf\x01\n\rObservationUI\x12!\n\x06groups\x18\x01 \x03(\x0b\x32\x11.Api.ControlGroup\x12\"\n\x06single\x18\x02 \x01(\x0b\x32\x10.Api.SinglePanelH\x00\x12 \n\x05multi\x18\x03 \x01(\x0b\x32\x0f.Api.MultiPanelH\x00\x12 \n\x05\x63\x61rgo\x18\x04 \x01(\x0b\x32\x0f.Api.CargoPanelH\x00\x12*\n\nproduction\x18\x05 \x01(\x0b\x32\x14.Api.ProductionPanelH\x00\x42\x07\n\x05panel\"\x9a\x01\n\x0c\x43ontrolGroup\x12 \n\x13\x63ontrol_group_index\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x1d\n\x10leader_unit_type\x18\x02 \x01(\rH\x01\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x03 \x01(\rH\x02\x88\x01\x01\x42\x16\n\x14_control_group_indexB\x13\n\x11_leader_unit_typeB\x08\n\x06_count\"\xdb\x03\n\x08UnitInfo\x12\x16\n\tunit_type\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x1c\n\x0fplayer_relative\x18\x02 \x01(\rH\x01\x88\x01\x01\x12\x13\n\x06health\x18\x03 \x01(\x05H\x02\x88\x01\x01\x12\x14\n\x07shields\x18\x04 \x01(\x05H\x03\x88\x01\x01\x12\x13\n\x06\x65nergy\x18\x05 \x01(\x05H\x04\x88\x01\x01\x12\"\n\x15transport_slots_taken\x18\x06 \x01(\x05H\x05\x88\x01\x01\x12\x1b\n\x0e\x62uild_progress\x18\x07 \x01(\x02H\x06\x88\x01\x01\x12\"\n\x06\x61\x64\x64_on\x18\x08 \x01(\x0b\x32\r.Api.UnitInfoH\x07\x88\x01\x01\x12\x17\n\nmax_health\x18\t \x01(\x05H\x08\x88\x01\x01\x12\x18\n\x0bmax_shields\x18\n \x01(\x05H\t\x88\x01\x01\x12\x17\n\nmax_energy\x18\x0b \x01(\x05H\n\x88\x01\x01\x42\x0c\n\n_unit_typeB\x12\n\x10_player_relativeB\t\n\x07_healthB\n\n\x08_shieldsB\t\n\x07_energyB\x18\n\x16_transport_slots_takenB\x11\n\x0f_build_progressB\t\n\x07_add_onB\r\n\x0b_max_healthB\x0e\n\x0c_max_shieldsB\r\n\x0b_max_energy\"\xf9\x01\n\x0bSinglePanel\x12 \n\x04unit\x18\x01 \x01(\x0b\x32\r.Api.UnitInfoH\x00\x88\x01\x01\x12!\n\x14\x61ttack_upgrade_level\x18\x02 \x01(\x05H\x01\x88\x01\x01\x12 \n\x13\x61rmor_upgrade_level\x18\x03 \x01(\x05H\x02\x88\x01\x01\x12!\n\x14shield_upgrade_level\x18\x04 \x01(\x05H\x03\x88\x01\x01\x12\r\n\x05\x62uffs\x18\x05 \x03(\x05\x42\x07\n\x05_unitB\x17\n\x15_attack_upgrade_levelB\x16\n\x14_armor_upgrade_levelB\x17\n\x15_shield_upgrade_level\"*\n\nMultiPanel\x12\x1c\n\x05units\x18\x01 \x03(\x0b\x32\r.Api.UnitInfo\"\x8c\x01\n\nCargoPanel\x12 \n\x04unit\x18\x01 \x01(\x0b\x32\r.Api.UnitInfoH\x00\x88\x01\x01\x12!\n\npassengers\x18\x02 \x03(\x0b\x32\r.Api.UnitInfo\x12\x1c\n\x0fslots_available\x18\x03 \x01(\x05H\x01\x88\x01\x01\x42\x07\n\x05_unitB\x12\n\x10_slots_available\"c\n\tBuildItem\x12\x17\n\nability_id\x18\x01 \x01(\rH\x00\x88\x01\x01\x12\x1b\n\x0e\x62uild_progress\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\r\n\x0b_ability_idB\x11\n\x0f_build_progress\"\x8a\x01\n\x0fProductionPanel\x12 \n\x04unit\x18\x01 \x01(\x0b\x32\r.Api.UnitInfoH\x00\x88\x01\x01\x12\"\n\x0b\x62uild_queue\x18\x02 \x03(\x0b\x32\r.Api.UnitInfo\x12(\n\x10production_queue\x18\x03 \x03(\x0b\x32\x0e.Api.BuildItemB\x07\n\x05_unit\"\xf7\x03\n\x08\x41\x63tionUI\x12\x30\n\rcontrol_group\x18\x01 \x01(\x0b\x32\x17.Api.ActionControlGroupH\x00\x12,\n\x0bselect_army\x18\x02 \x01(\x0b\x32\x15.Api.ActionSelectArmyH\x00\x12\x37\n\x11select_warp_gates\x18\x03 \x01(\x0b\x32\x1a.Api.ActionSelectWarpGatesH\x00\x12.\n\x0cselect_larva\x18\x04 \x01(\x0b\x32\x16.Api.ActionSelectLarvaH\x00\x12\x39\n\x12select_idle_worker\x18\x05 \x01(\x0b\x32\x1b.Api.ActionSelectIdleWorkerH\x00\x12,\n\x0bmulti_panel\x18\x06 \x01(\x0b\x32\x15.Api.ActionMultiPanelH\x00\x12\x32\n\x0b\x63\x61rgo_panel\x18\x07 \x01(\x0b\x32\x1b.Api.ActionCargoPanelUnloadH\x00\x12\x45\n\x10production_panel\x18\x08 \x01(\x0b\x32).Api.ActionProductionPanelRemoveFromQueueH\x00\x12\x34\n\x0ftoggle_autocast\x18\t \x01(\x0b\x32\x19.Api.ActionToggleAutocastH\x00\x42\x08\n\x06\x61\x63tion\"\x97\x02\n\x12\x41\x63tionControlGroup\x12?\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32*.Api.ActionControlGroup.ControlGroupActionH\x00\x88\x01\x01\x12 \n\x13\x63ontrol_group_index\x18\x02 \x01(\rH\x01\x88\x01\x01\"{\n\x12\x43ontrolGroupAction\x12\x1f\n\x1b\x45numControlGroupActionUnset\x10\x00\x12\n\n\x06Recall\x10\x01\x12\x07\n\x03Set\x10\x02\x12\n\n\x06\x41ppend\x10\x03\x12\x0f\n\x0bSetAndSteal\x10\x04\x12\x12\n\x0e\x41ppendAndSteal\x10\x05\x42\t\n\x07_actionB\x16\n\x14_control_group_index\"@\n\x10\x41\x63tionSelectArmy\x12\x1a\n\rselection_add\x18\x01 \x01(\x08H\x00\x88\x01\x01\x42\x10\n\x0e_selection_add\"E\n\x15\x41\x63tionSelectWarpGates\x12\x1a\n\rselection_add\x18\x01 \x01(\x08H\x00\x88\x01\x01\x42\x10\n\x0e_selection_add\"\x13\n\x11\x41\x63tionSelectLarva\"\xae\x01\n\x16\x41\x63tionSelectIdleWorker\x12\x33\n\x04type\x18\x01 \x01(\x0e\x32 .Api.ActionSelectIdleWorker.TypeH\x00\x88\x01\x01\"V\n\x04Type\x12\'\n#EnumActionSelectIdleWorkerTypeUnset\x10\x00\x12\x07\n\x03Set\x10\x01\x12\x07\n\x03\x41\x64\x64\x10\x02\x12\x07\n\x03\x41ll\x10\x03\x12\n\n\x06\x41\x64\x64\x41ll\x10\x04\x42\x07\n\x05_type\"\xed\x01\n\x10\x41\x63tionMultiPanel\x12-\n\x04type\x18\x01 \x01(\x0e\x32\x1a.Api.ActionMultiPanel.TypeH\x00\x88\x01\x01\x12\x17\n\nunit_index\x18\x02 \x01(\x05H\x01\x88\x01\x01\"y\n\x04Type\x12!\n\x1d\x45numActionMultiPanelTypeUnset\x10\x00\x12\x10\n\x0cSingleSelect\x10\x01\x12\x10\n\x0c\x44\x65selectUnit\x10\x02\x12\x13\n\x0fSelectAllOfType\x10\x03\x12\x15\n\x11\x44\x65selectAllOfType\x10\x04\x42\x07\n\x05_typeB\r\n\x0b_unit_index\"@\n\x16\x41\x63tionCargoPanelUnload\x12\x17\n\nunit_index\x18\x01 \x01(\x05H\x00\x88\x01\x01\x42\r\n\x0b_unit_index\"N\n$ActionProductionPanelRemoveFromQueue\x12\x17\n\nunit_index\x18\x01 \x01(\x05H\x00\x88\x01\x01\x42\r\n\x0b_unit_index\">\n\x14\x41\x63tionToggleAutocast\x12\x17\n\nability_id\x18\x01 \x01(\x05H\x00\x88\x01\x01\x42\r\n\x0b_ability_idb\x06proto3"
|
9
9
|
|
10
10
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
11
|
-
|
12
|
-
begin
|
13
|
-
pool.add_serialized_file(descriptor_data)
|
14
|
-
rescue TypeError
|
15
|
-
# Compatibility code: will be removed in the next major version.
|
16
|
-
require 'google/protobuf/descriptor_pb'
|
17
|
-
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
18
|
-
parsed.clear_dependency
|
19
|
-
serialized = parsed.class.encode(parsed)
|
20
|
-
file = pool.add_serialized_file(serialized)
|
21
|
-
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
22
|
-
imports = [
|
23
|
-
]
|
24
|
-
imports.each do |type_name, expected_filename|
|
25
|
-
import_file = pool.lookup(type_name).file_descriptor
|
26
|
-
if import_file.name != expected_filename
|
27
|
-
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
warn "Each proto file must use a consistent fully-qualified name."
|
31
|
-
warn "This will become an error in the next major version."
|
32
|
-
end
|
11
|
+
pool.add_serialized_file(descriptor_data)
|
33
12
|
|
34
13
|
module Api
|
35
14
|
ObservationUI = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Api.ObservationUI").msgclass
|
@@ -6,7 +6,7 @@ module Sc2
|
|
6
6
|
# A set of action related tasks for unit groups
|
7
7
|
class UnitGroup
|
8
8
|
# Our first unit's bot object.
|
9
|
-
# Returns nil if units are empty, so use
|
9
|
+
# Returns nil if units are empty, so use safety operator bot&.method(...)
|
10
10
|
# @return [Sc2::Player, nil] player with active connection
|
11
11
|
def bot
|
12
12
|
first&.bot
|
@@ -27,7 +27,7 @@ module Sc2
|
|
27
27
|
|
28
28
|
# Builds target unit type, i.e. issuing a build command to worker.build(...Api::UnitTypeId::BARRACKS)
|
29
29
|
# @param unit_type_id [Integer] Api::UnitTypeId the unit type you wish to build
|
30
|
-
# @param target [Api::Point2D, Integer, nil] is a unit tag or a Api::Point2D. Nil for addons/orbital
|
30
|
+
# @param target [Api::Point2D, Api::Unit, Integer, nil] is a unit tag or a Api::Point2D. Nil for addons/orbital
|
31
31
|
# @param queue_command [Boolean] shift+command
|
32
32
|
def build(unit_type_id:, target: nil, queue_command: false)
|
33
33
|
return if size.zero?
|
@@ -6,7 +6,11 @@ require "kdtree"
|
|
6
6
|
module Sc2
|
7
7
|
# Manage virtual control groups of units, similar to Hash or Array.
|
8
8
|
class UnitGroup
|
9
|
+
# An array of all worker unit type ids
|
10
|
+
# @return [Array<Integer>]
|
9
11
|
TYPE_WORKER = [Api::UnitTypeId::SCV, Api::UnitTypeId::MULE, Api::UnitTypeId::DRONE, Api::UnitTypeId::DRONEBURROWED, Api::UnitTypeId::PROBE].freeze
|
12
|
+
# An array of all gas structure unit type ids
|
13
|
+
# @return [Array<Integer>]
|
10
14
|
TYPE_GAS_STRUCTURE = [
|
11
15
|
Api::UnitTypeId::REFINERY,
|
12
16
|
Api::UnitTypeId::REFINERYRICH,
|
@@ -15,6 +19,8 @@ module Sc2
|
|
15
19
|
Api::UnitTypeId::EXTRACTOR,
|
16
20
|
Api::UnitTypeId::EXTRACTORRICH
|
17
21
|
].freeze
|
22
|
+
# An array of all mineral unit type ids
|
23
|
+
# @return [Array<Integer>]
|
18
24
|
TYPE_MINERAL = [
|
19
25
|
Api::UnitTypeId::MINERALCRYSTAL,
|
20
26
|
Api::UnitTypeId::RICHMINERALFIELD,
|
@@ -33,6 +39,8 @@ module Sc2
|
|
33
39
|
Api::UnitTypeId::MINERALFIELDOPAQUE,
|
34
40
|
Api::UnitTypeId::MINERALFIELDOPAQUE900
|
35
41
|
].freeze
|
42
|
+
# An array of all open geyser unit type ids
|
43
|
+
# @return [Array<Integer>]
|
36
44
|
TYPE_GEYSER = [
|
37
45
|
Api::UnitTypeId::VESPENEGEYSER,
|
38
46
|
Api::UnitTypeId::SPACEPLATFORMGEYSER,
|
@@ -41,6 +49,8 @@ module Sc2
|
|
41
49
|
Api::UnitTypeId::PURIFIERVESPENEGEYSER,
|
42
50
|
Api::UnitTypeId::SHAKURASVESPENEGEYSER
|
43
51
|
].freeze
|
52
|
+
# An array of all debris unit type ids
|
53
|
+
# @return [Array<Integer>]
|
44
54
|
TYPE_REJECT_DEBRIS = ((TYPE_MINERAL + TYPE_GEYSER) << Api::UnitTypeId::XELNAGATOWER).freeze
|
45
55
|
TYPE_TECHLAB = [
|
46
56
|
Api::UnitTypeId::TECHLAB,
|
@@ -48,12 +58,16 @@ module Sc2
|
|
48
58
|
Api::UnitTypeId::FACTORYTECHLAB,
|
49
59
|
Api::UnitTypeId::STARPORTTECHLAB
|
50
60
|
].freeze
|
61
|
+
# An array of all reactor structure unit type ids
|
62
|
+
# @return [Array<Integer>]
|
51
63
|
TYPE_REACTOR = [
|
52
64
|
Api::UnitTypeId::REACTOR,
|
53
65
|
Api::UnitTypeId::BARRACKSREACTOR,
|
54
66
|
Api::UnitTypeId::FACTORYREACTOR,
|
55
67
|
Api::UnitTypeId::STARPORTREACTOR
|
56
68
|
].freeze
|
69
|
+
# An array of all base structures unit type ids
|
70
|
+
# @return [Array<Integer>]
|
57
71
|
TYPE_BASES = [
|
58
72
|
Api::UnitTypeId::COMMANDCENTER, Api::UnitTypeId::COMMANDCENTERFLYING,
|
59
73
|
Api::UnitTypeId::ORBITALCOMMAND, Api::UnitTypeId::ORBITALCOMMANDFLYING,
|
@@ -174,6 +188,15 @@ module Sc2
|
|
174
188
|
|
175
189
|
# GENERICS ---
|
176
190
|
|
191
|
+
# Selects units you own
|
192
|
+
# i.e. @bot.all_units.owned # => Units you own
|
193
|
+
# @return [Sc2::UnitGroup] workers
|
194
|
+
def owned
|
195
|
+
cached("#{__method__}:Self") do
|
196
|
+
select { |unit| unit.alliance == :Self }
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
177
200
|
# Selects worker units
|
178
201
|
# @return [Sc2::UnitGroup] workers
|
179
202
|
def workers
|
@@ -247,7 +270,7 @@ module Sc2
|
|
247
270
|
select(&:is_idle?)
|
248
271
|
end
|
249
272
|
|
250
|
-
# Selects units which have this ability available
|
273
|
+
# Selects units which have this ability available
|
251
274
|
# Queries API if necessary
|
252
275
|
# @param [Integer] ability_id
|
253
276
|
# @return [UnitGroup] units which have the ability available
|
@@ -255,6 +278,12 @@ module Sc2
|
|
255
278
|
select { |unit| unit.ability_available?(ability_id) }
|
256
279
|
end
|
257
280
|
|
281
|
+
# Checks whether any unit's first order matches these abilities
|
282
|
+
# @param ability_ids [Integer, Array<Integer>] accepts one or an array of Api::AbilityId
|
283
|
+
def is_performing_ability?(ability_ids)
|
284
|
+
any? { |unit| unit.is_performing_ability?(ability_ids) }
|
285
|
+
end
|
286
|
+
|
258
287
|
# NEUTRAL ------------------------------------------
|
259
288
|
|
260
289
|
# Selects mineral fields
|
@@ -301,6 +330,12 @@ module Sc2
|
|
301
330
|
end
|
302
331
|
alias_method :larvae, :larva
|
303
332
|
|
333
|
+
# Selects eggs. Eggs come from Larva and turn into Units.
|
334
|
+
# @return [Sc2::UnitGroup] eggs
|
335
|
+
def eggs
|
336
|
+
select_type(Api::UnitTypeId::EGG)
|
337
|
+
end
|
338
|
+
|
304
339
|
# Selects queens
|
305
340
|
# @return [Sc2::UnitGroup] queens
|
306
341
|
def queens
|
data/lib/sc2ai/version.rb
CHANGED
data/lib/sc2ai.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# TODO: MOVE RUBY_GC_* to load into shell ENV, because they apparently can't be set at runtime.
|
4
|
-
# Arbitrary very large numbers which should not be reached
|
5
|
-
# RUBY_GC_MALLOC_LIMIT=128000000000;
|
6
|
-
# RUBY_GC_OLDMALLOC_LIMIT=128000000000;
|
7
|
-
# RUBY_GC_OLDMALLOC_LIMIT_MAX=128000000000;
|
8
|
-
# RUBY_GC_HEAP_INIT_SLOTS=329375
|
9
|
-
|
10
3
|
# In the event major runs, let it compact
|
11
4
|
GC.auto_compact = true
|
12
5
|
|
@@ -5,16 +5,26 @@
|
|
5
5
|
*.proto
|
6
6
|
*.zip
|
7
7
|
|
8
|
-
|
9
8
|
# Gem-specific ignores
|
10
9
|
.build/
|
11
10
|
data/debug_observation.json
|
11
|
+
run_example_match.rb
|
12
12
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
13
|
+
# Generic ruby gitignores
|
14
|
+
*.gem
|
15
|
+
*.rbc
|
16
|
+
.config
|
17
|
+
coverage/
|
18
|
+
pkg/
|
16
19
|
spec/
|
17
20
|
test/
|
21
|
+
tmp/
|
22
|
+
.byebug_history
|
23
|
+
.bundle/
|
24
|
+
vendor/bundle
|
25
|
+
lib/bundler/man/
|
18
26
|
|
19
|
-
#
|
27
|
+
# Other
|
28
|
+
.idea/
|
29
|
+
.vscode/
|
20
30
|
|
@@ -5,7 +5,7 @@ class <%= @classname %> < Sc2::Player::Bot
|
|
5
5
|
def configure
|
6
6
|
@realtime = false # Step-mode vs Bot, Realtime vs Humans
|
7
7
|
@step_count = 2 # 2s/22.4 = ~89.29ms step cycle time allowance
|
8
|
-
@enable_feature_layer = false
|
8
|
+
@enable_feature_layer = false # Enables ui_ and spatial_ actions. Advanced, and has performance cost.
|
9
9
|
end
|
10
10
|
|
11
11
|
def on_step
|