sc2ai 0.0.6 → 0.0.7
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/stableid.json +424 -2562
- data/data/versions.json +8 -0
- data/lib/docker_build/Dockerfile.ruby +1 -1
- data/lib/sc2ai/api/ability_id.rb +12 -314
- data/lib/sc2ai/api/buff_id.rb +9 -16
- data/lib/sc2ai/api/data.rb +1 -1
- data/lib/sc2ai/api/tech_tree.rb +35 -0
- data/lib/sc2ai/api/tech_tree_data.rb +14 -9
- data/lib/sc2ai/api/unit_type_id.rb +6 -58
- data/lib/sc2ai/api/upgrade_id.rb +9 -9
- data/lib/sc2ai/connection/requests.rb +10 -7
- data/lib/sc2ai/data.rb +101 -0
- data/lib/sc2ai/local_play/match.rb +1 -3
- data/lib/sc2ai/player/actions.rb +8 -4
- data/lib/sc2ai/player/debug.rb +2 -3
- data/lib/sc2ai/player/game_state.rb +28 -0
- data/lib/sc2ai/player/geometry.rb +44 -39
- data/lib/sc2ai/player/previous_state.rb +1 -0
- data/lib/sc2ai/player/units.rb +25 -3
- data/lib/sc2ai/player.rb +3 -3
- data/lib/sc2ai/protocol/_meta_documentation.rb +18 -0
- data/lib/sc2ai/protocol/extensions/point_2_d.rb +1 -1
- data/lib/sc2ai/protocol/extensions/point_distance.rb +11 -0
- data/lib/sc2ai/protocol/extensions/position.rb +8 -10
- data/lib/sc2ai/protocol/extensions/unit.rb +29 -3
- data/lib/sc2ai/protocol/extensions/unit_type.rb +9 -0
- data/lib/sc2ai/unit_group/action_ext.rb +3 -3
- data/lib/sc2ai/unit_group/filter_ext.rb +22 -7
- data/lib/sc2ai/version.rb +1 -1
- data/lib/templates/new/run_example_match.rb.tt +1 -1
- data/sig/sc2ai.rbs +383 -509
- metadata +20 -17
@@ -227,6 +227,7 @@ module Api
|
|
227
227
|
# @param target [Api::Unit, Integer, Api::Point2D] is a unit, unit tag or a Api::Point2D
|
228
228
|
# @param queue_command [Boolean] shift+command
|
229
229
|
def attack(target:, queue_command: false)
|
230
|
+
return false if target.nil?
|
230
231
|
action(ability_id: Api::AbilityId::ATTACK, target:, queue_command:)
|
231
232
|
end
|
232
233
|
|
@@ -241,7 +242,7 @@ module Api
|
|
241
242
|
end
|
242
243
|
|
243
244
|
# Builds target unit type, i.e. issuing a build command to worker.build(...Api::UnitTypeId::BARRACKS)
|
244
|
-
# @param unit_type_id [Integer] Api::UnitTypeId the unit type
|
245
|
+
# @param unit_type_id [Integer] Api::UnitTypeId the unit type you wish to build
|
245
246
|
# @param target [Api::Point2D, Integer, nil] is a unit tag or a Api::Point2D. Nil for addons/orbital
|
246
247
|
# @param queue_command [Boolean] shift+command
|
247
248
|
def build(unit_type_id:, target: nil, queue_command: false)
|
@@ -263,7 +264,7 @@ module Api
|
|
263
264
|
end
|
264
265
|
|
265
266
|
# Research a specific upgrade
|
266
|
-
# @param upgrade_id [Integer] Api::UnitTypeId the unit type
|
267
|
+
# @param upgrade_id [Integer] Api::UnitTypeId the unit type you wish to research
|
267
268
|
# @param queue_command [Boolean] shift+command
|
268
269
|
def research(upgrade_id:, queue_command: false)
|
269
270
|
@bot.research(units: self, upgrade_id:, queue_command:)
|
@@ -359,7 +360,7 @@ module Api
|
|
359
360
|
# @param target [Api::Unit, Integer] optionally check if unit is engaged with specific target
|
360
361
|
def is_attacking?(target: nil)
|
361
362
|
is_performing_ability_on_target?(
|
362
|
-
[Api::AbilityId::ATTACK_ATTACK],
|
363
|
+
[Api::AbilityId::ATTACK_ATTACK, Api::AbilityId::ATTACK],
|
363
364
|
target:
|
364
365
|
)
|
365
366
|
end
|
@@ -421,6 +422,14 @@ module Api
|
|
421
422
|
end
|
422
423
|
end
|
423
424
|
|
425
|
+
# Returns whether this unit has an ability available
|
426
|
+
# Queries API if necessary
|
427
|
+
# @param [Integer] ability_id
|
428
|
+
# @return [Boolean]
|
429
|
+
def ability_available?(ability_id)
|
430
|
+
@bot.unit_ability_available?(unit_tag: tag, ability_id:)
|
431
|
+
end
|
432
|
+
|
424
433
|
# Checks whether a weapon can target a unit
|
425
434
|
# @param unit [Api::unit]
|
426
435
|
# @param weapon [Api::Weapon]
|
@@ -546,8 +555,25 @@ module Api
|
|
546
555
|
build(unit_type_id: unit_type_id, queue_command:)
|
547
556
|
end
|
548
557
|
|
558
|
+
# PROTOSS Convenience functions ---
|
559
|
+
|
560
|
+
# Warps in unit type at target (location or pylon)
|
561
|
+
# Only works if the source is a Warp Gate
|
562
|
+
# @param unit_type_id [Integer] Api::UnitTypeId the unit type you wish to build
|
563
|
+
# @param target [Api::Point2D] a point, which should be inside an energy source
|
564
|
+
# @param queue_command [Boolean] shift+command
|
565
|
+
def warp(unit_type_id:, target:, queue_command: false)
|
566
|
+
@bot.warp(units: self, unit_type_id:, target:, queue_command:)
|
567
|
+
end
|
568
|
+
|
549
569
|
# GENERAL Convenience functions ---
|
550
570
|
|
571
|
+
# Returns true if unit does not have orders
|
572
|
+
# @return [Boolean] whether unit is idle
|
573
|
+
def is_idle?
|
574
|
+
orders.empty?
|
575
|
+
end
|
576
|
+
|
551
577
|
# ...
|
552
578
|
|
553
579
|
private
|
@@ -26,7 +26,7 @@ module Sc2
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Builds target unit type, i.e. issuing a build command to worker.build(...Api::UnitTypeId::BARRACKS)
|
29
|
-
# @param unit_type_id [Integer] Api::UnitTypeId the unit type
|
29
|
+
# @param unit_type_id [Integer] Api::UnitTypeId the unit type you wish to build
|
30
30
|
# @param target [Api::Point2D, 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)
|
@@ -41,10 +41,10 @@ module Sc2
|
|
41
41
|
|
42
42
|
# Warps in unit type at target (location or pylon)
|
43
43
|
# Will only have affect is this group consists of warp gates, i.e. bot.structures.warpgates
|
44
|
-
# @param unit_type_id [Integer] Api::UnitTypeId the unit type
|
44
|
+
# @param unit_type_id [Integer] Api::UnitTypeId the unit type you wish to build
|
45
45
|
# @param target [Api::Point2D] a point, which should be inside an energy source
|
46
46
|
# @param queue_command [Boolean] shift+command
|
47
|
-
def warp(unit_type_id:, target
|
47
|
+
def warp(unit_type_id:, target:, queue_command: false)
|
48
48
|
return if size.zero?
|
49
49
|
bot&.warp(units: self, unit_type_id:, target:, queue_command:)
|
50
50
|
end
|
@@ -121,13 +121,14 @@ module Sc2
|
|
121
121
|
|
122
122
|
# @private
|
123
123
|
# Does the opposite of selector and returns those values for parent
|
124
|
-
def
|
125
|
-
@parent.
|
124
|
+
def select(...)
|
125
|
+
@parent.reject(...)
|
126
126
|
end
|
127
127
|
|
128
|
+
# @private
|
128
129
|
# Does the opposite of selector and returns those values for parent
|
129
|
-
def
|
130
|
-
@parent.
|
130
|
+
def reject(...)
|
131
|
+
@parent.select(...)
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
@@ -230,14 +231,28 @@ module Sc2
|
|
230
231
|
alias_method :assimilators, :gas
|
231
232
|
|
232
233
|
# Selects only units which have finished constructing, i.o.w. build_progress == 1.0
|
233
|
-
# @return [UnitGroup]
|
234
|
+
# @return [UnitGroup] complete unit group
|
234
235
|
def completed
|
235
236
|
select(&:is_completed?)
|
236
237
|
end
|
237
238
|
|
239
|
+
# Selects only units which have finished constructing, i.o.w. build_progress != 1.0
|
240
|
+
# @return [UnitGroup] incomplete unit group
|
241
|
+
def incomplete
|
242
|
+
reject(&:is_completed?)
|
243
|
+
end
|
244
|
+
|
238
245
|
# Selects only units which do not have orders
|
239
246
|
def idle
|
240
|
-
select
|
247
|
+
select(&:is_idle?)
|
248
|
+
end
|
249
|
+
|
250
|
+
# Selects units which have this ability available\
|
251
|
+
# Queries API if necessary
|
252
|
+
# @param [Integer] ability_id
|
253
|
+
# @return [UnitGroup] units which have the ability available
|
254
|
+
def ability_available?(ability_id)
|
255
|
+
select { |unit| unit.ability_available?(ability_id) }
|
241
256
|
end
|
242
257
|
|
243
258
|
# NEUTRAL ------------------------------------------
|
@@ -340,7 +355,7 @@ module Sc2
|
|
340
355
|
# Selects pylons and warp prisms in phasing mode
|
341
356
|
# @return [Sc2::UnitGroup] pylons annd warp prisms phasing
|
342
357
|
def warpables
|
343
|
-
select_type([Api::UnitTypeId::PYLON, Api::UnitTypeId::WARPPRISMPHASING])
|
358
|
+
select_type([Api::UnitTypeId::PYLON, Api::UnitTypeId::WARPPRISMPHASING]).completed
|
344
359
|
end
|
345
360
|
|
346
361
|
# Geometric/Map ---
|
data/lib/sc2ai/version.rb
CHANGED