sc2ai 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2012,11 +2012,63 @@ module Api
2012
2012
  MINERALFIELD450 = 1996
2013
2013
  MINERALFIELDOPAQUE = 1997
2014
2014
  MINERALFIELDOPAQUE900 = 1998
2015
- COLLAPSIBLEROCKTOWERDEBRISRAMPLEFTGREEN = 1999
2016
- COLLAPSIBLEROCKTOWERDEBRISRAMPRIGHTGREEN = 2000
2017
- COLLAPSIBLEROCKTOWERPUSHUNITRAMPLEFTGREEN = 2001
2018
- COLLAPSIBLEROCKTOWERPUSHUNITRAMPRIGHTGREEN = 2002
2019
- COLLAPSIBLEROCKTOWERRAMPLEFTGREEN = 2003
2020
- COLLAPSIBLEROCKTOWERRAMPRIGHTGREEN = 2004
2015
+ MECHAZERGLINGACGLUESCREENDUMMY_2 = 1999
2016
+ MECHABANELINGACGLUESCREENDUMMY_2 = 2000
2017
+ MECHAHYDRALISKACGLUESCREENDUMMY_2 = 2001
2018
+ MECHAINFESTORACGLUESCREENDUMMY_2 = 2002
2019
+ MECHACORRUPTORACGLUESCREENDUMMY_2 = 2003
2020
+ MECHAULTRALISKACGLUESCREENDUMMY_2 = 2004
2021
+ MECHAOVERSEERACGLUESCREENDUMMY_2 = 2005
2022
+ MECHALURKERACGLUESCREENDUMMY_2 = 2006
2023
+ MECHABATTLECARRIERLORDACGLUESCREENDUMMY_2 = 2007
2024
+ MECHASPINECRAWLERACGLUESCREENDUMMY_2 = 2008
2025
+ MECHASPORECRAWLERACGLUESCREENDUMMY_2 = 2009
2026
+ TROOPERMENGSKACGLUESCREENDUMMY_2 = 2010
2027
+ MEDIVACMENGSKACGLUESCREENDUMMY_2 = 2011
2028
+ BLIMPMENGSKACGLUESCREENDUMMY_2 = 2012
2029
+ MARAUDERMENGSKACGLUESCREENDUMMY_2 = 2013
2030
+ GHOSTMENGSKACGLUESCREENDUMMY_2 = 2014
2031
+ SIEGETANKMENGSKACGLUESCREENDUMMY_2 = 2015
2032
+ THORMENGSKACGLUESCREENDUMMY_2 = 2016
2033
+ VIKINGMENGSKACGLUESCREENDUMMY_2 = 2017
2034
+ BATTLECRUISERMENGSKACGLUESCREENDUMMY_2 = 2018
2035
+ BUNKERDEPOTMENGSKACGLUESCREENDUMMY_2 = 2019
2036
+ MISSILETURRETMENGSKACGLUESCREENDUMMY_2 = 2020
2037
+ ARTILLERYMENGSKACGLUESCREENDUMMY_2 = 2021
2038
+ LOADOUTSPRAY1_2 = 2022
2039
+ LOADOUTSPRAY2_2 = 2023
2040
+ LOADOUTSPRAY3_2 = 2024
2041
+ LOADOUTSPRAY4_2 = 2025
2042
+ LOADOUTSPRAY5_2 = 2026
2043
+ LOADOUTSPRAY6_2 = 2027
2044
+ LOADOUTSPRAY7_2 = 2028
2045
+ LOADOUTSPRAY8_2 = 2029
2046
+ LOADOUTSPRAY9_2 = 2030
2047
+ LOADOUTSPRAY10_2 = 2031
2048
+ LOADOUTSPRAY11_2 = 2032
2049
+ LOADOUTSPRAY12_2 = 2033
2050
+ LOADOUTSPRAY13_2 = 2034
2051
+ LOADOUTSPRAY14_2 = 2035
2052
+ COLLAPSIBLEROCKTOWERDEBRISRAMPLEFTGREEN = 2036
2053
+ COLLAPSIBLEROCKTOWERDEBRISRAMPRIGHTGREEN = 2037
2054
+ COLLAPSIBLEROCKTOWERPUSHUNITRAMPLEFTGREEN = 2038
2055
+ COLLAPSIBLEROCKTOWERPUSHUNITRAMPRIGHTGREEN = 2039
2056
+ COLLAPSIBLEROCKTOWERRAMPLEFTGREEN = 2040
2057
+ COLLAPSIBLEROCKTOWERRAMPRIGHTGREEN = 2041
2058
+ DUMMYUNIT000 = 2042
2059
+ DUMMYUNIT001 = 2043
2060
+ DUMMYUNIT002 = 2044
2061
+ DUMMYUNIT003 = 2045
2062
+ DUMMYUNIT004 = 2046
2063
+ DUMMYUNIT005 = 2047
2064
+ DUMMYUNIT006 = 2048
2065
+ DUMMYUNIT007 = 2049
2066
+ DUMMYUNIT008 = 2050
2067
+ DUMMYUNIT009 = 2051
2068
+ DUMMYUNIT010 = 2052
2069
+ DUMMYUNIT011 = 2053
2070
+ DUMMYUNIT012 = 2054
2071
+ DUMMYUNIT013 = 2055
2072
+ DUMMYUNIT014 = 2056
2021
2073
  end
2022
2074
  end
@@ -306,5 +306,7 @@ module Api
306
306
  PSIONICAMPLIFIERS = 300
307
307
  SECRETEDCOATING = 301
308
308
  ENHANCEDSHOCKWAVES = 302
309
+ HURRICANETHRUSTERS = 303
310
+ INTERFERENCEMATRIX = 304
309
311
  end
310
312
  end
data/lib/sc2ai/cli/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "thor"
2
+
2
3
  require "sc2ai/cli/new"
3
4
  require "sc2ai/cli/ladderzip"
4
5
 
@@ -20,36 +21,36 @@ module Sc2
20
21
  desc "setup410", "Downloads and install SC2 v4.10"
21
22
  # downloads and install SC2 v4.10
22
23
  def setup410
23
- puts " "
24
- puts "This script sets up SC2 at version 4.10, which we use competitively."
25
- puts "Press any key to continue..."
26
- puts " "
27
- $stdin.getch
28
-
29
- puts "You must accept the Blizzard® Starcraft® II AI and Machine Learning License at"
30
- puts "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html"
31
- puts "It is PERMISSIVE and grants you freedoms over the standard EULA."
32
- puts "We do not record this action, but depend on software goverend by that license to continue."
24
+ say " "
25
+ say "This script sets up SC2 at version 4.10, which we use competitively."
26
+ say "Press any key to continue..."
27
+ ask ""
28
+
29
+ say "You must accept the Blizzard® Starcraft® II AI and Machine Learning License at"
30
+ say "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html"
31
+ say "It is PERMISSIVE and grants you freedoms over the standard EULA."
32
+ say "We do not record this action, but depend on software goverend by that license to continue."
33
33
  puts 'If you accept, type "iagreetotheeula" (without quotes) and press ENTER to continue:'
34
34
 
35
35
  while $stdin.gets.chomp != "iagreetotheeula"
36
- puts ""
36
+ say ""
37
37
  puts 'Type "iagreetotheeula" (without quotes) and press ENTER to continue:'
38
38
  end
39
- puts ""
40
- puts ""
41
- puts "Great decision."
39
+ say ""
40
+ say ""
41
+ say "Great decision."
42
42
 
43
+ require "sc2ai"
43
44
  Async do
44
45
  Sc2.logger.level = :fatal
45
- puts "SC2 will launch a blank window, be unresponsive, but download about 100mb in the background."
46
- puts "Let it finish and close itself."
47
- puts "Press ENTER if you understand."
48
- $stdin.getch
46
+ say "SC2 will launch a blank window, be unresponsive, but download about 100mb in the background."
47
+ say "Let it finish and close itself."
48
+ say "Press ENTER if you understand."
49
+ ask ""
49
50
 
50
- puts ""
51
- puts ""
52
- puts "This will only take a minute..."
51
+ say ""
52
+ say ""
53
+ say "This will only take a minute..."
53
54
 
54
55
  Sc2.config.version = nil
55
56
  client = Sc2::ClientManager.obtain(0)
@@ -68,22 +69,23 @@ module Sc2
68
69
  base_build = "75689"
69
70
  path = Sc2::Paths.executable(base_build: base_build)
70
71
  if path.include?(base_build) && Pathname(path).exist?
71
- puts " "
72
- puts "Success. Downloaded complete."
73
- puts " "
72
+ say " "
73
+ say "Success. Download complete.", :green
74
+ say " "
74
75
  else
75
- puts "Error. Slightly worrying, but no fear."
76
- puts "To manually setup, grab the latest ladder maps and add them to your map folder."
77
- puts "Grab the latest maps from https://aiarena.net/wiki/maps/"
78
- puts "Detected map folder: #{Sc2::Paths.maps_dir}"
79
- puts "Then, download any recent replay from https://aiarena.net/ and double click to launch"
76
+ say "Error. Slightly worrying, but no fear.", :red
77
+ say "To manually setup, grab the latest ladder maps and add them to your map folder."
78
+ say "Grab the latest maps from https://aiarena.net/wiki/maps/"
79
+ say "Detected map folder: #{Sc2::Paths.maps_dir}"
80
+ say "Then, download any recent replay from https://aiarena.net/ and double click to launch"
80
81
  end
81
82
 
83
+ observer.api.quit
82
84
  observer.disconnect
83
- puts "Generating sc2ai.yml to always use 4.10..."
85
+ say "Generating sc2ai.yml to always use 4.10..."
84
86
  Sc2.config.config_file.write({"version" => "4.10"}.to_yaml.to_s)
85
- puts ""
86
- puts "Done. You're good to go."
87
+ say ""
88
+ say "Done. You're good to go.", :green
87
89
  ensure
88
90
  Sc2::ClientManager.stop(0)
89
91
  end
@@ -133,7 +135,7 @@ module Sc2
133
135
  option :RealTime, type: :boolean, default: false, desc: "Forces realtime flag"
134
136
  def laddermatch
135
137
  require "sc2ai"
136
-
138
+
137
139
  unless Sc2.ladder?
138
140
  raise Sc2::Error, "This command is only for competing on aiarena.net"
139
141
  end
@@ -18,11 +18,21 @@ module Sc2
18
18
  desc "Builds a ladder zip using docker (requires docker)"
19
19
 
20
20
  def docker_exists
21
- if Kernel.system("docker --version")
21
+ if Kernel.system("docker --version", out: File::NULL, err: File::NULL)
22
22
  say_status("docker", "found", :green)
23
23
  else
24
24
  say_status("docker", "not found", :red)
25
25
  say("Please install 'docker' and/or ensure it's in your PATH to continue.")
26
+ raise SystemExit
27
+ end
28
+
29
+ if Kernel.system("docker info", out: File::NULL, err: File::NULL)
30
+ say_status("docker engine", "found", :green)
31
+ else
32
+ say(" ")
33
+ say_status("docker engine", "offline", :red)
34
+ say("Please start docker engine. If you have Docker Desktop installed, open it before retrying.")
35
+ raise SystemExit
26
36
  end
27
37
  end
28
38
 
@@ -64,7 +74,8 @@ module Sc2
64
74
 
65
75
  def create_executable
66
76
  template("ladderzip/bin/ladder", "./.build/bin/ladder")
67
- create_link(".build/#{botname}", "./bin/ladder")
77
+ # This fails on Windows. creating by hand in #link_ladder function below.
78
+ # create_link("./.build/#{botname}", "./bin/ladder")
68
79
  end
69
80
 
70
81
  def start_container
@@ -86,9 +97,11 @@ module Sc2
86
97
  include_pattern.collect! { |pt| pt.delete_prefix("!") }
87
98
 
88
99
  files = Dir.glob("**/*")
100
+
89
101
  ignored_files = files
90
102
  .select { |f| ignore_pattern.any? { |p| File.fnmatch?(p, f) } }
91
- .reject! { |f| include_pattern.any? { |p| File.fnmatch?(p, f) } }
103
+ .reject { |f| include_pattern.any? { |p| File.fnmatch?(p, f) } }
104
+
92
105
  files -= ignored_files unless ignored_files.nil?
93
106
 
94
107
  files.each do |file|
@@ -103,6 +116,12 @@ module Sc2
103
116
  Kernel.system(cmd)
104
117
  end
105
118
 
119
+ def link_ladder
120
+ say_status("docker", "linking executable...", :cyan)
121
+ cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot ln -s ./bin/ladder ./#{botname}"
122
+ Kernel.system(cmd)
123
+ end
124
+
106
125
  def install_gems
107
126
  say_status("docker", "bundle install...", :cyan)
108
127
  cmd = "docker compose -f #{@compose_file} exec --workdir /root/ruby-builder bot bundle install"
@@ -202,7 +202,7 @@ module Sc2
202
202
  # @param y [Float, Integer]
203
203
  # @return [Boolean] true if location is powered
204
204
  def powered?(x:, y:)
205
- parsed_creep[y.to_i, x.to_i] != 0
205
+ parsed_power_grid[y.to_i, x.to_i] != 0
206
206
  end
207
207
 
208
208
  # Returns whether a x/y block is pathable as per minimap
data/lib/sc2ai/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Sc2
4
4
  # gem version
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sc2ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dyson Returns
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-07 00:00:00.000000000 Z
11
+ date: 2024-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: webrick
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.8'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1.8'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: standard
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -292,7 +306,7 @@ dependencies:
292
306
  version: '0.22'
293
307
  description: This is a Ruby interface to STARCRAFT® II. It can be used for machine
294
308
  learning via Rumale or custom scripted AI battle.
295
- email:
309
+ email:
296
310
  executables:
297
311
  - sc2ai
298
312
  extensions: []
@@ -389,7 +403,6 @@ files:
389
403
  - lib/templates/new/boot.rb.tt
390
404
  - lib/templates/new/my_bot.rb.tt
391
405
  - lib/templates/new/run_example_match.rb.tt
392
- - sc2ai.gemspec
393
406
  homepage: https://www.github.com/dysonreturns/sc2ai
394
407
  licenses:
395
408
  - MIT
@@ -397,7 +410,7 @@ licenses:
397
410
  metadata:
398
411
  homepage_uri: https://www.github.com/dysonreturns/sc2ai
399
412
  changelog_uri: https://www.github.com/dysonreturns/sc2ai/blob/main/docs/CHANGELOG.md
400
- post_install_message:
413
+ post_install_message:
401
414
  rdoc_options: []
402
415
  require_paths:
403
416
  - lib
@@ -413,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
413
426
  version: '0'
414
427
  requirements: []
415
428
  rubygems_version: 3.5.3
416
- signing_key:
429
+ signing_key:
417
430
  specification_version: 4
418
431
  summary: STARCRAFT® II AI API
419
432
  test_files: []
data/sc2ai.gemspec DELETED
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.expand_path("./lib"))
4
- require_relative "lib/sc2ai/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "sc2ai"
8
- spec.version = Sc2::VERSION
9
- spec.authors = ["Dyson Returns"]
10
-
11
- spec.summary = "STARCRAFT® II AI API"
12
- spec.description = "This is a Ruby interface to STARCRAFT® II. It can be used for machine learning via Rumale or custom scripted AI battle."
13
- spec.homepage = "https://www.github.com/dysonreturns/sc2ai"
14
- spec.licenses = ["MIT", "Nonstandard"]
15
- spec.required_ruby_version = ">= 3.2.2"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- # spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/docs/CHANGELOG.md"
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(__dir__) do
24
- `git ls-files -z`.split("\x0").select do |f|
25
- (File.expand_path(f) == __FILE__) ||
26
- %r{\A(?:lib|data|exe)/}.match?(f)
27
- end
28
- end
29
-
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
33
-
34
- # Live dependencies ---
35
- spec.add_dependency "async", "2.6.5"
36
- # Sc2::Connection
37
- spec.add_dependency "async-websocket", "0.26.0"
38
- spec.add_dependency "google-protobuf", "3.25.1"
39
- # Sc2::Client / Controller
40
- spec.add_dependency "async-process", "1.3.1"
41
- # Cli
42
- spec.add_dependency "thor", "1.3.0"
43
-
44
- # Geometry
45
- spec.add_dependency "perfect-shape", "1.0.8"
46
-
47
- spec.add_dependency "numo-narray", "0.9.2.1"
48
- spec.add_dependency "numo-linalg", "0.1.7"
49
- spec.add_dependency "rumale", "0.28.1"
50
-
51
- # TODO: Find a way to not depend on a patched gem and yank this
52
- spec.add_dependency "sc2ai-kdtree", "~> 0.4"
53
-
54
- # Pre-packaged ladder dependencies
55
- # We add these locally, so that authors know what to use
56
- # spec.add_dependency "activerecord", "7.1.2"
57
- # spec.add_dependency "sqlite3", "1.7.0"
58
- # spec.add_dependency "rb_sys", "0.9.85"
59
- # spec.add_dependency "concurrent-ruby", "1.2.2"
60
- # spec.add_dependency "parallel", "1.24.0"
61
-
62
- # Dev dependencies ---
63
- spec.add_development_dependency "rake", "~> 13.1"
64
- # Doc
65
- spec.add_development_dependency "yard", "~> 0.9"
66
- # Linting
67
- # spec.add_development_dependency "fasterer" # no 3.3 support yet
68
- spec.add_development_dependency "standard", "~> 1.33"
69
-
70
- # Profiling
71
- spec.add_development_dependency "memory_profiler", "~> 1.0"
72
- spec.add_development_dependency "benchmark", "~> 0.3"
73
- spec.add_development_dependency "benchmark-ips", "~> 2.13"
74
-
75
- # Testing
76
- spec.add_development_dependency "factory_bot", "~> 6.4"
77
- spec.add_development_dependency "fakefs", "~> 2.5"
78
- spec.add_development_dependency "rspec", "~> 3.12"
79
- spec.add_development_dependency "simplecov", "~> 0.22"
80
- end