sc2ai 0.5.0 → 0.6.1

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.
@@ -23,6 +23,36 @@ module Api
23
23
  # i.e. 2 for Supply Depot (2x2)
24
24
  # @return [Integer] side-length for placement
25
25
  attr_accessor :placement_length
26
+
27
+ # @!attribute ground_range
28
+ # Ground weapon range or 0.0 when it can't shoot ground
29
+ # @return [Float]
30
+ attr_accessor :ground_range
31
+
32
+ # @!attribute air_range
33
+ # Air weapon range or 0.0 when it can't shoot air
34
+ # @return [Float]
35
+ attr_accessor :air_range
36
+
37
+ # @!attribute ground_damage
38
+ # Ground weapon damage or 0.0
39
+ # @return [Float]
40
+ attr_accessor :ground_damage
41
+
42
+ # @!attribute air_damage
43
+ # Air weapon damage or 0.0
44
+ # @return [Float]
45
+ attr_accessor :air_damage
46
+
47
+ # @!attribute ground_dps
48
+ # Ground weapon damage per second or 0.0
49
+ # @return [Float]
50
+ attr_accessor :ground_dps
51
+
52
+ # @!attribute air_dps
53
+ # Air weapon damage per second or 0.0
54
+ # @return [Float]
55
+ attr_accessor :air_dps
26
56
  end
27
57
  end
28
58
  Api::UnitTypeData.prepend Api::UnitTypeDataExtension
@@ -74,6 +74,18 @@ module Sc2
74
74
  Api::UnitTypeId::HATCHERY, Api::UnitTypeId::HIVE, Api::UnitTypeId::LAIR,
75
75
  Api::UnitTypeId::NEXUS
76
76
  ].freeze
77
+
78
+ # An array of passive detector unit types.
79
+ # Does not include units with detection abilities, such as Oracle/Ghost
80
+ # @return [Array<Integer>]
81
+ TYPE_DETECTORS = [
82
+ Api::UnitTypeId::RAVEN, Api::UnitTypeId::MISSILETURRET,
83
+ Api::UnitTypeId::OBSERVER, Api::UnitTypeId::OBSERVERSIEGEMODE,
84
+ Api::UnitTypeId::PHOTONCANNON,
85
+ Api::UnitTypeId::OVERSEER, Api::UnitTypeId::OVERSEERSIEGEMODE,
86
+ Api::UnitTypeId::SPORECRAWLER
87
+ ].freeze
88
+
77
89
  # Returns a new UnitGroup containing all units matching unit type id(s)
78
90
  # Multiple values work as an "OR" filter
79
91
  # @example
@@ -254,6 +266,12 @@ module Sc2
254
266
  alias_method :extractors, :gas
255
267
  alias_method :assimilators, :gas
256
268
 
269
+ # Selects units passively have Detection
270
+ # @return [UnitGroup] gas structures
271
+ def detectors
272
+ select_type(TYPE_DETECTORS)
273
+ end
274
+
257
275
  # Selects only units which have finished constructing, i.o.w. build_progress == 1.0
258
276
  # @return [UnitGroup] complete unit group
259
277
  def completed
@@ -374,7 +392,7 @@ module Sc2
374
392
  select_type(Api::UnitTypeId::CREEPTUMORBURROWED)
375
393
  end
376
394
 
377
- # Protoss ---
395
+ # PROTOSS ---
378
396
 
379
397
  # Selects pylons
380
398
  # @return [Sc2::UnitGroup] pylons
@@ -416,7 +434,10 @@ module Sc2
416
434
  # @param pos [Sc2::Position] unit.pos or a point of any kind
417
435
  # @return [Sc2::UnitGroup, Api::Unit, nil] return group or single unit if amount is not supplied
418
436
  def nearest_to(pos:, amount: nil)
419
- return UnitGroup.new if !amount.nil? && amount.to_i <= 0
437
+ unless amount.nil?
438
+ return UnitGroup.new if amount <= 0
439
+ return self if amount > @units.size
440
+ end
420
441
 
421
442
  if use_kdtree
422
443
  if amount.nil?
data/lib/sc2ai/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Sc2
2
2
  # gem version
3
3
  # @return [String]
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.1"
5
5
  end
@@ -89,7 +89,7 @@ message UnitTypeData {
89
89
  optional float sight_range = 25; // Range unit reveals vision.
90
90
 
91
91
  repeated uint32 tech_alias = 21 [packed=false]; // Other units that satisfy the same tech requirement.
92
- optional uint32 unit_alias = 22 [packed=false]; // The morphed variant of this unit.
92
+ optional uint32 unit_alias = 22; // The morphed variant of this unit.
93
93
 
94
94
  optional uint32 tech_requirement = 23; // Structure required to build this unit. (Or any with the same tech_alias)
95
95
  optional bool require_attached = 24; // Whether tech_requirement is an add-on.
@@ -191,7 +191,7 @@ message ActionRawUnitCommand {
191
191
  uint64 target_unit_tag = 3;
192
192
  }
193
193
  repeated uint64 unit_tags = 4 [packed=false];
194
- optional bool queue_command = 5 [packed=false];
194
+ optional bool queue_command = 5;
195
195
  }
196
196
 
197
197
  message ActionRawCameraMove {
@@ -1,5 +1,5 @@
1
1
  # Use the ladder's boot.rb file and configure there
2
- require "./boot.rb"
2
+ require_relative "boot"
3
3
 
4
4
  # Or simply, create by hand
5
5
  #my_bot = MyBot.new(name: "Botname", race: Api::Race::RANDOM)