sc2ai 0.0.0.pre → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/data/data.json +1 -0
  3. data/data/data_readable.json +22946 -0
  4. data/data/sc2ai/protocol/common.proto +59 -0
  5. data/data/sc2ai/protocol/data.proto +120 -0
  6. data/data/sc2ai/protocol/debug.proto +127 -0
  7. data/data/sc2ai/protocol/error.proto +221 -0
  8. data/data/sc2ai/protocol/query.proto +55 -0
  9. data/data/sc2ai/protocol/raw.proto +202 -0
  10. data/data/sc2ai/protocol/sc2api.proto +718 -0
  11. data/data/sc2ai/protocol/score.proto +108 -0
  12. data/data/sc2ai/protocol/spatial.proto +115 -0
  13. data/data/sc2ai/protocol/ui.proto +145 -0
  14. data/data/setup/setup.SC2Map +0 -0
  15. data/data/setup/setup.SC2Replay +0 -0
  16. data/data/stableid.json +37900 -0
  17. data/data/versions.json +554 -0
  18. data/exe/sc2ai +35 -0
  19. data/lib/docker_build/Dockerfile.ruby +74 -0
  20. data/lib/docker_build/docker-compose-base-image.yml +10 -0
  21. data/lib/docker_build/docker-compose-ladderzip.yml +9 -0
  22. data/lib/sc2ai/api/ability_id.rb +1951 -0
  23. data/lib/sc2ai/api/buff_id.rb +316 -0
  24. data/lib/sc2ai/api/data.rb +101 -0
  25. data/lib/sc2ai/api/effect_id.rb +20 -0
  26. data/lib/sc2ai/api/tech_tree.rb +82 -0
  27. data/lib/sc2ai/api/tech_tree_data.rb +2342 -0
  28. data/lib/sc2ai/api/unit_type_id.rb +2074 -0
  29. data/lib/sc2ai/api/upgrade_id.rb +312 -0
  30. data/lib/sc2ai/cli/cli.rb +177 -0
  31. data/lib/sc2ai/cli/ladderzip.rb +173 -0
  32. data/lib/sc2ai/cli/new.rb +88 -0
  33. data/lib/sc2ai/configuration.rb +145 -0
  34. data/lib/sc2ai/connection/connection_listener.rb +30 -0
  35. data/lib/sc2ai/connection/requests.rb +417 -0
  36. data/lib/sc2ai/connection/status_listener.rb +15 -0
  37. data/lib/sc2ai/connection.rb +146 -0
  38. data/lib/sc2ai/local_play/client/configurable_options.rb +115 -0
  39. data/lib/sc2ai/local_play/client.rb +159 -0
  40. data/lib/sc2ai/local_play/client_manager.rb +70 -0
  41. data/lib/sc2ai/local_play/map_file.rb +48 -0
  42. data/lib/sc2ai/local_play/match.rb +184 -0
  43. data/lib/sc2ai/overrides/array.rb +14 -0
  44. data/lib/sc2ai/overrides/async/process/child.rb +31 -0
  45. data/lib/sc2ai/overrides/kernel.rb +33 -0
  46. data/lib/sc2ai/paths.rb +294 -0
  47. data/lib/sc2ai/player/actions.rb +386 -0
  48. data/lib/sc2ai/player/debug.rb +224 -0
  49. data/lib/sc2ai/player/game_state.rb +131 -0
  50. data/lib/sc2ai/player/geometry.rb +766 -0
  51. data/lib/sc2ai/player/previous_state.rb +49 -0
  52. data/lib/sc2ai/player/units.rb +337 -0
  53. data/lib/sc2ai/player.rb +661 -0
  54. data/lib/sc2ai/ports.rb +152 -0
  55. data/lib/sc2ai/protocol/_meta_documentation.rb +39 -0
  56. data/lib/sc2ai/protocol/common_pb.rb +43 -0
  57. data/lib/sc2ai/protocol/data_pb.rb +47 -0
  58. data/lib/sc2ai/protocol/debug_pb.rb +56 -0
  59. data/lib/sc2ai/protocol/error_pb.rb +36 -0
  60. data/lib/sc2ai/protocol/extensions/color.rb +20 -0
  61. data/lib/sc2ai/protocol/extensions/point.rb +23 -0
  62. data/lib/sc2ai/protocol/extensions/point_2_d.rb +26 -0
  63. data/lib/sc2ai/protocol/extensions/position.rb +202 -0
  64. data/lib/sc2ai/protocol/extensions/power_source.rb +19 -0
  65. data/lib/sc2ai/protocol/extensions/unit.rb +489 -0
  66. data/lib/sc2ai/protocol/query_pb.rb +47 -0
  67. data/lib/sc2ai/protocol/raw_pb.rb +57 -0
  68. data/lib/sc2ai/protocol/sc2api_pb.rb +130 -0
  69. data/lib/sc2ai/protocol/score_pb.rb +40 -0
  70. data/lib/sc2ai/protocol/spatial_pb.rb +48 -0
  71. data/lib/sc2ai/protocol/ui_pb.rb +56 -0
  72. data/lib/sc2ai/unit_group/action_ext.rb +74 -0
  73. data/lib/sc2ai/unit_group/filter_ext.rb +379 -0
  74. data/lib/sc2ai/unit_group.rb +277 -0
  75. data/lib/sc2ai/version.rb +2 -1
  76. data/lib/sc2ai.rb +93 -2
  77. data/lib/templates/ladderzip/bin/ladder.tt +23 -0
  78. data/lib/templates/new/.ladderignore +20 -0
  79. data/lib/templates/new/Gemfile.tt +7 -0
  80. data/lib/templates/new/api/common.proto +59 -0
  81. data/lib/templates/new/api/data.proto +120 -0
  82. data/lib/templates/new/api/debug.proto +127 -0
  83. data/lib/templates/new/api/error.proto +221 -0
  84. data/lib/templates/new/api/query.proto +55 -0
  85. data/lib/templates/new/api/raw.proto +202 -0
  86. data/lib/templates/new/api/sc2api.proto +718 -0
  87. data/lib/templates/new/api/score.proto +108 -0
  88. data/lib/templates/new/api/spatial.proto +115 -0
  89. data/lib/templates/new/api/ui.proto +145 -0
  90. data/lib/templates/new/boot.rb.tt +6 -0
  91. data/lib/templates/new/my_bot.rb.tt +23 -0
  92. data/lib/templates/new/run_example_match.rb.tt +14 -0
  93. metadata +353 -9
@@ -0,0 +1,312 @@
1
+ # Generated from stableid.json, do not edit.
2
+
3
+ module Api
4
+ # Constant reference of Upgrade ids
5
+ module UpgradeId
6
+ NULL = 0
7
+ CARRIERLAUNCHSPEEDUPGRADE = 1
8
+ GLIALRECONSTITUTION = 2
9
+ TUNNELINGCLAWS = 3
10
+ CHITINOUSPLATING = 4
11
+ HISECAUTOTRACKING = 5
12
+ TERRANBUILDINGARMOR = 6
13
+ TERRANINFANTRYWEAPONSLEVEL1 = 7
14
+ TERRANINFANTRYWEAPONSLEVEL2 = 8
15
+ TERRANINFANTRYWEAPONSLEVEL3 = 9
16
+ NEOSTEELFRAME = 10
17
+ TERRANINFANTRYARMORSLEVEL1 = 11
18
+ TERRANINFANTRYARMORSLEVEL2 = 12
19
+ TERRANINFANTRYARMORSLEVEL3 = 13
20
+ REAPERSPEED = 14
21
+ STIMPACK = 15
22
+ SHIELDWALL = 16
23
+ PUNISHERGRENADES = 17
24
+ SIEGETECH = 18
25
+ HIGHCAPACITYBARRELS = 19
26
+ BANSHEECLOAK = 20
27
+ MEDIVACCADUCEUSREACTOR = 21
28
+ RAVENCORVIDREACTOR = 22
29
+ HUNTERSEEKER = 23
30
+ DURABLEMATERIALS = 24
31
+ PERSONALCLOAKING = 25
32
+ GHOSTMOEBIUSREACTOR = 26
33
+ TERRANVEHICLEARMORSLEVEL1 = 27
34
+ TERRANVEHICLEARMORSLEVEL2 = 28
35
+ TERRANVEHICLEARMORSLEVEL3 = 29
36
+ TERRANVEHICLEWEAPONSLEVEL1 = 30
37
+ TERRANVEHICLEWEAPONSLEVEL2 = 31
38
+ TERRANVEHICLEWEAPONSLEVEL3 = 32
39
+ TERRANSHIPARMORSLEVEL1 = 33
40
+ TERRANSHIPARMORSLEVEL2 = 34
41
+ TERRANSHIPARMORSLEVEL3 = 35
42
+ TERRANSHIPWEAPONSLEVEL1 = 36
43
+ TERRANSHIPWEAPONSLEVEL2 = 37
44
+ TERRANSHIPWEAPONSLEVEL3 = 38
45
+ PROTOSSGROUNDWEAPONSLEVEL1 = 39
46
+ PROTOSSGROUNDWEAPONSLEVEL2 = 40
47
+ PROTOSSGROUNDWEAPONSLEVEL3 = 41
48
+ PROTOSSGROUNDARMORSLEVEL1 = 42
49
+ PROTOSSGROUNDARMORSLEVEL2 = 43
50
+ PROTOSSGROUNDARMORSLEVEL3 = 44
51
+ PROTOSSSHIELDSLEVEL1 = 45
52
+ PROTOSSSHIELDSLEVEL2 = 46
53
+ PROTOSSSHIELDSLEVEL3 = 47
54
+ OBSERVERGRAVITICBOOSTER = 48
55
+ GRAVITICDRIVE = 49
56
+ EXTENDEDTHERMALLANCE = 50
57
+ HIGHTEMPLARKHAYDARINAMULET = 51
58
+ PSISTORMTECH = 52
59
+ ZERGMELEEWEAPONSLEVEL1 = 53
60
+ ZERGMELEEWEAPONSLEVEL2 = 54
61
+ ZERGMELEEWEAPONSLEVEL3 = 55
62
+ ZERGGROUNDARMORSLEVEL1 = 56
63
+ ZERGGROUNDARMORSLEVEL2 = 57
64
+ ZERGGROUNDARMORSLEVEL3 = 58
65
+ ZERGMISSILEWEAPONSLEVEL1 = 59
66
+ ZERGMISSILEWEAPONSLEVEL2 = 60
67
+ ZERGMISSILEWEAPONSLEVEL3 = 61
68
+ OVERLORDSPEED = 62
69
+ OVERLORDTRANSPORT = 63
70
+ BURROW = 64
71
+ ZERGLINGATTACKSPEED = 65
72
+ ZERGLINGMOVEMENTSPEED = 66
73
+ HYDRALISKSPEED = 67
74
+ ZERGFLYERWEAPONSLEVEL1 = 68
75
+ ZERGFLYERWEAPONSLEVEL2 = 69
76
+ ZERGFLYERWEAPONSLEVEL3 = 70
77
+ ZERGFLYERARMORSLEVEL1 = 71
78
+ ZERGFLYERARMORSLEVEL2 = 72
79
+ ZERGFLYERARMORSLEVEL3 = 73
80
+ INFESTORENERGYUPGRADE = 74
81
+ CENTRIFICALHOOKS = 75
82
+ BATTLECRUISERENABLESPECIALIZATIONS = 76
83
+ BATTLECRUISERBEHEMOTHREACTOR = 77
84
+ PROTOSSAIRWEAPONSLEVEL1 = 78
85
+ PROTOSSAIRWEAPONSLEVEL2 = 79
86
+ PROTOSSAIRWEAPONSLEVEL3 = 80
87
+ PROTOSSAIRARMORSLEVEL1 = 81
88
+ PROTOSSAIRARMORSLEVEL2 = 82
89
+ PROTOSSAIRARMORSLEVEL3 = 83
90
+ WARPGATERESEARCH = 84
91
+ HALTECH = 85
92
+ CHARGE = 86
93
+ BLINKTECH = 87
94
+ ANABOLICSYNTHESIS = 88
95
+ OBVERSEINCUBATION = 89
96
+ VIKINGJOTUNBOOSTERS = 90
97
+ ORGANICCARAPACE = 91
98
+ INFESTORPERISTALSIS = 92
99
+ ABDOMINALFORTITUDE = 93
100
+ HYDRALISKSPEEDUPGRADE = 94
101
+ BANELINGBURROWMOVE = 95
102
+ COMBATDRUGS = 96
103
+ STRIKECANNONS = 97
104
+ TRANSFORMATIONSERVOS = 98
105
+ PHOENIXRANGEUPGRADE = 99
106
+ TEMPESTRANGEUPGRADE = 100
107
+ NEURALPARASITE = 101
108
+ LOCUSTLIFETIMEINCREASE = 102
109
+ ULTRALISKBURROWCHARGEUPGRADE = 103
110
+ ORACLEENERGYUPGRADE = 104
111
+ RESTORESHIELDS = 105
112
+ PROTOSSHEROSHIPWEAPON = 106
113
+ PROTOSSHEROSHIPDETECTOR = 107
114
+ PROTOSSHEROSHIPSPELL = 108
115
+ REAPERJUMP = 109
116
+ INCREASEDRANGE = 110
117
+ ZERGBURROWMOVE = 111
118
+ ANIONPULSECRYSTALS = 112
119
+ TERRANVEHICLEANDSHIPWEAPONSLEVEL1 = 113
120
+ TERRANVEHICLEANDSHIPWEAPONSLEVEL2 = 114
121
+ TERRANVEHICLEANDSHIPWEAPONSLEVEL3 = 115
122
+ TERRANVEHICLEANDSHIPARMORSLEVEL1 = 116
123
+ TERRANVEHICLEANDSHIPARMORSLEVEL2 = 117
124
+ TERRANVEHICLEANDSHIPARMORSLEVEL3 = 118
125
+ FLYINGLOCUSTS = 119
126
+ ROACHSUPPLY = 120
127
+ IMMORTALREVIVE = 121
128
+ DRILLCLAWS = 122
129
+ CYCLONELOCKONRANGEUPGRADE = 123
130
+ CYCLONEAIRUPGRADE = 124
131
+ LIBERATORMORPH = 125
132
+ ADEPTSHIELDUPGRADE = 126
133
+ LURKERRANGE = 127
134
+ IMMORTALBARRIER = 128
135
+ ADEPTKILLBOUNCE = 129
136
+ ADEPTPIERCINGATTACK = 130
137
+ CINEMATICMODE = 131
138
+ CURSORDEBUG = 132
139
+ MAGFIELDLAUNCHERS = 133
140
+ EVOLVEGROOVEDSPINES = 134
141
+ EVOLVEMUSCULARAUGMENTS = 135
142
+ BANSHEESPEED = 136
143
+ MEDIVACRAPIDDEPLOYMENT = 137
144
+ RAVENRECALIBRATEDEXPLOSIVES = 138
145
+ MEDIVACINCREASESPEEDBOOST = 139
146
+ LIBERATORAGRANGEUPGRADE = 140
147
+ DARKTEMPLARBLINKUPGRADE = 141
148
+ RAVAGERRANGE = 142
149
+ RAVENDAMAGEUPGRADE = 143
150
+ CYCLONELOCKONDAMAGEUPGRADE = 144
151
+ ARESCLASSWEAPONSSYSTEMVIKING = 145
152
+ AUTOHARVESTER = 146
153
+ HYBRIDCPLASMAUPGRADEHARD = 147
154
+ HYBRIDCPLASMAUPGRADEINSANE = 148
155
+ INTERCEPTORLIMIT4 = 149
156
+ INTERCEPTORLIMIT6 = 150
157
+ def self._330MMBARRAGECANNONS = 151
158
+ NOTPOSSIBLESIEGEMODE = 152
159
+ NEOSTEELFRAME_2 = 153
160
+ NEOSTEELANDSHRIKETURRETICONUPGRADE = 154
161
+ OCULARIMPLANTS = 155
162
+ CROSSSPECTRUMDAMPENERS = 156
163
+ ORBITALSTRIKE = 157
164
+ CLUSTERBOMB = 158
165
+ SHAPEDHULL = 159
166
+ SPECTRETOOLTIPUPGRADE = 160
167
+ ULTRACAPACITORS = 161
168
+ VANADIUMPLATING = 162
169
+ COMMANDCENTERREACTOR = 163
170
+ REGENERATIVEBIOSTEEL = 164
171
+ CELLULARREACTORS = 165
172
+ BANSHEECLOAKEDDAMAGE = 166
173
+ DISTORTIONBLASTERS = 167
174
+ EMPTOWER = 168
175
+ SUPPLYDEPOTDROP = 169
176
+ HIVEMINDEMULATOR = 170
177
+ FORTIFIEDBUNKERCARAPACE = 171
178
+ PREDATOR = 172
179
+ SCIENCEVESSEL = 173
180
+ DUALFUSIONWELDERS = 174
181
+ ADVANCEDCONSTRUCTION = 175
182
+ ADVANCEDMEDICTRAINING = 176
183
+ PROJECTILEACCELERATORS = 177
184
+ REINFORCEDSUPERSTRUCTURE = 178
185
+ MULE = 179
186
+ ORBITALRELAY = 180
187
+ RAZORWIRE = 181
188
+ ADVANCEDHEALINGAI = 182
189
+ TWINLINKEDFLAMETHROWERS = 183
190
+ NANOCONSTRUCTOR = 184
191
+ CERBERUSMINES = 185
192
+ HYPERFLUXOR = 186
193
+ TRILITHIUMPOWERCELLS = 187
194
+ PERMANENTCLOAKGHOST = 188
195
+ PERMANENTCLOAKSPECTRE = 189
196
+ ULTRASONICPULSE = 190
197
+ SURVIVALPODS = 191
198
+ ENERGYSTORAGE = 192
199
+ FULLBORECANISTERAMMO = 193
200
+ CAMPAIGNJOTUNBOOSTERS = 194
201
+ MICROFILTERING = 195
202
+ PARTICLECANNONAIR = 196
203
+ VULTUREAUTOREPAIR = 197
204
+ PSIDISRUPTOR = 198
205
+ SCIENCEVESSELENERGYMANIPULATION = 199
206
+ SCIENCEVESSELPLASMAWEAPONRY = 200
207
+ SHOWGATLINGGUN = 201
208
+ TECHREACTOR = 202
209
+ TECHREACTORAI = 203
210
+ TERRANDEFENSERANGEBONUS = 204
211
+ X88TNAPALMUPGRADE = 205
212
+ HURRICANEMISSILES = 206
213
+ MECHANICALREBIRTH = 207
214
+ MARINESTIMPACK = 208
215
+ DARKTEMPLARTACTICS = 209
216
+ CLUSTERWARHEADS = 210
217
+ CLOAKDISTORTIONFIELD = 211
218
+ DEVASTATORMISSILES = 212
219
+ DISTORTIONTHRUSTERS = 213
220
+ DYNAMICPOWERROUTING = 214
221
+ IMPALERROUNDS = 215
222
+ KINETICFIELDS = 216
223
+ BURSTCAPACITORS = 217
224
+ HAILSTORMMISSILEPODS = 218
225
+ RAPIDDEPLOYMENT = 219
226
+ REAPERSTIMPACK = 220
227
+ REAPERD8CHARGE = 221
228
+ TYCHUS05BATTLECRUISERPENETRATION = 222
229
+ VIRALPLASMA = 223
230
+ FIREBATJUGGERNAUTPLATING = 224
231
+ MULTILOCKTARGETINGSYSTEMS = 225
232
+ TURBOCHARGEDENGINES = 226
233
+ DISTORTIONSENSORS = 227
234
+ INFERNALPREIGNITERS = 228
235
+ HELLIONCAMPAIGNINFERNALPREIGNITER = 229
236
+ NAPALMFUELTANKS = 230
237
+ AUXILIARYMEDBOTS = 231
238
+ JUGGERNAUTPLATING = 232
239
+ MARAUDERLIFEBOOST = 233
240
+ COMBATSHIELD = 234
241
+ REAPERU238ROUNDS = 235
242
+ MAELSTROMROUNDS = 236
243
+ SIEGETANKSHAPEDBLAST = 237
244
+ TUNGSTENSPIKES = 238
245
+ BEARCLAWNOZZLES = 239
246
+ NANOBOTINJECTORS = 240
247
+ STABILIZERMEDPACKS = 241
248
+ HALOROCKETS = 242
249
+ SCAVENGINGSYSTEMS = 243
250
+ EXTRAMINES = 244
251
+ ARESCLASSWEAPONSSYSTEM = 245
252
+ WHITENAPALM = 246
253
+ VIRALMUNITIONS = 247
254
+ JACKHAMMERCONCUSSIONGRENADES = 248
255
+ FIRESUPPRESSIONSYSTEMS = 249
256
+ FLARERESEARCH = 250
257
+ MODULARCONSTRUCTION = 251
258
+ EXPANDEDHULL = 252
259
+ SHRIKETURRET = 253
260
+ MICROFUSIONREACTORS = 254
261
+ WRAITHCLOAK = 255
262
+ SINGULARITYCHARGE = 256
263
+ GRAVITICTHRUSTERS = 257
264
+ YAMATOCANNON = 258
265
+ DEFENSIVEMATRIX = 259
266
+ DARKPROTOSS = 260
267
+ TERRANINFANTRYWEAPONSULTRACAPACITORSLEVEL1 = 261
268
+ TERRANINFANTRYWEAPONSULTRACAPACITORSLEVEL2 = 262
269
+ TERRANINFANTRYWEAPONSULTRACAPACITORSLEVEL3 = 263
270
+ TERRANINFANTRYARMORSVANADIUMPLATINGLEVEL1 = 264
271
+ TERRANINFANTRYARMORSVANADIUMPLATINGLEVEL2 = 265
272
+ TERRANINFANTRYARMORSVANADIUMPLATINGLEVEL3 = 266
273
+ TERRANVEHICLEWEAPONSULTRACAPACITORSLEVEL1 = 267
274
+ TERRANVEHICLEWEAPONSULTRACAPACITORSLEVEL2 = 268
275
+ TERRANVEHICLEWEAPONSULTRACAPACITORSLEVEL3 = 269
276
+ TERRANVEHICLEARMORSVANADIUMPLATINGLEVEL1 = 270
277
+ TERRANVEHICLEARMORSVANADIUMPLATINGLEVEL2 = 271
278
+ TERRANVEHICLEARMORSVANADIUMPLATINGLEVEL3 = 272
279
+ TERRANSHIPWEAPONSULTRACAPACITORSLEVEL1 = 273
280
+ TERRANSHIPWEAPONSULTRACAPACITORSLEVEL2 = 274
281
+ TERRANSHIPWEAPONSULTRACAPACITORSLEVEL3 = 275
282
+ TERRANSHIPARMORSVANADIUMPLATINGLEVEL1 = 276
283
+ TERRANSHIPARMORSVANADIUMPLATINGLEVEL2 = 277
284
+ TERRANSHIPARMORSVANADIUMPLATINGLEVEL3 = 278
285
+ HIREKELMORIANMINERSPH = 279
286
+ HIREDEVILDOGSPH = 280
287
+ HIRESPARTANCOMPANYPH = 281
288
+ HIREHAMMERSECURITIESPH = 282
289
+ HIRESIEGEBREAKERSPH = 283
290
+ HIREHELSANGELSPH = 284
291
+ HIREDUSKWINGPH = 285
292
+ HIREDUKESREVENGE = 286
293
+ TOSHEASYMODE = 287
294
+ VOIDRAYSPEEDUPGRADE = 288
295
+ SMARTSERVOS = 289
296
+ ARMORPIERCINGROCKETS = 290
297
+ CYCLONERAPIDFIRELAUNCHERS = 291
298
+ RAVENENHANCEDMUNITIONS = 292
299
+ DIGGINGCLAWS = 293
300
+ CARRIERCARRIERCAPACITY = 294
301
+ CARRIERLEASHRANGEUPGRADE = 295
302
+ TEMPESTGROUNDATTACKUPGRADE = 296
303
+ MICROBIALSHROUD = 297
304
+ SUNDERINGIMPACT = 298
305
+ AMPLIFIEDSHIELDING = 299
306
+ PSIONICAMPLIFIERS = 300
307
+ SECRETEDCOATING = 301
308
+ ENHANCEDSHOCKWAVES = 302
309
+ HURRICANETHRUSTERS = 303
310
+ INTERFERENCEMATRIX = 304
311
+ end
312
+ end
@@ -0,0 +1,177 @@
1
+ require "thor"
2
+
3
+ require "sc2ai/cli/new"
4
+ require "sc2ai/cli/ladderzip"
5
+
6
+ module Sc2
7
+ # Command line utilities
8
+ # standard:disable Style/GlobalVars
9
+ class Cli < Thor
10
+ # Silence!
11
+ class << self
12
+ def exit_on_failure?
13
+ true
14
+ end
15
+ end
16
+
17
+ register(Sc2::Cli::New, "new", "new BOTNAME RACE", "Creates botname folder with bot template")
18
+ register(Sc2::Cli::Ladderzip, "ladderzip", "ladderzip BOTNAME", "Prepares a zip via docker for supplied aiarena bot name")
19
+
20
+ # TODO: Use thor's #ask and other methods helpers of raw $stdin and puts.
21
+ desc "setup410", "Downloads and install SC2 v4.10"
22
+ # downloads and install SC2 v4.10
23
+ def setup410
24
+ say " "
25
+ say "This script sets up SC2 at version 4.10, which we use competitively."
26
+ say "Press any key to continue..."
27
+ ask ""
28
+
29
+ say "You must accept the Blizzard® Starcraft® II AI and Machine Learning License at"
30
+ say "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html"
31
+ say "It is PERMISSIVE and grants you freedoms over the standard EULA."
32
+ say "We do not record this action, but depend on software goverend by that license to continue."
33
+ puts 'If you accept, type "iagreetotheeula" (without quotes) and press ENTER to continue:'
34
+
35
+ while $stdin.gets.chomp != "iagreetotheeula"
36
+ say ""
37
+ puts 'Type "iagreetotheeula" (without quotes) and press ENTER to continue:'
38
+ end
39
+ say ""
40
+ say ""
41
+ say "Great decision."
42
+
43
+ require "sc2ai"
44
+ Async do
45
+ Sc2.logger.level = :fatal
46
+ say "SC2 will launch a blank window, be unresponsive, but download about 100mb in the background."
47
+ say "Let it finish and close itself."
48
+ say "Press ENTER if you understand."
49
+ ask ""
50
+
51
+ say ""
52
+ say ""
53
+ say "This will only take a minute..."
54
+
55
+ Sc2.config.version = nil
56
+ client = Sc2::ClientManager.obtain(0)
57
+ if Gem.win_platform?
58
+ sleep(10)
59
+ end
60
+ observer = Sc2::Player::Observer.new
61
+ observer.connect(host: client.host, port: client.port)
62
+ setup_replay = Sc2::Paths.gem_root.join("data", "setup", "setup.SC2Replay")
63
+ observer.api.replay_info(
64
+ replay_data: File.binread(setup_replay),
65
+ download_data: true
66
+ )
67
+
68
+ # Auto-detect executable path and ensure it matched exactly
69
+ base_build = "75689"
70
+ path = Sc2::Paths.executable(base_build: base_build)
71
+ if path.include?(base_build) && Pathname(path).exist?
72
+ say " "
73
+ say "Success. Download complete.", :green
74
+ say " "
75
+ else
76
+ say "Error. Slightly worrying, but no fear.", :red
77
+ say "To manually setup, grab the latest ladder maps and add them to your map folder."
78
+ say "Grab the latest maps from https://aiarena.net/wiki/maps/"
79
+ say "Detected map folder: #{Sc2::Paths.maps_dir}"
80
+ say "Then, download any recent replay from https://aiarena.net/ and double click to launch"
81
+ end
82
+
83
+ observer.api.quit
84
+ observer.disconnect
85
+ say "Generating sc2ai.yml to always use 4.10..."
86
+ Sc2.config.config_file.write({"version" => "4.10"}.to_yaml.to_s)
87
+ say ""
88
+ say "Done. You're good to go.", :green
89
+ ensure
90
+ Sc2::ClientManager.stop(0)
91
+ end
92
+ end
93
+
94
+ desc "ladderconfig", "Prints out how you're configured for the ladder."
95
+ def ladderconfig
96
+ require "sc2ai"
97
+ unless Pathname("./boot.rb").exist?
98
+ raise Sc2::Error, "boot.rb not found. Bot started from wrong directory."
99
+ end
100
+
101
+ require "./boot"
102
+ # Debug
103
+ Sc2.logger.info "Bot class: #{$bot.class}"
104
+ Sc2.logger.info "Config:"
105
+ Sc2.logger.info " in-game name: #{$bot.name}"
106
+ Sc2.logger.info " race: #{Api::Race.lookup($bot.race)}"
107
+ Sc2.logger.info " realtime: #{$bot.realtime}"
108
+ Sc2.logger.info " step_count: #{$bot.step_count}"
109
+ Sc2.logger.info " enable_feature_layer: #{$bot.enable_feature_layer}"
110
+ Sc2.logger.info " interface_options: #{$bot.interface_options}"
111
+ end
112
+
113
+ # desc "ladderzip", "Uses docker to cross-compile a compatible binary for the ladder"
114
+ # def ladderzip
115
+ # end
116
+
117
+ # desc "ladderquickzip", "Ladder zip, if you have no additional gems installed."
118
+ # long_desc <<-LONGDESC
119
+ # `sc2ai ladderzip_basic` will download a portable ruby and gems, then copy your bot files into a zip file.
120
+ #
121
+ # If you have added any gems which need compiling, this option is not for you.
122
+ # Any gems built with native extensions will likely not be targeting the linux platform and be nonfunctional.
123
+ #
124
+ # For a cross-platform build, use ladderzip instead. This will launch a Docker container to compile a zip for you.
125
+ # LONGDESC
126
+ # def ladderquickzip
127
+ # raise Sc2::Error, "Not yet implemented."
128
+ # end
129
+
130
+ desc "laddermatch", "Joins a ladder match as per aiarena spec"
131
+ option :GamePort, required: true, desc: "SC2 port. Corresponds to SC2 launch option '-port'"
132
+ option :LadderServer, required: true, desc: "SC2 server ip or hostname"
133
+ option :StartPort, required: true, desc: "Match port range calculated starting at this port."
134
+ option :OpponentId, desc: "Unique identifier"
135
+ option :RealTime, type: :boolean, default: false, desc: "Forces realtime flag"
136
+ def laddermatch
137
+ require "sc2ai"
138
+
139
+ unless Sc2.ladder?
140
+ raise Sc2::Error, "This command is only for competing on aiarena.net"
141
+ end
142
+
143
+ unless Pathname("./boot.rb").exist?
144
+ raise Sc2::Error, "boot.rb not found. Bot started from wrong directory."
145
+ end
146
+
147
+ Sc2.logger.level = :info
148
+
149
+ require "./boot"
150
+
151
+ # Ladder specific overrides
152
+ $bot.realtime = true if options[:RealTime]
153
+ $bot.opponent_id = options[:OpponentId] if options[:OpponentId]
154
+
155
+ Async do
156
+ $bot.connect(host: options[:LadderServer], port: options[:GamePort])
157
+ $bot.join_game(
158
+ server_host: options[:LadderServer],
159
+ port_config: Sc2::Ports.port_config_basic(start_port: options[:StartPort], num_players: 2)
160
+ )
161
+ $bot.add_listener($bot, klass: Sc2::Connection::StatusListener)
162
+ $bot.play
163
+ end.wait
164
+ end
165
+
166
+ # desc "install APP_NAME", "install one of the available apps" # [4]
167
+ # method_options :force => :boolean, :alias => :string # [5]
168
+ # def install(name)
169
+ # user_alias = options[:alias]
170
+ # if options.force?
171
+ # # do something
172
+ # end
173
+ # # other code
174
+ # end
175
+ end
176
+ # standard:enable Style/GlobalVars
177
+ end
@@ -0,0 +1,173 @@
1
+ module Sc2
2
+ # Command line utilities
3
+ class Cli < Thor
4
+ # Populating "./build" with our source...
5
+ # - Symlink executable ./build/bin/ladder to ./.build/botname for ladder
6
+ # - copy our source to .build, sans .ladderignore
7
+ # copy .build to docker
8
+ # bundle install on docker
9
+ # zipping up code + ruby + gems
10
+ # get zip, clean up
11
+ # stop docker
12
+ # standard:disable Style/GlobalVars
13
+ class Ladderzip < Thor::Group
14
+ include Thor::Actions
15
+
16
+ # Define arguments and options
17
+ argument :botname, desc: "Your bot name as on aiarena.net. Will be used as a filename (alphanumeric, no spaces)."
18
+ desc "Builds a ladder zip using docker (requires docker)"
19
+
20
+ def docker_exists
21
+ if Kernel.system("docker --version", out: File::NULL, err: File::NULL)
22
+ say_status("docker", "found", :green)
23
+ else
24
+ say_status("docker", "not found", :red)
25
+ say("Please install 'docker' and/or ensure it's in your PATH to continue.")
26
+ raise SystemExit
27
+ end
28
+
29
+ if Kernel.system("docker info", out: File::NULL, err: File::NULL)
30
+ say_status("docker engine", "found", :green)
31
+ else
32
+ say(" ")
33
+ say_status("docker engine", "offline", :red)
34
+ say("Please start docker engine. If you have Docker Desktop installed, open it before retrying.")
35
+ raise SystemExit
36
+ end
37
+ end
38
+
39
+ def set_compose_file
40
+ @compose_file = Sc2::Paths.gem_root
41
+ .join("lib", "docker_build", "docker-compose-ladderzip.yml")
42
+ .expand_path.to_s
43
+ end
44
+
45
+ def bot_validation
46
+ if Pathname("./boot.rb").exist?
47
+ say_status("detected boot.rb", "found", :green)
48
+ else
49
+ say_status("detected boot.rb", "not found", :red)
50
+ raise Sc2::Error, "boot.rb not found. Bot started from wrong directory."
51
+ end
52
+
53
+ require "./boot"
54
+
55
+ if $bot.is_a? Sc2::Player
56
+ say_status("instance $bot", $bot.class, :green)
57
+ else
58
+ say_status("instance $bot", $bot.class, :red)
59
+ raise Sc2::Error, "$bot instance nil or not Sc2::Player. Review boot.rb to ensure it creates $bot."
60
+ end
61
+ end
62
+
63
+ def self.source_paths
64
+ [Pathname(".").expand_path.to_s]
65
+ end
66
+
67
+ def self.source_root
68
+ Paths.template_root.to_s
69
+ end
70
+
71
+ def ensure_build_dir
72
+ empty_directory "./.build"
73
+ end
74
+
75
+ def create_executable
76
+ template("ladderzip/bin/ladder", "./.build/bin/ladder")
77
+ # This fails on Windows. creating by hand in #link_ladder function below.
78
+ # create_link("./.build/#{botname}", "./bin/ladder")
79
+ end
80
+
81
+ def start_container
82
+ cmd = "docker compose -f #{@compose_file} up bot -d --force-recreate"
83
+ Kernel.system(cmd)
84
+ end
85
+
86
+ def populate_build
87
+ # Manually parse *ignore file. Not doing a docker build on this simply to abuse dockerignore.
88
+ ignore_pattern = File.open("./.ladderignore").each_line
89
+ .collect(&:strip)
90
+ .reject { |pt| pt&.start_with?("#") || pt&.size&.zero? }
91
+ ignore_pattern << "**.build/*"
92
+ ignore_pattern << "**.ruby/*"
93
+
94
+ include_pattern = ignore_pattern.select { |pt| pt&.start_with?("!") }
95
+ ignore_pattern -= include_pattern
96
+
97
+ include_pattern.collect! { |pt| pt.delete_prefix("!") }
98
+
99
+ files = Dir.glob("**/*")
100
+
101
+ ignored_files = files
102
+ .select { |f| ignore_pattern.any? { |p| File.fnmatch?(p, f) } }
103
+ .reject { |f| include_pattern.any? { |p| File.fnmatch?(p, f) } }
104
+
105
+ files -= ignored_files unless ignored_files.nil?
106
+
107
+ files.each do |file|
108
+ next if File.directory?(file)
109
+ copy_file file, "./.build/#{file}"
110
+ end
111
+ end
112
+
113
+ def copy_build_to_docker
114
+ say_status("docker", "copying source...", :cyan)
115
+ cmd = "docker compose -f #{@compose_file} cp ./.build/. bot:/root/ruby-builder/"
116
+ Kernel.system(cmd)
117
+ end
118
+
119
+ def link_ladder
120
+ say_status("docker", "linking executable...", :cyan)
121
+ cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot ln -s ./bin/ladder ./#{botname}"
122
+ Kernel.system(cmd)
123
+ end
124
+
125
+ def install_gems
126
+ say_status("docker", "bundle install...", :cyan)
127
+ cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot bundle install"
128
+ Kernel.system(cmd)
129
+ end
130
+
131
+ def compress
132
+ say_status("docker", "compress ladder zip...", :cyan)
133
+ cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot zip -qry9 /root/build.zip ."
134
+ Kernel.system(cmd)
135
+ end
136
+
137
+ def retreive_zip
138
+ say_status("docker", "pulling 'build.zip'", :green)
139
+ cmd = "docker compose -f #{@compose_file} cp bot:/root/build.zip ."
140
+ Kernel.system(cmd)
141
+ if File.exist?("./build.zip")
142
+ say_status("docker", "pulled 'build.zip' ok", :green)
143
+ else
144
+ say_status("docker", "error pulling 'build.zip'", :red)
145
+ exit
146
+ end
147
+ cmd = "docker compose -f #{@compose_file} exec bot rm /root/build.zip"
148
+ Kernel.system(cmd)
149
+ end
150
+
151
+ def clean
152
+ remove_file "./.build"
153
+ end
154
+
155
+ def stop_container
156
+ cmd = "docker compose --progress=plain -f #{@compose_file} stop bot"
157
+ Kernel.system(cmd)
158
+ end
159
+
160
+ def bye
161
+ say ""
162
+ say "Your bot is ready to upload. Use the file 'build.zip'."
163
+ say ""
164
+ say "A friendly reminder that since you passed \"#{botname}\", "
165
+ say "aiarena expects your bot to be named exactly that."
166
+ say "If the names mismatch, simply rerun this command with the correct BOTNAME."
167
+ say ""
168
+ say "Good luck."
169
+ end
170
+ end
171
+ # standard:enable Style/GlobalVars
172
+ end
173
+ end