sc2ai 0.0.0.pre → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/data/data.json +1 -0
  3. data/data/data_readable.json +22842 -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 +35730 -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 +1644 -0
  23. data/lib/sc2ai/api/buff_id.rb +306 -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 +83 -0
  27. data/lib/sc2ai/api/tech_tree_data.rb +2338 -0
  28. data/lib/sc2ai/api/unit_type_id.rb +2022 -0
  29. data/lib/sc2ai/api/upgrade_id.rb +310 -0
  30. data/lib/sc2ai/cli/cli.rb +175 -0
  31. data/lib/sc2ai/cli/ladderzip.rb +154 -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. data/sc2ai.gemspec +80 -0
  94. metadata +344 -13
@@ -0,0 +1,310 @@
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
+ end
310
+ end
@@ -0,0 +1,175 @@
1
+ require "thor"
2
+ require "sc2ai/cli/new"
3
+ require "sc2ai/cli/ladderzip"
4
+
5
+ module Sc2
6
+ # Command line utilities
7
+ # standard:disable Style/GlobalVars
8
+ class Cli < Thor
9
+ # Silence!
10
+ class << self
11
+ def exit_on_failure?
12
+ true
13
+ end
14
+ end
15
+
16
+ register(Sc2::Cli::New, "new", "new BOTNAME RACE", "Creates botname folder with bot template")
17
+ register(Sc2::Cli::Ladderzip, "ladderzip", "ladderzip BOTNAME", "Prepares a zip via docker for supplied aiarena bot name")
18
+
19
+ # TODO: Use thor's #ask and other methods helpers of raw $stdin and puts.
20
+ desc "setup410", "Downloads and install SC2 v4.10"
21
+ # downloads and install SC2 v4.10
22
+ def setup410
23
+ puts " "
24
+ puts "This script sets up SC2 at version 4.10, which we use competitively."
25
+ puts "Press any key to continue..."
26
+ puts " "
27
+ $stdin.getch
28
+
29
+ puts "You must accept the Blizzard® Starcraft® II AI and Machine Learning License at"
30
+ puts "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html"
31
+ puts "It is PERMISSIVE and grants you freedoms over the standard EULA."
32
+ puts "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
+ puts ""
37
+ puts 'Type "iagreetotheeula" (without quotes) and press ENTER to continue:'
38
+ end
39
+ puts ""
40
+ puts ""
41
+ puts "Great decision."
42
+
43
+ Async do
44
+ Sc2.logger.level = :fatal
45
+ puts "SC2 will launch a blank window, be unresponsive, but download about 100mb in the background."
46
+ puts "Let it finish and close itself."
47
+ puts "Press ENTER if you understand."
48
+ $stdin.getch
49
+
50
+ puts ""
51
+ puts ""
52
+ puts "This will only take a minute..."
53
+
54
+ Sc2.config.version = nil
55
+ client = Sc2::ClientManager.obtain(0)
56
+ if Gem.win_platform?
57
+ sleep(10)
58
+ end
59
+ observer = Sc2::Player::Observer.new
60
+ observer.connect(host: client.host, port: client.port)
61
+ setup_replay = Sc2::Paths.gem_root.join("data", "setup", "setup.SC2Replay")
62
+ observer.api.replay_info(
63
+ replay_data: File.binread(setup_replay),
64
+ download_data: true
65
+ )
66
+
67
+ # Auto-detect executable path and ensure it matched exactly
68
+ base_build = "75689"
69
+ path = Sc2::Paths.executable(base_build: base_build)
70
+ if path.include?(base_build) && Pathname(path).exist?
71
+ puts " "
72
+ puts "Success. Downloaded complete."
73
+ puts " "
74
+ else
75
+ puts "Error. Slightly worrying, but no fear."
76
+ puts "To manually setup, grab the latest ladder maps and add them to your map folder."
77
+ puts "Grab the latest maps from https://aiarena.net/wiki/maps/"
78
+ puts "Detected map folder: #{Sc2::Paths.maps_dir}"
79
+ puts "Then, download any recent replay from https://aiarena.net/ and double click to launch"
80
+ end
81
+
82
+ observer.disconnect
83
+ puts "Generating sc2ai.yml to always use 4.10..."
84
+ Sc2.config.config_file.write({"version" => "4.10"}.to_yaml.to_s)
85
+ puts ""
86
+ puts "Done. You're good to go."
87
+ ensure
88
+ Sc2::ClientManager.stop(0)
89
+ end
90
+ end
91
+
92
+ desc "ladderconfig", "Prints out how you're configured for the ladder."
93
+ def ladderconfig
94
+ require "sc2ai"
95
+ unless Pathname("./boot.rb").exist?
96
+ raise Sc2::Error, "boot.rb not found. Bot started from wrong directory."
97
+ end
98
+
99
+ require "./boot"
100
+ # Debug
101
+ Sc2.logger.info "Bot class: #{$bot.class}"
102
+ Sc2.logger.info "Config:"
103
+ Sc2.logger.info " in-game name: #{$bot.name}"
104
+ Sc2.logger.info " race: #{Api::Race.lookup($bot.race)}"
105
+ Sc2.logger.info " realtime: #{$bot.realtime}"
106
+ Sc2.logger.info " step_count: #{$bot.step_count}"
107
+ Sc2.logger.info " enable_feature_layer: #{$bot.enable_feature_layer}"
108
+ Sc2.logger.info " interface_options: #{$bot.interface_options}"
109
+ end
110
+
111
+ # desc "ladderzip", "Uses docker to cross-compile a compatible binary for the ladder"
112
+ # def ladderzip
113
+ # end
114
+
115
+ # desc "ladderquickzip", "Ladder zip, if you have no additional gems installed."
116
+ # long_desc <<-LONGDESC
117
+ # `sc2ai ladderzip_basic` will download a portable ruby and gems, then copy your bot files into a zip file.
118
+ #
119
+ # If you have added any gems which need compiling, this option is not for you.
120
+ # Any gems built with native extensions will likely not be targeting the linux platform and be nonfunctional.
121
+ #
122
+ # For a cross-platform build, use ladderzip instead. This will launch a Docker container to compile a zip for you.
123
+ # LONGDESC
124
+ # def ladderquickzip
125
+ # raise Sc2::Error, "Not yet implemented."
126
+ # end
127
+
128
+ desc "laddermatch", "Joins a ladder match as per aiarena spec"
129
+ option :GamePort, required: true, desc: "SC2 port. Corresponds to SC2 launch option '-port'"
130
+ option :LadderServer, required: true, desc: "SC2 server ip or hostname"
131
+ option :StartPort, required: true, desc: "Match port range calculated starting at this port."
132
+ option :OpponentId, desc: "Unique identifier"
133
+ option :RealTime, type: :boolean, default: false, desc: "Forces realtime flag"
134
+ def laddermatch
135
+ require "sc2ai"
136
+
137
+ unless Sc2.ladder?
138
+ raise Sc2::Error, "This command is only for competing on aiarena.net"
139
+ end
140
+
141
+ unless Pathname("./boot.rb").exist?
142
+ raise Sc2::Error, "boot.rb not found. Bot started from wrong directory."
143
+ end
144
+
145
+ Sc2.logger.level = :info
146
+
147
+ require "./boot"
148
+
149
+ # Ladder specific overrides
150
+ $bot.realtime = true if options[:RealTime]
151
+ $bot.opponent_id = options[:OpponentId] if options[:OpponentId]
152
+
153
+ Async do
154
+ $bot.connect(host: options[:LadderServer], port: options[:GamePort])
155
+ $bot.join_game(
156
+ server_host: options[:LadderServer],
157
+ port_config: Sc2::Ports.port_config_basic(start_port: options[:StartPort], num_players: 2)
158
+ )
159
+ $bot.add_listener($bot, klass: Sc2::Connection::StatusListener)
160
+ $bot.play
161
+ end.wait
162
+ end
163
+
164
+ # desc "install APP_NAME", "install one of the available apps" # [4]
165
+ # method_options :force => :boolean, :alias => :string # [5]
166
+ # def install(name)
167
+ # user_alias = options[:alias]
168
+ # if options.force?
169
+ # # do something
170
+ # end
171
+ # # other code
172
+ # end
173
+ end
174
+ # standard:enable Style/GlobalVars
175
+ end
@@ -0,0 +1,154 @@
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")
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
+ end
27
+ end
28
+
29
+ def set_compose_file
30
+ @compose_file = Sc2::Paths.gem_root
31
+ .join("lib", "docker_build", "docker-compose-ladderzip.yml")
32
+ .expand_path.to_s
33
+ end
34
+
35
+ def bot_validation
36
+ if Pathname("./boot.rb").exist?
37
+ say_status("detected boot.rb", "found", :green)
38
+ else
39
+ say_status("detected boot.rb", "not found", :red)
40
+ raise Sc2::Error, "boot.rb not found. Bot started from wrong directory."
41
+ end
42
+
43
+ require "./boot"
44
+
45
+ if $bot.is_a? Sc2::Player
46
+ say_status("instance $bot", $bot.class, :green)
47
+ else
48
+ say_status("instance $bot", $bot.class, :red)
49
+ raise Sc2::Error, "$bot instance nil or not Sc2::Player. Review boot.rb to ensure it creates $bot."
50
+ end
51
+ end
52
+
53
+ def self.source_paths
54
+ [Pathname(".").expand_path.to_s]
55
+ end
56
+
57
+ def self.source_root
58
+ Paths.template_root.to_s
59
+ end
60
+
61
+ def ensure_build_dir
62
+ empty_directory "./.build"
63
+ end
64
+
65
+ def create_executable
66
+ template("ladderzip/bin/ladder", "./.build/bin/ladder")
67
+ create_link(".build/#{botname}", "./bin/ladder")
68
+ end
69
+
70
+ def start_container
71
+ cmd = "docker compose -f #{@compose_file} up bot -d --force-recreate"
72
+ Kernel.system(cmd)
73
+ end
74
+
75
+ def populate_build
76
+ # Manually parse *ignore file. Not doing a docker build on this simply to abuse dockerignore.
77
+ ignore_pattern = File.open("./.ladderignore").each_line
78
+ .collect(&:strip)
79
+ .reject { |pt| pt&.start_with?("#") || pt&.size&.zero? }
80
+ ignore_pattern << "**.build/*"
81
+ ignore_pattern << "**.ruby/*"
82
+
83
+ include_pattern = ignore_pattern.select { |pt| pt&.start_with?("!") }
84
+ ignore_pattern -= include_pattern
85
+
86
+ include_pattern.collect! { |pt| pt.delete_prefix("!") }
87
+
88
+ files = Dir.glob("**/*")
89
+ ignored_files = files
90
+ .select { |f| ignore_pattern.any? { |p| File.fnmatch?(p, f) } }
91
+ .reject! { |f| include_pattern.any? { |p| File.fnmatch?(p, f) } }
92
+ files -= ignored_files unless ignored_files.nil?
93
+
94
+ files.each do |file|
95
+ next if File.directory?(file)
96
+ copy_file file, "./.build/#{file}"
97
+ end
98
+ end
99
+
100
+ def copy_build_to_docker
101
+ say_status("docker", "copying source...", :cyan)
102
+ cmd = "docker compose -f #{@compose_file} cp ./.build/. bot:/root/ruby-builder/"
103
+ Kernel.system(cmd)
104
+ end
105
+
106
+ def install_gems
107
+ say_status("docker", "bundle install...", :cyan)
108
+ cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot bundle install"
109
+ Kernel.system(cmd)
110
+ end
111
+
112
+ def compress
113
+ say_status("docker", "compress ladder zip...", :cyan)
114
+ cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot zip -qry9 /root/build.zip ."
115
+ Kernel.system(cmd)
116
+ end
117
+
118
+ def retreive_zip
119
+ say_status("docker", "pulling 'build.zip'", :green)
120
+ cmd = "docker compose -f #{@compose_file} cp bot:/root/build.zip ."
121
+ Kernel.system(cmd)
122
+ if File.exist?("./build.zip")
123
+ say_status("docker", "pulled 'build.zip' ok", :green)
124
+ else
125
+ say_status("docker", "error pulling 'build.zip'", :red)
126
+ exit
127
+ end
128
+ cmd = "docker compose -f #{@compose_file} exec bot rm /root/build.zip"
129
+ Kernel.system(cmd)
130
+ end
131
+
132
+ def clean
133
+ remove_file "./.build"
134
+ end
135
+
136
+ def stop_container
137
+ cmd = "docker compose --progress=plain -f #{@compose_file} stop bot"
138
+ Kernel.system(cmd)
139
+ end
140
+
141
+ def bye
142
+ say ""
143
+ say "Your bot is ready to upload. Use the file 'build.zip'."
144
+ say ""
145
+ say "A friendly reminder that since you passed \"#{botname}\", "
146
+ say "aiarena expects your bot to be named exactly that."
147
+ say "If the names mismatch, simply rerun this command with the correct BOTNAME."
148
+ say ""
149
+ say "Good luck."
150
+ end
151
+ end
152
+ # standard:enable Style/GlobalVars
153
+ end
154
+ end