sc2ai 0.4.2 → 0.5.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/data/sc2ai/protocol/data.proto +2 -2
  3. data/data/sc2ai/protocol/debug.proto +1 -1
  4. data/data/sc2ai/protocol/raw.proto +6 -6
  5. data/data/sc2ai/protocol/sc2api.proto +1 -1
  6. data/data/sc2ai/protocol/ui.proto +1 -1
  7. data/{lib/docker_build → docker_build}/Dockerfile.ruby +2 -2
  8. data/lib/sc2ai/cli/ladderzip.rb +1 -1
  9. data/lib/sc2ai/local_play/client.rb +1 -1
  10. data/lib/sc2ai/local_play/match.rb +1 -0
  11. data/lib/sc2ai/overrides/async/process/child.rb +2 -1
  12. data/lib/sc2ai/paths.rb +0 -1
  13. data/lib/sc2ai/player/debug.rb +3 -3
  14. data/lib/sc2ai/player.rb +9 -0
  15. data/lib/sc2ai/protocol/common_pb.rb +460 -105
  16. data/lib/sc2ai/protocol/data_pb.rb +833 -482
  17. data/lib/sc2ai/protocol/debug_pb.rb +1112 -401
  18. data/lib/sc2ai/protocol/error_pb.rb +430 -862
  19. data/lib/sc2ai/protocol/extensions/action.rb +1 -1
  20. data/lib/sc2ai/protocol/extensions/color.rb +1 -1
  21. data/lib/sc2ai/protocol/extensions/point.rb +1 -1
  22. data/lib/sc2ai/protocol/extensions/point_2_d.rb +1 -1
  23. data/lib/sc2ai/protocol/extensions/point_distance.rb +4 -4
  24. data/lib/sc2ai/protocol/extensions/position.rb +20 -0
  25. data/lib/sc2ai/protocol/extensions/power_source.rb +1 -1
  26. data/lib/sc2ai/protocol/extensions/unit.rb +1 -1
  27. data/lib/sc2ai/protocol/extensions/unit_type_data.rb +1 -1
  28. data/lib/sc2ai/protocol/query_pb.rb +558 -88
  29. data/lib/sc2ai/protocol/raw_pb.rb +1829 -1156
  30. data/lib/sc2ai/protocol/sc2api_pb.rb +5233 -1463
  31. data/lib/sc2ai/protocol/score_pb.rb +444 -103
  32. data/lib/sc2ai/protocol/spatial_pb.rb +935 -145
  33. data/lib/sc2ai/protocol/ui_pb.rb +1432 -435
  34. data/lib/sc2ai/version.rb +1 -1
  35. data/lib/templates/new/api/data.proto +2 -2
  36. data/lib/templates/new/api/debug.proto +1 -1
  37. data/lib/templates/new/api/raw.proto +6 -6
  38. data/lib/templates/new/api/sc2api.proto +1 -1
  39. data/lib/templates/new/api/ui.proto +1 -1
  40. data/lib/templates/new/run_example_match.rb.tt +1 -1
  41. data/sig/sc2ai.rbs +1361 -23
  42. metadata +7 -7
  43. /data/{lib/docker_build → docker_build}/docker-compose-base-image.yml +0 -0
  44. /data/{lib/docker_build → docker_build}/docker-compose-ladderzip.yml +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0db477a14bdf3d61b9ba5398b2b4e141832db450cabf2ba1b25c3ecbf5936b95
4
- data.tar.gz: f8b7b955443d9233b7a05c4cabedd4cc22540996b841b3896815cb02fd8c22c1
3
+ metadata.gz: 5b421602e2cdff4d59e4b3b4ab168f7d894a43f4474244b229ec72c78d6bf6a9
4
+ data.tar.gz: cbc072cb8a55cacabd0ac751ff5286f582c0145241a98343834f0c0def7c31c1
5
5
  SHA512:
6
- metadata.gz: 8d1bea39be1caff988cea9351abef368eef22d544dfa04551b681d473e5055765fc7c347435e714b3f05fad4649ce38918b2732b04f22f88b08639e22d0ad15b
7
- data.tar.gz: 97457f03348767c490e6386b95919d01fa2bda0859e7c6c957ef96f3f0b00b76d54d82f5725ced238f6a62901b9bfdd27197e2230bb36d9736bb58c10d6a4ba1
6
+ metadata.gz: df8e5f7a8557d0f3dce348cbd9dcdc8ef8f03f88b5f00376d7972b36c223e042ed61123612642189e2722b0a62eb22f7f02a16ca5650864bdd8f3a49ddc86680
7
+ data.tar.gz: d5094e865be75f4b7c31b25a41ff8f021edbb4380567f304a39c1ade99d3155fa408d821c980f2751daf85eddee3f8f9c84a81557255e923db524d9570fad817
@@ -88,8 +88,8 @@ message UnitTypeData {
88
88
  optional bool has_minerals = 20;
89
89
  optional float sight_range = 25; // Range unit reveals vision.
90
90
 
91
- repeated uint32 tech_alias = 21; // Other units that satisfy the same tech requirement.
92
- optional uint32 unit_alias = 22; // The morphed variant of this unit.
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.
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.
@@ -90,7 +90,7 @@ message DebugCreateUnit {
90
90
  }
91
91
 
92
92
  message DebugKillUnit {
93
- repeated uint64 tag = 1;
93
+ repeated uint64 tag = 1 [packed =false];
94
94
  }
95
95
 
96
96
  message DebugTestProcess {
@@ -46,7 +46,7 @@ message PowerSource {
46
46
  message PlayerRaw {
47
47
  repeated PowerSource power_sources = 1;
48
48
  optional Point camera = 2;
49
- repeated uint32 upgrade_ids = 3;
49
+ repeated uint32 upgrade_ids = 3 [packed=false];
50
50
  }
51
51
 
52
52
  message UnitOrder {
@@ -112,7 +112,7 @@ message Unit {
112
112
  optional float radius = 8;
113
113
  optional float build_progress = 9; // Range: [0.0, 1.0]
114
114
  optional CloakState cloak = 10;
115
- repeated uint32 buff_ids = 27;
115
+ repeated uint32 buff_ids = 27 [packed=false];
116
116
 
117
117
  optional float detect_range = 31;
118
118
  optional float radar_range = 32;
@@ -160,7 +160,7 @@ message MapState {
160
160
  }
161
161
 
162
162
  message Event {
163
- repeated uint64 dead_units = 1;
163
+ repeated uint64 dead_units = 1 [packed=false];
164
164
  }
165
165
 
166
166
  message Effect {
@@ -190,8 +190,8 @@ message ActionRawUnitCommand {
190
190
  Point2D target_world_space_pos = 2;
191
191
  uint64 target_unit_tag = 3;
192
192
  }
193
- repeated uint64 unit_tags = 4;
194
- optional bool queue_command = 5;
193
+ repeated uint64 unit_tags = 4 [packed=false];
194
+ optional bool queue_command = 5 [packed=false];
195
195
  }
196
196
 
197
197
  message ActionRawCameraMove {
@@ -200,5 +200,5 @@ message ActionRawCameraMove {
200
200
 
201
201
  message ActionRawToggleAutocast {
202
202
  optional int32 ability_id = 1;
203
- repeated uint64 unit_tags = 2;
203
+ repeated uint64 unit_tags = 2 [packed=false];
204
204
  }
@@ -689,7 +689,7 @@ message ActionObserverCameraFollowPlayer {
689
689
  }
690
690
 
691
691
  message ActionObserverCameraFollowUnits {
692
- repeated uint64 unit_tags = 1;
692
+ repeated uint64 unit_tags = 1 [packed=false];
693
693
  }
694
694
 
695
695
  enum Alert {
@@ -42,7 +42,7 @@ message SinglePanel {
42
42
  optional int32 attack_upgrade_level = 2;
43
43
  optional int32 armor_upgrade_level = 3;
44
44
  optional int32 shield_upgrade_level = 4;
45
- repeated int32 buffs = 5;
45
+ repeated int32 buffs = 5 [packed=false];
46
46
  }
47
47
 
48
48
  message MultiPanel {
@@ -9,7 +9,7 @@ ARG DEBIAN_DISABLE_RUBYGEMS_INTEGRATION=true
9
9
 
10
10
  # Deps - Ruby build
11
11
  RUN apt-get update
12
- RUN apt install --assume-yes rustc curl build-essential libssl-dev zlib1g-dev libgmp-dev uuid-dev
12
+ RUN apt install --assume-yes rustc curl build-essential libssl-dev zlib1g-dev libgmp-dev libffi-dev uuid-dev
13
13
 
14
14
  # Deps - libyaml from source
15
15
  RUN curl https://pyyaml.org/download/libyaml/yaml-0.2.5.tar.gz -o yaml-0.2.5.tar.gz
@@ -65,7 +65,7 @@ RUN /root/ruby-builder/.ruby/bin/bundle config set --global without test develop
65
65
  RUN apt-get update
66
66
  RUN apt-get purge $(aptitude search '~i!~M!~prequired!~pimportant!~R~prequired!~R~R~prequired!~R~pimportant!~R~R~pimportant!busybox!grub!initramfs-tools' | awk '{print $2}') --assume-yes
67
67
  RUN apt-get purge aptitude --assume-yes
68
- RUN apt-get install zip openssl build-essential libopenblas0-serial --assume-yes
68
+ RUN apt-get install zip openssl build-essential libopenblas0-serial libffi-dev --assume-yes
69
69
  RUN apt-get autoremove --assume-yes
70
70
  RUN apt-get clean --assume-yes
71
71
 
@@ -38,7 +38,7 @@ module Sc2
38
38
 
39
39
  def set_compose_file
40
40
  @compose_file = Sc2::Paths.gem_root
41
- .join("lib", "docker_build", "docker-compose-ladderzip.yml")
41
+ .join("docker_build", "docker-compose-ladderzip.yml")
42
42
  .expand_path.to_s
43
43
  end
44
44
 
@@ -67,7 +67,7 @@ module Sc2
67
67
  begin
68
68
  ::Async::Process.spawn(command_string, **options)
69
69
  rescue
70
- Sc2.logger.info("Client exited unexpectedly")
70
+ Sc2.logger.info("Client exited")
71
71
  task&.stop
72
72
  end
73
73
  end
@@ -68,6 +68,7 @@ module Sc2
68
68
  ensure
69
69
  Sc2.logger.debug { "Game over, disconnect players." }
70
70
  # Suppress interrupt errors #$stderr.reopen File.new(File::NULL, "w")
71
+ player.quit if Gem.win_platform?
71
72
  player.disconnect
72
73
  ClientManager.stop(player_index) # unless keep_clients_alive
73
74
  end
@@ -19,9 +19,10 @@ module Async
19
19
  options[:pgroup] = true
20
20
  end
21
21
 
22
- @pid = ::Process.spawn(*args, **options)
22
+
23
23
 
24
24
  @thread = Thread.new do
25
+ @pid = ::Process.spawn(*args, **options)
25
26
  _, @exit_status = ::Process.wait2(@pid)
26
27
  @output.close
27
28
  end
data/lib/sc2ai/paths.rb CHANGED
@@ -280,7 +280,6 @@ module Sc2
280
280
  # Platform-specific patches
281
281
  if platform == PF_WSL1 || platform == PF_WSL2
282
282
  dir = win_to_wsl(path: dir)
283
- raise Pathname(dir).inspect
284
283
  elsif PF_WINDOWS
285
284
  dir = dir.tr("\\", "/")
286
285
  end
@@ -29,7 +29,7 @@ module Sc2
29
29
  draw: Api::DebugDraw.new(
30
30
  text: [
31
31
  Api::DebugText.new(
32
- text:,
32
+ text: text.to_s,
33
33
  size:,
34
34
  virtual_pos: Api::Point.new(x: 0.01, y: 0.01) # unit or fixed position.
35
35
  )
@@ -50,7 +50,7 @@ module Sc2
50
50
  draw: Api::DebugDraw.new(
51
51
  text: [
52
52
  Api::DebugText.new(
53
- text:,
53
+ text: text.to_s,
54
54
  virtual_pos: Api::Point.new(
55
55
  x: left_percent.to_f / 100,
56
56
  y: top_percent.to_f / 100
@@ -74,7 +74,7 @@ module Sc2
74
74
  draw: Api::DebugDraw.new(
75
75
  text: [
76
76
  Api::DebugText.new(
77
- text:,
77
+ text: text.to_s,
78
78
  world_pos: point,
79
79
  color:,
80
80
  size:
data/lib/sc2ai/player.rb CHANGED
@@ -129,6 +129,15 @@ module Sc2
129
129
  @api&.close
130
130
  end
131
131
 
132
+ # @private
133
+ # Note: Do not document, because ladder players should never quit,
134
+ # but rather #leave_game instead
135
+ # Sends quit command to SC2
136
+ # @return [void]
137
+ def quit
138
+ @api&.quit
139
+ end
140
+
132
141
  # @!endgroup Connection
133
142
 
134
143
  # API --------------------