UG_RRobots 1.2 → 1.3
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.
- data/COPYRIGHT.txt +6 -0
- data/RakeFile +29 -0
- data/bin/rrobots +39 -1
- data/lib/battlefield.rb +8 -2
- data/lib/configuration.rb +6 -4
- data/lib/tkarena.rb +2 -7
- metadata +15 -4
data/COPYRIGHT.txt
ADDED
data/RakeFile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require "rake/clean"
|
4
|
+
require "rake/gempackagetask"
|
5
|
+
|
6
|
+
spec = Gem::Specification.new do |s|
|
7
|
+
s.name = "UG_RRobots"
|
8
|
+
s.version = "1.3"
|
9
|
+
s.author = "Simon Kröger, Romain GEORGES"
|
10
|
+
s.email = "dev@ultragreen.net"
|
11
|
+
s.homepage = "http://www.ultragreen.net/projects/rrobots"
|
12
|
+
s.platform = Gem::Platform::RUBY
|
13
|
+
s.summary = "Ultragreen RRobots Fork with new features like toolboxes, config file, gemified"
|
14
|
+
s.files = FileList["{bin,lib,images,config,doc,contribs,robots}/**/*"].to_a.concat(['COPYRIGHT.txt','RakeFile'])
|
15
|
+
s.require_path = "lib"
|
16
|
+
# s.autorequire = "name"
|
17
|
+
# s.test_files = FileList["{test}/**/*test.rb"].to_a
|
18
|
+
s.has_rdoc = true
|
19
|
+
s.extra_rdoc_files = ["doc/manual.rdoc","doc/manual_fr.rdoc"].concat(FileList["bin/*"].to_a)
|
20
|
+
# s.add_dependency("dependency", ">= 0.x.x")
|
21
|
+
s.bindir = 'bin'
|
22
|
+
s.executables = ['rrobots','tournament']
|
23
|
+
s.description = "Ultragreen RRobots Fork"
|
24
|
+
s.rdoc_options << '--title' << 'UG RRobots a RRobots project Fork ' << '--main' << 'doc/manual.rdoc' << '--line-numbers' << '--exclude' << 'robots images' << '--diagram'
|
25
|
+
end
|
26
|
+
|
27
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
28
|
+
pkg.need_tar = true
|
29
|
+
end
|
data/bin/rrobots
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'misc'
|
3
4
|
require 'robot'
|
4
5
|
require 'yaml'
|
5
6
|
require 'overloads'
|
@@ -14,7 +15,9 @@ require 'bullets'
|
|
14
15
|
##############################################
|
15
16
|
|
16
17
|
def usage
|
17
|
-
puts "usage: rrobots
|
18
|
+
puts "usage: rrobots [resolution] [#match] [-nogui] [-speed=<N>] [-timeout=<N>] [-teams=<N>] [-with-toolboxes] <FirstRobotClassName[.rb]> <SecondRobotClassName[.rb]> <...>"
|
19
|
+
puts "Or : rrobots -list-internals"
|
20
|
+
puts "\t[-list-internals] (exclusive) give the list of avaibles internals Robots"
|
18
21
|
puts "\t[resolution] (optional) should be of the form 640x480 or 800*600. default is 800x800"
|
19
22
|
puts "\t[match] (optional) to replay a match, put the match# here, including the #sign. "
|
20
23
|
puts "\t[-nogui] (optional) run the match without the gui, for highest possible speed.(ignores speed value if present)"
|
@@ -94,8 +97,37 @@ def print_outcome(battlefield)
|
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
def hash_internals
|
104
|
+
my_res = Hash::new
|
105
|
+
robots_path = gem_path('robots')
|
106
|
+
Dir["#{robots_path}/*.rb"].each {|file|
|
107
|
+
robots = File.basename(file, ".rb")
|
108
|
+
my_res[robots] = file
|
109
|
+
}
|
110
|
+
return my_res
|
111
|
+
end
|
112
|
+
|
113
|
+
def list_internals
|
114
|
+
title = "List of avaibles internals robots :"
|
115
|
+
puts title
|
116
|
+
puts "-"*title.size
|
117
|
+
hash_internals.each do |key,value|
|
118
|
+
puts " - #{key}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
97
123
|
$stdout.sync = true
|
98
124
|
|
125
|
+
# look for query for robots internal list
|
126
|
+
ARGV.grep(/^(-list-internals)/) do |item|
|
127
|
+
list_internals
|
128
|
+
exit 0
|
129
|
+
end
|
130
|
+
|
99
131
|
# look for resolution arg
|
100
132
|
xres, yres = 800, 800
|
101
133
|
ARGV.grep(/^(\d+)[x\*](\d+$)/) do |item|
|
@@ -171,6 +203,8 @@ battlefield = Battlefield.new xres*2, yres*2, timeout, seed, with_toolboxes, mer
|
|
171
203
|
|
172
204
|
c = 0
|
173
205
|
team_divider = (ARGV.size / teams.size.to_f).ceil
|
206
|
+
|
207
|
+
|
174
208
|
ARGV.map! do |robot|
|
175
209
|
begin
|
176
210
|
begin
|
@@ -180,6 +214,10 @@ ARGV.map! do |robot|
|
|
180
214
|
begin
|
181
215
|
require robot
|
182
216
|
rescue LoadError
|
217
|
+
end
|
218
|
+
begin
|
219
|
+
require hash_internals[robot]
|
220
|
+
rescue LoadError
|
183
221
|
end
|
184
222
|
in_game_name = File.basename(robot).sub(/\..*$/, '')
|
185
223
|
in_game_name[0] = in_game_name[0,1].upcase
|
data/lib/battlefield.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
class Battlefield
|
2
3
|
attr_reader :width
|
3
4
|
attr_reader :height
|
@@ -15,14 +16,19 @@ class Battlefield
|
|
15
16
|
attr_reader :config
|
16
17
|
|
17
18
|
def initialize width, height, timeout, seed, with_toolboxes, merge, write_config
|
19
|
+
filename = "rrobots.yml"
|
18
20
|
@config = Configuration::new
|
19
|
-
|
20
|
-
|
21
|
+
@path_prefix = gem_path('config')
|
22
|
+
config_sources = [@path_prefix]
|
23
|
+
config_sources.push "." if merge and File::exist?('./rrobots.yml')
|
24
|
+
config_sources.each do |filepath|
|
25
|
+
file = YAML::load(File.open("#{filepath}/#{filename}"))
|
21
26
|
file.extend(Configuration_accessors)
|
22
27
|
[:game, :toolboxes, :robots, :bullets, :battlefield].each do |accessor|
|
23
28
|
@config.send(accessor).merge(file.send(accessor))
|
24
29
|
end
|
25
30
|
end
|
31
|
+
|
26
32
|
@config.write_config if write_config
|
27
33
|
@width = (width != self.config.battlefield[:width]) ? width : self.config.battlefield[:width]
|
28
34
|
@height = (height != self.config.battlefield[:height]) ? height : self.config.battlefield[:height]
|
data/lib/configuration.rb
CHANGED
@@ -10,12 +10,14 @@ class Configuration
|
|
10
10
|
|
11
11
|
include Configuration_accessors
|
12
12
|
|
13
|
-
def write_config
|
14
|
-
|
15
|
-
File.
|
13
|
+
def write_config(path='.')
|
14
|
+
filepath = "#{path}/#{@filename}"
|
15
|
+
File.unlink(filepath) if File::exist?(filepath)
|
16
|
+
File.open(filepath, 'w') { |f| f.puts self.to_yaml }
|
16
17
|
end
|
17
18
|
|
18
|
-
def initialize
|
19
|
+
def initialize(filename="rrobots.yml")
|
20
|
+
@filename = filename
|
19
21
|
@game = { :timeout => 50000 }
|
20
22
|
@toolboxes = { :with_toolboxes => false, :life_time => 200, :spawning_chances => 100, :energy_heal_points => 20 }
|
21
23
|
@robots = { :energy_max => 100 }
|
data/lib/tkarena.rb
CHANGED
@@ -16,13 +16,8 @@ class TkArena
|
|
16
16
|
@speed_multiplier = speed_multiplier
|
17
17
|
@text_colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#00ffff', '#ff00ff', '#ffffff', '#777777']
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
table_map = Gem.location_of_caller.first.split('/')
|
22
|
-
2.times do
|
23
|
-
table_map.pop
|
24
|
-
end
|
25
|
-
@path_prefix = table_map.join('/')
|
19
|
+
|
20
|
+
@path_prefix = gem_path
|
26
21
|
|
27
22
|
@default_skin_prefix = "images/red_"
|
28
23
|
@on_game_over_handlers = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: UG_RRobots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Simon Kr\xC3\xB6ger, Romain GEORGES"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-16 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,6 +23,8 @@ extensions: []
|
|
23
23
|
extra_rdoc_files:
|
24
24
|
- doc/manual.rdoc
|
25
25
|
- doc/manual_fr.rdoc
|
26
|
+
- bin/rrobots
|
27
|
+
- bin/tournament
|
26
28
|
files:
|
27
29
|
- bin/rrobots
|
28
30
|
- bin/tournament
|
@@ -188,13 +190,22 @@ files:
|
|
188
190
|
- robots/SittingDuck.rb
|
189
191
|
- robots/SniperDuck.rb
|
190
192
|
- robots/WallPainter.rb
|
193
|
+
- COPYRIGHT.txt
|
194
|
+
- RakeFile
|
191
195
|
has_rdoc: true
|
192
196
|
homepage: http://www.ultragreen.net/projects/rrobots
|
193
197
|
licenses: []
|
194
198
|
|
195
199
|
post_install_message:
|
196
|
-
rdoc_options:
|
197
|
-
|
200
|
+
rdoc_options:
|
201
|
+
- --title
|
202
|
+
- "UG RRobots a RRobots project Fork "
|
203
|
+
- --main
|
204
|
+
- doc/manual.rdoc
|
205
|
+
- --line-numbers
|
206
|
+
- --exclude
|
207
|
+
- robots images
|
208
|
+
- --diagram
|
198
209
|
require_paths:
|
199
210
|
- lib
|
200
211
|
required_ruby_version: !ruby/object:Gem::Requirement
|