sc2ai 0.2.0 → 0.3.0
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/sc2ai/protocol/common.proto +5 -5
- data/data/sc2ai/protocol/data.proto +22 -22
- data/data/sc2ai/protocol/debug.proto +24 -24
- data/data/sc2ai/protocol/error.proto +216 -215
- data/data/sc2ai/protocol/raw.proto +20 -20
- data/data/sc2ai/protocol/sc2api.proto +111 -111
- data/data/sc2ai/protocol/score.proto +3 -3
- data/data/sc2ai/protocol/spatial.proto +5 -5
- data/data/sc2ai/protocol/ui.proto +16 -16
- data/exe/sc2ai +0 -3
- data/lib/sc2ai/api/data.rb +3 -3
- data/lib/sc2ai/connection/connection_listener.rb +3 -3
- data/lib/sc2ai/connection/requests.rb +31 -35
- data/lib/sc2ai/connection/status_listener.rb +1 -1
- data/lib/sc2ai/connection.rb +1 -1
- data/lib/sc2ai/local_play/client.rb +2 -2
- data/lib/sc2ai/local_play/match.rb +7 -2
- data/lib/sc2ai/paths.rb +12 -2
- data/lib/sc2ai/player/actions.rb +54 -35
- data/lib/sc2ai/player/debug.rb +21 -21
- data/lib/sc2ai/player/game_state.rb +11 -18
- data/lib/sc2ai/player/geo.rb +54 -64
- data/lib/sc2ai/player/units.rb +16 -16
- data/lib/sc2ai/player.rb +103 -41
- data/lib/sc2ai/ports.rb +1 -1
- data/lib/sc2ai/protocol/_meta_documentation.rb +265 -265
- data/lib/sc2ai/protocol/common_pb.rb +3865 -15
- data/lib/sc2ai/protocol/data_pb.rb +9109 -18
- data/lib/sc2ai/protocol/debug_pb.rb +10437 -26
- data/lib/sc2ai/protocol/error_pb.rb +1086 -10
- data/lib/sc2ai/protocol/extensions/ability_remapable.rb +9 -9
- data/lib/sc2ai/protocol/extensions/action.rb +60 -0
- data/lib/sc2ai/protocol/extensions/point_2_d.rb +5 -0
- data/lib/sc2ai/protocol/extensions/position.rb +10 -35
- data/lib/sc2ai/protocol/extensions/power_source.rb +3 -0
- data/lib/sc2ai/protocol/extensions/unit.rb +19 -35
- data/lib/sc2ai/protocol/query_pb.rb +5025 -17
- data/lib/sc2ai/protocol/raw_pb.rb +18350 -27
- data/lib/sc2ai/protocol/sc2api_pb.rb +48420 -93
- data/lib/sc2ai/protocol/score_pb.rb +5968 -12
- data/lib/sc2ai/protocol/spatial_pb.rb +11944 -18
- data/lib/sc2ai/protocol/ui_pb.rb +12927 -28
- data/lib/sc2ai/unit_group/action_ext.rb +0 -2
- data/lib/sc2ai/unit_group/filter_ext.rb +10 -9
- data/lib/sc2ai/unit_group/geo_ext.rb +0 -2
- data/lib/sc2ai/unit_group.rb +1 -1
- data/lib/sc2ai/version.rb +2 -3
- data/lib/sc2ai.rb +10 -11
- data/lib/templates/ladderzip/bin/ladder.tt +0 -3
- data/lib/templates/new/api/common.proto +6 -6
- data/lib/templates/new/api/data.proto +23 -20
- data/lib/templates/new/api/debug.proto +25 -21
- data/lib/templates/new/api/error.proto +217 -215
- data/lib/templates/new/api/query.proto +1 -1
- data/lib/templates/new/api/raw.proto +16 -14
- data/lib/templates/new/api/sc2api.proto +108 -94
- data/lib/templates/new/api/score.proto +4 -3
- data/lib/templates/new/api/spatial.proto +6 -5
- data/lib/templates/new/api/ui.proto +17 -14
- data/lib/templates/new/boot.rb.tt +1 -1
- data/lib/templates/new/my_bot.rb.tt +1 -1
- data/lib/templates/new/run_example_match.rb.tt +2 -2
- data/sig/sc2ai.rbs +11005 -1926
- metadata +26 -21
- data/lib/sc2ai/overrides/kernel.rb +0 -33
- data/sig/minaswan.rbs +0 -10323
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "sc2ai/unit_group"
|
4
3
|
require "kdtree"
|
5
4
|
|
6
5
|
module Sc2
|
@@ -118,7 +117,7 @@ module Sc2
|
|
118
117
|
# structures.not.creep_tumors #=> all structures
|
119
118
|
# structures.not.pylons #=>
|
120
119
|
# units.not.workers # equivalent of units.army, but works too
|
121
|
-
# @return [Sc2::UnitGroupNotSelector]
|
120
|
+
# @return [Sc2::UnitGroup::UnitGroupNotSelector]
|
122
121
|
def not
|
123
122
|
UnitGroupNotSelector.new(self)
|
124
123
|
end
|
@@ -128,6 +127,8 @@ module Sc2
|
|
128
127
|
class UnitGroupNotSelector < UnitGroup
|
129
128
|
attr_accessor :parent
|
130
129
|
|
130
|
+
# @param unit_group [Sc2::UnitGroup]
|
131
|
+
# @return [UnitGroupNotSelector]
|
131
132
|
def initialize(unit_group)
|
132
133
|
@parent = unit_group
|
133
134
|
super
|
@@ -150,10 +151,10 @@ module Sc2
|
|
150
151
|
# Multiple values work as an "AND" filter
|
151
152
|
# @example
|
152
153
|
# # Single
|
153
|
-
# ug.select_attribute(Api::Attribute::
|
154
|
+
# ug.select_attribute(Api::Attribute::STRUCTURE) #=> <UnitGroup: ...>
|
154
155
|
# ug.select_attribute(:Structure) #=> <UnitGroup: ...>
|
155
156
|
# # Multiple - select mechanical flying units
|
156
|
-
# ug.select_attribute([:
|
157
|
+
# ug.select_attribute([:MECHANICAL, :FLYING]) #=> <UnitGroup: ...>
|
157
158
|
# @param attributes [Integer, Array<Integer>] one or an array of unit Api::UnitTypeId
|
158
159
|
# @return [UnitGroup]
|
159
160
|
def select_attribute(attributes)
|
@@ -170,7 +171,7 @@ module Sc2
|
|
170
171
|
# Multiple values work as an "AND" filter
|
171
172
|
# @example
|
172
173
|
# # Single
|
173
|
-
# ug.reject_attribute(Api::Attribute::
|
174
|
+
# ug.reject_attribute(Api::Attribute::STRUCTURE) #=> <UnitGroup: ...>
|
174
175
|
# ug.reject_attribute(:Structure) #=> <UnitGroup: ...>
|
175
176
|
# # Multiple - reject mechanical flying units
|
176
177
|
# ug.reject_attribute(:Mechanical, :Flying) #=> <UnitGroup: ...>
|
@@ -192,8 +193,8 @@ module Sc2
|
|
192
193
|
# i.e. @bot.all_units.owned # => Units you own
|
193
194
|
# @return [Sc2::UnitGroup] workers
|
194
195
|
def owned
|
195
|
-
cached("#{__method__}:
|
196
|
-
select { |unit| unit.alliance == :
|
196
|
+
cached("#{__method__}:SELF") do
|
197
|
+
select { |unit| unit.alliance == :SELF }
|
197
198
|
end
|
198
199
|
end
|
199
200
|
|
@@ -216,7 +217,7 @@ module Sc2
|
|
216
217
|
# Selects units with attribute Structure
|
217
218
|
# @return [Sc2::UnitGroup] structures
|
218
219
|
def structures
|
219
|
-
select_attribute(Api::Attribute::
|
220
|
+
select_attribute(Api::Attribute::STRUCTURE)
|
220
221
|
end
|
221
222
|
|
222
223
|
# Contains an array non-army types
|
@@ -405,7 +406,7 @@ module Sc2
|
|
405
406
|
attr_accessor :use_kdtree
|
406
407
|
|
407
408
|
# Builds a kdtree if not already built and returns it
|
408
|
-
# @return [Kdtree]
|
409
|
+
# @return [::Kdtree]
|
409
410
|
def kdtree
|
410
411
|
return @kdtree unless @kdtree.nil?
|
411
412
|
@kdtree = Kdtree.new(@units.values.each_with_index.map { |unit, index| [unit.pos.x, unit.pos.y, index] })
|
data/lib/sc2ai/unit_group.rb
CHANGED
data/lib/sc2ai/version.rb
CHANGED
data/lib/sc2ai.rb
CHANGED
@@ -38,20 +38,16 @@ Dir.glob(File.join(__dir__, "sc2ai", "overrides", "**", "*.rb")).each do |file|
|
|
38
38
|
require(file)
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
# during packing/unpacking, because they dont start capitalized, so we silence temporarily.
|
44
|
-
silence_warnings do
|
45
|
-
require "rumale"
|
46
|
-
require_relative "sc2ai/protocol/sc2api_pb"
|
47
|
-
end
|
41
|
+
require "rumale"
|
42
|
+
|
48
43
|
# noinspection RubyMismatchedArgumentType
|
49
|
-
Dir[File.join(__dir__, "sc2ai", "*.rb")].each { |file| require(file) }
|
50
|
-
# The upper include can probably preload everything it needs
|
44
|
+
Dir[File.join(__dir__, "sc2ai", "protocol", "*.rb")].sort.each { |file| require(file) }
|
51
45
|
# noinspection RubyMismatchedArgumentType
|
52
|
-
Dir[File.join(__dir__, "sc2ai", "protocol", "extensions", "
|
46
|
+
Dir[File.join(__dir__, "sc2ai", "protocol", "extensions", "*.rb")].sort.each { |file| require(file) }
|
53
47
|
# noinspection RubyMismatchedArgumentType
|
54
|
-
Dir[File.join(__dir__, "sc2ai", "
|
48
|
+
Dir[File.join(__dir__, "sc2ai", "*.rb")].sort.each { |file| require(file) }
|
49
|
+
# noinspection RubyMismatchedArgumentType
|
50
|
+
Dir[File.join(__dir__, "sc2ai", "local_play", "**", "*.rb")].sort.each { |file| require(file) }
|
55
51
|
|
56
52
|
# Facilitates StarCraft 2 AI
|
57
53
|
module Sc2
|
@@ -61,6 +57,7 @@ module Sc2
|
|
61
57
|
class << self
|
62
58
|
# Instantiate the Configuration singleton or return it.
|
63
59
|
# Remember that the instance has attribute readers so that we can access the configured values
|
60
|
+
# @return [Sc2::Configuration]
|
64
61
|
def config
|
65
62
|
@config ||= Configuration.new
|
66
63
|
yield @config if block_given?
|
@@ -81,6 +78,8 @@ module Sc2
|
|
81
78
|
|
82
79
|
@logger = Logger.new($stdout)
|
83
80
|
@logger.level = :debug
|
81
|
+
@logger.datetime_format = "%H:%M:%S.%6N"
|
82
|
+
|
84
83
|
@logger
|
85
84
|
end
|
86
85
|
|
@@ -15,9 +15,6 @@ export RUBY_GC_HEAP_INIT_SIZE_160_SLOTS=18000
|
|
15
15
|
export RUBY_GC_HEAP_INIT_SIZE_320_SLOTS=2000
|
16
16
|
export RUBY_GC_HEAP_INIT_SIZE_640_SLOTS=1000
|
17
17
|
|
18
|
-
# Maxime <3
|
19
|
-
export RUBY_YJIT_ENABLE=true
|
20
|
-
|
21
18
|
export AIARENA=true
|
22
19
|
sc2ai ladderconfig
|
23
20
|
exec sc2ai laddermatch "$@" 1>&2
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
syntax = "
|
2
|
+
syntax = "proto3";
|
3
3
|
|
4
4
|
package Api;
|
5
5
|
|
@@ -49,11 +49,11 @@ message Size2DI {
|
|
49
49
|
}
|
50
50
|
|
51
51
|
enum Race {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
NO_RACE = 0;
|
53
|
+
TERRAN = 1;
|
54
|
+
ZERG = 2;
|
55
|
+
PROTOSS = 3;
|
56
|
+
RANDOM = 4;
|
57
57
|
}
|
58
58
|
|
59
59
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
syntax = "
|
2
|
+
syntax = "proto3";
|
3
3
|
|
4
4
|
package Api;
|
5
5
|
|
@@ -19,11 +19,12 @@ message AbilityData {
|
|
19
19
|
optional uint32 remaps_to_ability_id = 7; // This ability id may be represented by the given more generic id.
|
20
20
|
|
21
21
|
enum Target {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
ENUM_TARGET_UNSET = 0; // PROTO3 COMPAT
|
23
|
+
NONE = 1; // DOES NOT REQUIRE A TARGET.
|
24
|
+
POINT = 2; // REQUIRES A TARGET POSITION.
|
25
|
+
UNIT = 3; // REQUIRES A UNIT TO TARGET. GIVEN BY POSITION USING FEATURE LAYERS.
|
26
|
+
POINT_OR_UNIT = 4; // REQUIRES EITHER A TARGET POINT OR TARGET UNIT.
|
27
|
+
POINT_OR_NONE = 5; // REQUIRES EITHER A TARGET POINT OR NO TARGET. (EG. BUILDING ADD_ONS)
|
27
28
|
}
|
28
29
|
|
29
30
|
optional bool available = 8; // If true, the ability may be used by this set of mods/map.
|
@@ -37,17 +38,18 @@ message AbilityData {
|
|
37
38
|
}
|
38
39
|
|
39
40
|
enum Attribute {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
ENUM_ATTRIBUTE_UNSET = 0; // PROTO3 COMPAT
|
42
|
+
LIGHT = 1;
|
43
|
+
ARMORED = 2;
|
44
|
+
BIOLOGICAL = 3;
|
45
|
+
MECHANICAL = 4;
|
46
|
+
ROBOTIC = 5;
|
47
|
+
PSIONIC = 6;
|
48
|
+
MASSIVE = 7;
|
49
|
+
STRUCTURE = 8;
|
50
|
+
HOVER = 9;
|
51
|
+
HEROIC = 10;
|
52
|
+
SUMMONED = 11;
|
51
53
|
}
|
52
54
|
|
53
55
|
message DamageBonus {
|
@@ -57,9 +59,10 @@ message DamageBonus {
|
|
57
59
|
|
58
60
|
message Weapon {
|
59
61
|
enum TargetType {
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
ENUM_TARGET_TYPE_UNSET = 0; // PROTO3 COMPAT
|
63
|
+
GROUND = 1;
|
64
|
+
AIR = 2;
|
65
|
+
ANY = 3;
|
63
66
|
}
|
64
67
|
optional TargetType type = 1;
|
65
68
|
optional float damage = 2;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
syntax = "
|
2
|
+
syntax = "proto3";
|
3
3
|
|
4
4
|
package Api;
|
5
5
|
|
@@ -67,18 +67,19 @@ message DebugSphere {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
enum DebugGameState {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
70
|
+
ENUM_DEBUG_GAME_STATE_UNSET = 0; // PROTO3 COMPAT
|
71
|
+
SHOW_MAP = 1;
|
72
|
+
CONTROL_ENEMY = 2;
|
73
|
+
FOOD = 3;
|
74
|
+
FREE = 4;
|
75
|
+
ALL_RESOURCES = 5;
|
76
|
+
GOD = 6;
|
77
|
+
MINERALS = 7;
|
78
|
+
GAS = 8;
|
79
|
+
COOLDOWNS = 9;
|
80
|
+
TECH_TREE = 10;
|
81
|
+
UPGRADE = 11;
|
82
|
+
FAST_BUILD = 12;
|
82
83
|
}
|
83
84
|
|
84
85
|
message DebugCreateUnit {
|
@@ -94,9 +95,10 @@ message DebugKillUnit {
|
|
94
95
|
|
95
96
|
message DebugTestProcess {
|
96
97
|
enum Test {
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
ENUM_TEST_UNSET = 0; // PROTO3 COMPAT
|
99
|
+
HANG = 1;
|
100
|
+
CRASH = 2;
|
101
|
+
EXIT = 3;
|
100
102
|
}
|
101
103
|
optional Test test = 1;
|
102
104
|
optional int32 delay_ms = 2;
|
@@ -108,17 +110,19 @@ message DebugSetScore {
|
|
108
110
|
|
109
111
|
message DebugEndGame {
|
110
112
|
enum EndResult {
|
111
|
-
|
112
|
-
|
113
|
+
ENUM_END_RESULT_UNSET = 0; // PROTO3 COMPAT
|
114
|
+
SURRENDER = 1; // DEFAULT IF NOTHING IS SET. THE CURRENT PLAYER ADMITS DEFEAT.
|
115
|
+
DECLARE_VICTORY = 2;
|
113
116
|
}
|
114
117
|
optional EndResult end_result = 1;
|
115
118
|
}
|
116
119
|
|
117
120
|
message DebugSetUnitValue {
|
118
121
|
enum UnitValue {
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
+
ENUM_UNIT_VALUE_UNSET = 0; // PROTO3 COMPAT
|
123
|
+
ENERGY = 1;
|
124
|
+
LIFE = 2;
|
125
|
+
SHIELDS = 3;
|
122
126
|
}
|
123
127
|
optional UnitValue unit_value = 1;
|
124
128
|
optional float value = 2;
|