sc2ai 0.6.2 → 0.6.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a52a7a32bf219355f194817695d5505e47a897da5f3023ff856f4c88a66cc4d0
4
- data.tar.gz: 94a565f3dc3c3f43896559664961242a9c06b30429bb41345183eb3fd680f29c
3
+ metadata.gz: 9da11456b2d9014945dc54f3a92dfc47cef7ecf40be7facaceb75bc8a04df9b1
4
+ data.tar.gz: e5926c8416141ef1a8677e8fb0832126414cdbed3729951f236ecab14274d336
5
5
  SHA512:
6
- metadata.gz: 8275c1840c4c7a9548a08ccf90215d41d8eabea15f7915109221f0c8c1deba96847103fc7f552927304c23b702a53aab5f091d8af7a52da33d7d0c419cfe2369
7
- data.tar.gz: c547597a3bfb0babfbc2765c0d9fb6af7fab9137077faaf6f419ff51cad0cdfc30dd9816bab8383e9559b1cabc88aa5ec908aaf66348e3ac5570192708c23959
6
+ metadata.gz: 3ce8e35ea773557def35d44eff9dfc63a475b09c82ad573644cae647b222da83f65047a0a935d0465aad5919002144e6c28543792539f4783dad88700225f5ef
7
+ data.tar.gz: 5848c68e72fad356096f6b7bf2da049ee9f7f3a4c36676f682401d9e612f71d26d8950d94c733e4cda04887592a2be030faadc3f6e2d1b918528c2aa63e5eada
@@ -4,7 +4,7 @@ LABEL service="bot-ruby-local"
4
4
  USER root
5
5
  WORKDIR /root/ruby-builder
6
6
 
7
- ARG RUBY_VERSION=3.4.2
7
+ ARG RUBY_VERSION=3.4.3
8
8
  ARG DEBIAN_DISABLE_RUBYGEMS_INTEGRATION=true
9
9
 
10
10
  # Deps - Ruby build
data/lib/sc2ai/cli/cli.rb CHANGED
@@ -72,7 +72,11 @@ module Sc2
72
72
  say "Generating sc2ai.yml to always use 4.10..."
73
73
  Sc2.config.config_file.write({"version" => "4.10"}.to_yaml.to_s)
74
74
  say ""
75
- say "Done. You're good to go.", :green
75
+ say "Done. You're good to go."
76
+ say "To run an example match, execute:"
77
+ say ""
78
+ say "ruby run_example_match.rb", :green
79
+ say ""
76
80
  ensure
77
81
  Sc2::ClientManager.stop(0)
78
82
  end
@@ -83,7 +83,7 @@ module Sc2
83
83
  end
84
84
 
85
85
  def start_container
86
- cmd = "docker compose -f #{@compose_file} up versus_bot -d --force-recreate"
86
+ cmd = "docker compose -f #{@compose_file} up bot -d --force-recreate"
87
87
  Kernel.system(cmd)
88
88
  end
89
89
 
@@ -304,6 +304,25 @@ module Sc2
304
304
  true
305
305
  end
306
306
 
307
+ # Checks whether you have met the tech requirements for building a specific unit type
308
+ # @param [Integer] unit_type_id
309
+ # @return [Boolean]
310
+ def tech_requirement_met?(unit_type_id)
311
+ created_from_unit_type = Api::TechTree.unit_created_from(unit_type_id: unit_type_id)
312
+ required_building = Api::TechTree.unit_type_creation_abilities(
313
+ source: created_from_unit_type.first,
314
+ target: unit_type_id
315
+ )[:required_building]
316
+
317
+ # Ensure we have required building, if there's such a requirement
318
+ if required_building
319
+ return false unless all_units.owned.select_type(required_building).completed.size > 0
320
+ end
321
+
322
+ # Ensure we have a completed source which it's created from
323
+ all_units.owned.select_type(created_from_unit_type).completed.size > 0
324
+ end
325
+
307
326
  # Micro/Unit-Specific ------
308
327
 
309
328
  # Returns whether Query Available Ability is true for unit and tag
@@ -58,75 +58,74 @@ module Api
58
58
  # @return [Boolean] whether unit has attribute
59
59
  # @example
60
60
  # unit.has_attribute?(Api::Attribute::MECHANICAL)
61
- # unit.has_attribute?(:MECHANICAL)
62
61
  def has_attribute?(attribute)
63
62
  attributes.include? attribute
64
63
  end
65
64
 
66
65
  # Checks if unit is light
67
- # @return [Boolean] whether unit has attribute :Light
66
+ # @return [Boolean] whether unit has attribute :LIGHT
68
67
  def is_light?
69
- has_attribute?(:LIGHT)
68
+ has_attribute?(Api::Attribute::LIGHT)
70
69
  end
71
70
 
72
71
  # Checks if unit is armored
73
- # @return [Boolean] whether unit has attribute :Armored
72
+ # @return [Boolean] whether unit has attribute :ARMORED
74
73
  def is_armored?
75
- has_attribute?(:ARMORED)
74
+ has_attribute?(Api::Attribute::ARMORED)
76
75
  end
77
76
 
78
77
  # Checks if unit is biological
79
- # @return [Boolean] whether unit has attribute :Biological
78
+ # @return [Boolean] whether unit has attribute :BIOLOGICAL
80
79
  def is_biological?
81
- has_attribute?(:BIOLOGICAL)
80
+ has_attribute?(Api::Attribute::BIOLOGICAL)
82
81
  end
83
82
 
84
83
  # Checks if unit is mechanical
85
- # @return [Boolean] whether unit has attribute :Mechanical
84
+ # @return [Boolean] whether unit has attribute :MECHANICAL
86
85
  def is_mechanical?
87
- has_attribute?(:MECHANICAL)
86
+ has_attribute?(Api::Attribute::MECHANICAL)
88
87
  end
89
88
 
90
89
  # Checks if unit is robotic
91
- # @return [Boolean] whether unit has attribute :Robotic
90
+ # @return [Boolean] whether unit has attribute :ROBOTIC
92
91
  def is_robotic?
93
- has_attribute?(:ROBOTIC)
92
+ has_attribute?(Api::Attribute::ROBOTIC)
94
93
  end
95
94
 
96
95
  # Checks if unit is psionic
97
- # @return [Boolean] whether unit has attribute :Psionic
96
+ # @return [Boolean] whether unit has attribute :PSIONIC
98
97
  def is_psionic?
99
- has_attribute?(:PSIONIC)
98
+ has_attribute?(Api::Attribute::PSIONIC)
100
99
  end
101
100
 
102
101
  # Checks if unit is massive
103
- # @return [Boolean] whether unit has attribute :Massive
102
+ # @return [Boolean] whether unit has attribute :MASSIVE
104
103
  def is_massive?
105
- has_attribute?(:MASSIVE)
104
+ has_attribute?(Api::Attribute::MASSIVE)
106
105
  end
107
106
 
108
107
  # Checks if unit is structure
109
- # @return [Boolean] whether unit has attribute :Structure
108
+ # @return [Boolean] whether unit has attribute :STRUCTURE
110
109
  def is_structure?
111
- has_attribute?(:STRUCTURE)
110
+ has_attribute?(Api::Attribute::STRUCTURE)
112
111
  end
113
112
 
114
113
  # Checks if unit is hovering
115
- # @return [Boolean] whether unit has attribute :Hover
114
+ # @return [Boolean] whether unit has attribute :HOVER
116
115
  def is_hover?
117
- has_attribute?(:HOVER)
116
+ has_attribute?(Api::Attribute::HOVER)
118
117
  end
119
118
 
120
119
  # Checks if unit is heroic
121
- # @return [Boolean] whether unit has attribute :Heroic
120
+ # @return [Boolean] whether unit has attribute :HEROIC
122
121
  def is_heroic?
123
- has_attribute?(:HEROIC)
122
+ has_attribute?(Api::Attribute::HEROIC)
124
123
  end
125
124
 
126
125
  # Checks if unit is summoned
127
- # @return [Boolean] whether unit has attribute :Summoned
126
+ # @return [Boolean] whether unit has attribute :SUMMONED
128
127
  def is_summoned?
129
- has_attribute?(:SUMMONED)
128
+ has_attribute?(Api::Attribute::SUMMONED)
130
129
  end
131
130
 
132
131
  # @!group Virtual properties
@@ -86,6 +86,17 @@ module Sc2
86
86
  Api::UnitTypeId::SPORECRAWLER
87
87
  ].freeze
88
88
 
89
+ # Protoss: An array of unit types warped from Warp Gate.
90
+ # @return [Array<Integer>]
91
+ TYPE_WARPGATE_UNIT = [
92
+ Api::UnitTypeId::ZEALOT,
93
+ Api::UnitTypeId::STALKER,
94
+ Api::UnitTypeId::HIGHTEMPLAR,
95
+ Api::UnitTypeId::DARKTEMPLAR,
96
+ Api::UnitTypeId::SENTRY,
97
+ Api::UnitTypeId::ADEPT
98
+ ].freeze
99
+
89
100
  # Returns a new UnitGroup containing all units matching unit type id(s)
90
101
  # Multiple values work as an "OR" filter
91
102
  # @example
@@ -172,7 +183,7 @@ module Sc2
172
183
  def select_attribute(attributes)
173
184
  cached("#{__method__}:#{attributes.hash}") do
174
185
  attributes = [attributes] unless attributes.is_a? Array
175
- attributes = attributes.map { |a| a.is_a?(Symbol) ? a : Api::Attribute.lookup(a) }
186
+ attributes = attributes.map { |a| a.is_a?(Symbol) ? Api::Attribute.lookup(a) : a }
176
187
  select do |unit|
177
188
  attributes & unit.attributes == attributes
178
189
  end
@@ -192,7 +203,7 @@ module Sc2
192
203
  def reject_attribute(attributes)
193
204
  cached("#{__method__}:#{attributes.hash}") do
194
205
  attributes = [attributes] unless attributes.is_a? Array
195
- attributes = attributes.map { |a| a.is_a?(Symbol) ? a : Api::Attribute.lookup(a) }
206
+ attributes = attributes.map { |a| a.is_a?(Symbol) ? Api::Attribute.lookup(a) : a }
196
207
  reject do |unit|
197
208
  unit.attributes & attributes == attributes
198
209
  end
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.6.2"
4
+ VERSION = "0.6.5"
5
5
  end
data/sig/sc2ai.rbs CHANGED
@@ -1012,6 +1012,11 @@ module Sc2
1012
1012
  # Checks whether you have the resources to
1013
1013
  def can_afford_upgrade?: (untyped upgrade_id) -> bool
1014
1014
 
1015
+ # Checks whether you have met the tech requirements for building a specific unit type
1016
+ #
1017
+ # _@param_ `unit_type_id`
1018
+ def tech_requirement_met?: (Integer unit_type_id) -> bool
1019
+
1015
1020
  # Returns whether Query Available Ability is true for unit and tag
1016
1021
  # Queries API if necessary. Uses batching in the background.
1017
1022
  #
@@ -1142,6 +1147,11 @@ module Sc2
1142
1147
  # Checks whether you have the resources to
1143
1148
  def can_afford_upgrade?: (untyped upgrade_id) -> bool
1144
1149
 
1150
+ # Checks whether you have met the tech requirements for building a specific unit type
1151
+ #
1152
+ # _@param_ `unit_type_id`
1153
+ def tech_requirement_met?: (Integer unit_type_id) -> bool
1154
+
1145
1155
  # Returns whether Query Available Ability is true for unit and tag
1146
1156
  # Queries API if necessary. Uses batching in the background.
1147
1157
  #
@@ -1866,6 +1876,11 @@ module Sc2
1866
1876
  # Checks whether you have the resources to
1867
1877
  def can_afford_upgrade?: (untyped upgrade_id) -> bool
1868
1878
 
1879
+ # Checks whether you have met the tech requirements for building a specific unit type
1880
+ #
1881
+ # _@param_ `unit_type_id`
1882
+ def tech_requirement_met?: (Integer unit_type_id) -> bool
1883
+
1869
1884
  # Returns whether Query Available Ability is true for unit and tag
1870
1885
  # Queries API if necessary. Uses batching in the background.
1871
1886
  #
@@ -2327,6 +2342,11 @@ module Sc2
2327
2342
  # Checks whether you have the resources to
2328
2343
  def can_afford_upgrade?: (untyped upgrade_id) -> bool
2329
2344
 
2345
+ # Checks whether you have met the tech requirements for building a specific unit type
2346
+ #
2347
+ # _@param_ `unit_type_id`
2348
+ def tech_requirement_met?: (Integer unit_type_id) -> bool
2349
+
2330
2350
  # Returns whether Query Available Ability is true for unit and tag
2331
2351
  # Queries API if necessary. Uses batching in the background.
2332
2352
  #
@@ -3103,6 +3123,7 @@ module Sc2
3103
3123
  TYPE_REACTOR: ::Array[Integer]
3104
3124
  TYPE_BASES: ::Array[Integer]
3105
3125
  TYPE_DETECTORS: ::Array[Integer]
3126
+ TYPE_WARPGATE_UNIT: ::Array[Integer]
3106
3127
 
3107
3128
  # _@param_ `units` — default to be added.
3108
3129
  #
@@ -3733,6 +3754,7 @@ module Sc2
3733
3754
  TYPE_REACTOR: ::Array[Integer]
3734
3755
  TYPE_BASES: ::Array[Integer]
3735
3756
  TYPE_DETECTORS: ::Array[Integer]
3757
+ TYPE_WARPGATE_UNIT: ::Array[Integer]
3736
3758
 
3737
3759
  # _@param_ `unit_group`
3738
3760
  def initialize: (Sc2::UnitGroup unit_group) -> void
@@ -8484,63 +8506,62 @@ module Api
8484
8506
  #
8485
8507
  # ```ruby
8486
8508
  # unit.has_attribute?(Api::Attribute::MECHANICAL)
8487
- # unit.has_attribute?(:MECHANICAL)
8488
8509
  # ```
8489
8510
  def has_attribute?: (untyped attribute) -> bool
8490
8511
 
8491
8512
  # Checks if unit is light
8492
8513
  #
8493
- # _@return_ — whether unit has attribute :Light
8514
+ # _@return_ — whether unit has attribute :LIGHT
8494
8515
  def is_light?: () -> bool
8495
8516
 
8496
8517
  # Checks if unit is armored
8497
8518
  #
8498
- # _@return_ — whether unit has attribute :Armored
8519
+ # _@return_ — whether unit has attribute :ARMORED
8499
8520
  def is_armored?: () -> bool
8500
8521
 
8501
8522
  # Checks if unit is biological
8502
8523
  #
8503
- # _@return_ — whether unit has attribute :Biological
8524
+ # _@return_ — whether unit has attribute :BIOLOGICAL
8504
8525
  def is_biological?: () -> bool
8505
8526
 
8506
8527
  # Checks if unit is mechanical
8507
8528
  #
8508
- # _@return_ — whether unit has attribute :Mechanical
8529
+ # _@return_ — whether unit has attribute :MECHANICAL
8509
8530
  def is_mechanical?: () -> bool
8510
8531
 
8511
8532
  # Checks if unit is robotic
8512
8533
  #
8513
- # _@return_ — whether unit has attribute :Robotic
8534
+ # _@return_ — whether unit has attribute :ROBOTIC
8514
8535
  def is_robotic?: () -> bool
8515
8536
 
8516
8537
  # Checks if unit is psionic
8517
8538
  #
8518
- # _@return_ — whether unit has attribute :Psionic
8539
+ # _@return_ — whether unit has attribute :PSIONIC
8519
8540
  def is_psionic?: () -> bool
8520
8541
 
8521
8542
  # Checks if unit is massive
8522
8543
  #
8523
- # _@return_ — whether unit has attribute :Massive
8544
+ # _@return_ — whether unit has attribute :MASSIVE
8524
8545
  def is_massive?: () -> bool
8525
8546
 
8526
8547
  # Checks if unit is structure
8527
8548
  #
8528
- # _@return_ — whether unit has attribute :Structure
8549
+ # _@return_ — whether unit has attribute :STRUCTURE
8529
8550
  def is_structure?: () -> bool
8530
8551
 
8531
8552
  # Checks if unit is hovering
8532
8553
  #
8533
- # _@return_ — whether unit has attribute :Hover
8554
+ # _@return_ — whether unit has attribute :HOVER
8534
8555
  def is_hover?: () -> bool
8535
8556
 
8536
8557
  # Checks if unit is heroic
8537
8558
  #
8538
- # _@return_ — whether unit has attribute :Heroic
8559
+ # _@return_ — whether unit has attribute :HEROIC
8539
8560
  def is_heroic?: () -> bool
8540
8561
 
8541
8562
  # Checks if unit is summoned
8542
8563
  #
8543
- # _@return_ — whether unit has attribute :Summoned
8564
+ # _@return_ — whether unit has attribute :SUMMONED
8544
8565
  def is_summoned?: () -> bool
8545
8566
 
8546
8567
  # Returns whether the unit is cloaked. Revealed cloak units also return true.
@@ -20433,63 +20454,62 @@ module Api
20433
20454
  #
20434
20455
  # ```ruby
20435
20456
  # unit.has_attribute?(Api::Attribute::MECHANICAL)
20436
- # unit.has_attribute?(:MECHANICAL)
20437
20457
  # ```
20438
20458
  def has_attribute?: (untyped attribute) -> bool
20439
20459
 
20440
20460
  # Checks if unit is light
20441
20461
  #
20442
- # _@return_ — whether unit has attribute :Light
20462
+ # _@return_ — whether unit has attribute :LIGHT
20443
20463
  def is_light?: () -> bool
20444
20464
 
20445
20465
  # Checks if unit is armored
20446
20466
  #
20447
- # _@return_ — whether unit has attribute :Armored
20467
+ # _@return_ — whether unit has attribute :ARMORED
20448
20468
  def is_armored?: () -> bool
20449
20469
 
20450
20470
  # Checks if unit is biological
20451
20471
  #
20452
- # _@return_ — whether unit has attribute :Biological
20472
+ # _@return_ — whether unit has attribute :BIOLOGICAL
20453
20473
  def is_biological?: () -> bool
20454
20474
 
20455
20475
  # Checks if unit is mechanical
20456
20476
  #
20457
- # _@return_ — whether unit has attribute :Mechanical
20477
+ # _@return_ — whether unit has attribute :MECHANICAL
20458
20478
  def is_mechanical?: () -> bool
20459
20479
 
20460
20480
  # Checks if unit is robotic
20461
20481
  #
20462
- # _@return_ — whether unit has attribute :Robotic
20482
+ # _@return_ — whether unit has attribute :ROBOTIC
20463
20483
  def is_robotic?: () -> bool
20464
20484
 
20465
20485
  # Checks if unit is psionic
20466
20486
  #
20467
- # _@return_ — whether unit has attribute :Psionic
20487
+ # _@return_ — whether unit has attribute :PSIONIC
20468
20488
  def is_psionic?: () -> bool
20469
20489
 
20470
20490
  # Checks if unit is massive
20471
20491
  #
20472
- # _@return_ — whether unit has attribute :Massive
20492
+ # _@return_ — whether unit has attribute :MASSIVE
20473
20493
  def is_massive?: () -> bool
20474
20494
 
20475
20495
  # Checks if unit is structure
20476
20496
  #
20477
- # _@return_ — whether unit has attribute :Structure
20497
+ # _@return_ — whether unit has attribute :STRUCTURE
20478
20498
  def is_structure?: () -> bool
20479
20499
 
20480
20500
  # Checks if unit is hovering
20481
20501
  #
20482
- # _@return_ — whether unit has attribute :Hover
20502
+ # _@return_ — whether unit has attribute :HOVER
20483
20503
  def is_hover?: () -> bool
20484
20504
 
20485
20505
  # Checks if unit is heroic
20486
20506
  #
20487
- # _@return_ — whether unit has attribute :Heroic
20507
+ # _@return_ — whether unit has attribute :HEROIC
20488
20508
  def is_heroic?: () -> bool
20489
20509
 
20490
20510
  # Checks if unit is summoned
20491
20511
  #
20492
- # _@return_ — whether unit has attribute :Summoned
20512
+ # _@return_ — whether unit has attribute :SUMMONED
20493
20513
  def is_summoned?: () -> bool
20494
20514
 
20495
20515
  # Returns whether the unit is cloaked. Revealed cloak units also return true.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sc2ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dyson Returns
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async
@@ -65,6 +65,20 @@ dependencies:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '1.3'
68
+ - !ruby/object:Gem::Dependency
69
+ name: logger
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
68
82
  - !ruby/object:Gem::Dependency
69
83
  name: numo-narray
70
84
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +122,7 @@ dependencies:
108
122
  - !ruby/object:Gem::Version
109
123
  version: '1.0'
110
124
  - !ruby/object:Gem::Dependency
111
- name: logger
125
+ name: fiddle
112
126
  requirement: !ruby/object:Gem::Requirement
113
127
  requirements:
114
128
  - - ">="
@@ -122,7 +136,7 @@ dependencies:
122
136
  - !ruby/object:Gem::Version
123
137
  version: '0'
124
138
  - !ruby/object:Gem::Dependency
125
- name: fiddle
139
+ name: cgi
126
140
  requirement: !ruby/object:Gem::Requirement
127
141
  requirements:
128
142
  - - ">="
@@ -136,7 +150,7 @@ dependencies:
136
150
  - !ruby/object:Gem::Version
137
151
  version: '0'
138
152
  - !ruby/object:Gem::Dependency
139
- name: reline
153
+ name: irb
140
154
  requirement: !ruby/object:Gem::Requirement
141
155
  requirements:
142
156
  - - ">="
@@ -458,14 +472,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
458
472
  requirements:
459
473
  - - ">="
460
474
  - !ruby/object:Gem::Version
461
- version: 3.3.7
475
+ version: 3.3.8
462
476
  required_rubygems_version: !ruby/object:Gem::Requirement
463
477
  requirements:
464
478
  - - ">="
465
479
  - !ruby/object:Gem::Version
466
480
  version: '0'
467
481
  requirements: []
468
- rubygems_version: 3.6.3
482
+ rubygems_version: 3.6.8
469
483
  specification_version: 4
470
484
  summary: STARCRAFT® II AI API
471
485
  test_files: []