UG_RRobots 1.3 → 2.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.
- data/{RakeFile → Rakefile} +4 -4
- data/bin/rrobots +83 -23
- data/bin/tournament +78 -10
- data/config/locales/en.yml +17 -0
- data/config/locales/fr.yml +14 -0
- data/config/rrobots.yml +9 -2
- data/doc/install.rdoc +85 -0
- data/doc/install_fr.rdoc +86 -0
- data/doc/manual.rdoc +11 -45
- data/doc/manual_fr.rdoc +10 -45
- data/doc/usage.rdoc +56 -0
- data/doc/usage_fr.rdoc +63 -0
- data/lib/battlefield.rb +19 -6
- data/lib/bullets.rb +11 -0
- data/lib/configuration.rb +3 -1
- data/lib/misc.rb +29 -0
- data/lib/overloads.rb +25 -1
- data/lib/robot.rb +24 -2
- data/lib/robotrunner.rb +71 -3
- data/lib/tkarena.rb +17 -15
- data/robots/Killer.rb +1 -1
- data/robots/MsgBot.rb +12 -4
- data/robots/SittingDuck.rb +1 -0
- metadata +24 -4
data/{RakeFile → Rakefile}
RENAMED
@@ -5,19 +5,19 @@ require "rake/gempackagetask"
|
|
5
5
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = "UG_RRobots"
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0"
|
9
9
|
s.author = "Simon Kröger, Romain GEORGES"
|
10
10
|
s.email = "dev@ultragreen.net"
|
11
11
|
s.homepage = "http://www.ultragreen.net/projects/rrobots"
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
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','
|
14
|
+
s.files = FileList["{bin,lib,images,config,doc,contribs,robots}/**/*"].to_a.concat(['COPYRIGHT.txt','Rakefile'])
|
15
15
|
s.require_path = "lib"
|
16
16
|
# s.autorequire = "name"
|
17
17
|
# s.test_files = FileList["{test}/**/*test.rb"].to_a
|
18
18
|
s.has_rdoc = true
|
19
|
-
s.extra_rdoc_files = ["doc
|
20
|
-
|
19
|
+
s.extra_rdoc_files = FileList["doc/*"].to_a.concat(FileList["bin/*"].to_a)
|
20
|
+
s.add_dependency("i18n", ">= 0.2.1")
|
21
21
|
s.bindir = 'bin'
|
22
22
|
s.executables = ['rrobots','tournament']
|
23
23
|
s.description = "Ultragreen RRobots Fork"
|
data/bin/rrobots
CHANGED
@@ -1,41 +1,61 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
#== Synopsis
|
3
|
+
#
|
4
|
+
# rrobots : AI Ruby Scripts based Robots simulation game
|
5
|
+
#
|
6
|
+
#== Date
|
7
|
+
#
|
8
|
+
# 2009-11-27
|
9
|
+
#
|
10
|
+
#== Copyright
|
11
|
+
#
|
12
|
+
#
|
13
|
+
# Ultragreen (c) 2005-2008 : Romain GEORGES UG RRobots
|
14
|
+
# Fork du projet RRobots
|
15
|
+
# Historical (c) Simon Kröger
|
16
|
+
# Ruby license (http://www.ruby-lang.org/en/LICENSE.txt).
|
17
|
+
#
|
18
|
+
#* Version : 2.0
|
19
|
+
#
|
20
|
+
#== About :
|
21
|
+
#
|
22
|
+
#* Author:: Simon Kröger, Romain GEORGES
|
23
|
+
#* type:: robots AI Game (need TK)
|
24
|
+
#* obj:: command
|
25
|
+
#
|
26
|
+
#== Source :
|
27
|
+
#
|
28
|
+
#* http://www.ultragreen.net/projects/rrobots
|
29
|
+
#
|
30
|
+
|
31
|
+
require 'I18n'
|
32
|
+
|
33
|
+
require 'rdoc/usage'
|
3
34
|
require 'misc'
|
4
35
|
require 'robot'
|
5
36
|
require 'yaml'
|
6
37
|
require 'overloads'
|
7
38
|
require 'configuration'
|
8
39
|
require 'battlefield'
|
9
|
-
|
10
|
-
|
11
|
-
|
40
|
+
|
41
|
+
|
42
|
+
init_I18n get_locale_from_env
|
12
43
|
|
13
44
|
##############################################
|
14
45
|
# arena
|
15
46
|
##############################################
|
16
47
|
|
17
48
|
def usage
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
puts "\t[match] (optional) to replay a match, put the match# here, including the #sign. "
|
23
|
-
puts "\t[-nogui] (optional) run the match without the gui, for highest possible speed.(ignores speed value if present)"
|
24
|
-
puts "\t[-speed=<N>] (optional, defaults to 1) updates GUI after every N ticks. The higher the N, the faster the match will play."
|
25
|
-
puts "\t[-timeout=<N>] (optional, default 50000) number of ticks a match will last at most."
|
26
|
-
puts "\t[-teams=<N>] (optional) split robots into N teams. Match ends when only one team has robots left."
|
27
|
-
puts "\t[-with-toolboxes] (optional) to accept the spawning of healing toolboxes (randomly)."
|
28
|
-
puts "\t[-ignore-config] (optional) to ignore the config file present in the path."
|
29
|
-
puts "\t[-write-config] (optional) to write the config in a file in the path."
|
30
|
-
puts "\tthe names of the rb files have to match the class names of the robots"
|
31
|
-
puts "\t(up to 8 robots)"
|
32
|
-
puts "\te.g. 'ruby rrobots.rb SittingDuck NervousDuck'"
|
33
|
-
puts "\t or 'ruby rrobots.rb 600x600 #1234567890 SittingDuck NervousDuck'"
|
49
|
+
usage_file = "usage.rdoc"
|
50
|
+
usage_file = "usage_#{I18n.locale}.rdoc" if I18n.locale != 'en'
|
51
|
+
doc = "#{gem_path('doc')}/#{usage_file}"
|
52
|
+
RDoc.file_no_exit(doc,"rrobots")
|
34
53
|
exit
|
35
54
|
end
|
36
55
|
|
37
56
|
def run_out_of_gui(battlefield)
|
38
|
-
$stderr.puts '
|
57
|
+
$stderr.puts I18n.t('rrobots.match_limit_warning')
|
58
|
+
|
39
59
|
|
40
60
|
until battlefield.game_over
|
41
61
|
battlefield.tick
|
@@ -94,6 +114,9 @@ def print_outcome(battlefield)
|
|
94
114
|
end
|
95
115
|
puts " kills: #{robot.kills}"
|
96
116
|
puts " toolboxes catched: #{robot.catched_toolboxes}" if battlefield.with_toolboxes
|
117
|
+
puts " dropped mines: #{robot.dropped_mines}" if battlefield.with_mines
|
118
|
+
puts " trigged mines: #{robot.trigged_mines}" if battlefield.with_mines
|
119
|
+
puts " destroyed mines: #{robot.destroyed_mines}" if battlefield.with_mines
|
97
120
|
end
|
98
121
|
end
|
99
122
|
|
@@ -111,7 +134,7 @@ def hash_internals
|
|
111
134
|
end
|
112
135
|
|
113
136
|
def list_internals
|
114
|
-
title =
|
137
|
+
title = I18n.t('rrobots.list_internals_title')
|
115
138
|
puts title
|
116
139
|
puts "-"*title.size
|
117
140
|
hash_internals.each do |key,value|
|
@@ -119,15 +142,45 @@ def list_internals
|
|
119
142
|
end
|
120
143
|
end
|
121
144
|
|
145
|
+
def list_locales
|
146
|
+
title = I18n.t('rrobots.list_locales_title')
|
147
|
+
puts title
|
148
|
+
puts "-"*title.size
|
149
|
+
I18n.backend.available_locales.each do |value|
|
150
|
+
puts " - #{value}"
|
151
|
+
end
|
152
|
+
end
|
122
153
|
|
123
154
|
$stdout.sync = true
|
124
155
|
|
156
|
+
|
157
|
+
ARGV.grep( /^-set-locale=(\w{2})/ )do |item|
|
158
|
+
x = $1.to_s
|
159
|
+
I18n.locale=x
|
160
|
+
ARGV.delete(item)
|
161
|
+
end
|
162
|
+
|
125
163
|
# look for query for robots internal list
|
126
164
|
ARGV.grep(/^(-list-internals)/) do |item|
|
127
165
|
list_internals
|
128
166
|
exit 0
|
129
167
|
end
|
130
168
|
|
169
|
+
# look for query for robots internal list
|
170
|
+
ARGV.grep(/^(-manual)/) do |item|
|
171
|
+
manual_file = "manual.rdoc"
|
172
|
+
manual_file = "manual_#{I18n.locale}.rdoc" if I18n.locale != 'en'
|
173
|
+
doc = "#{gem_path('doc')}/#{manual_file}"
|
174
|
+
RDoc.file_no_exit(doc)
|
175
|
+
exit 0
|
176
|
+
end
|
177
|
+
|
178
|
+
# look for query for locales avaible list
|
179
|
+
ARGV.grep(/^(-list-locales)/) do |item|
|
180
|
+
list_locales
|
181
|
+
exit 0
|
182
|
+
end
|
183
|
+
|
131
184
|
# look for resolution arg
|
132
185
|
xres, yres = 800, 800
|
133
186
|
ARGV.grep(/^(\d+)[x\*](\d+$)/) do |item|
|
@@ -149,6 +202,12 @@ with_toolboxes = true
|
|
149
202
|
ARGV.delete(item)
|
150
203
|
end
|
151
204
|
|
205
|
+
#look for with_toolboxes arg
|
206
|
+
with_mines = false
|
207
|
+
ARGV.grep( /^(-with-mines)/ ) do |item|
|
208
|
+
with_mines = true
|
209
|
+
ARGV.delete(item)
|
210
|
+
end
|
152
211
|
|
153
212
|
#look for mode arg
|
154
213
|
mode = :run_in_gui
|
@@ -179,6 +238,7 @@ ARGV.grep( /^-speed=(\d\d?)/ )do |item|
|
|
179
238
|
ARGV.delete(item)
|
180
239
|
end
|
181
240
|
|
241
|
+
|
182
242
|
#look for timeout arg
|
183
243
|
timeout = 50000
|
184
244
|
ARGV.grep( /^-timeout=(\d+)/ )do |item|
|
@@ -199,7 +259,7 @@ teams = Array.new([team_count, ARGV.size].min){ [] }
|
|
199
259
|
|
200
260
|
usage if ARGV.size > 8 || ARGV.empty?
|
201
261
|
|
202
|
-
battlefield = Battlefield.new xres*2, yres*2, timeout, seed, with_toolboxes, merge, write_config
|
262
|
+
battlefield = Battlefield.new xres*2, yres*2, timeout, seed, with_toolboxes, with_mines, merge, write_config
|
203
263
|
|
204
264
|
c = 0
|
205
265
|
team_divider = (ARGV.size / teams.size.to_f).ceil
|
data/bin/tournament
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "yaml"
|
4
|
+
require 'I18n'
|
5
|
+
require 'rdoc/usage'
|
6
|
+
require 'misc'
|
7
|
+
require 'overloads'
|
8
|
+
|
9
|
+
init_I18n get_locale_from_env
|
4
10
|
|
5
11
|
class Match
|
6
12
|
attr_reader :bots
|
@@ -286,15 +292,69 @@ end
|
|
286
292
|
####################################################################
|
287
293
|
|
288
294
|
def usage
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
295
|
+
usage_file = "usage.rdoc"
|
296
|
+
usage_file = "usage_#{I18n.locale}.rdoc" if I18n.locale != 'en'
|
297
|
+
doc = "#{gem_path('doc')}/#{usage_file}"
|
298
|
+
RDoc.file_no_exit(doc,"tournament")
|
299
|
+
exit
|
300
|
+
end
|
301
|
+
|
302
|
+
def hash_internals
|
303
|
+
my_res = Hash::new
|
304
|
+
robots_path = gem_path('robots')
|
305
|
+
Dir["#{robots_path}/*.rb"].each {|file|
|
306
|
+
robots = File.basename(file, ".rb")
|
307
|
+
my_res[robots] = file
|
308
|
+
}
|
309
|
+
return my_res
|
310
|
+
end
|
311
|
+
|
312
|
+
def list_internals
|
313
|
+
title = I18n.t('rrobots.list_internals_title')
|
314
|
+
puts title
|
315
|
+
puts "-"*title.size
|
316
|
+
hash_internals.each do |key,value|
|
317
|
+
puts " - #{key}"
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def list_locales
|
322
|
+
title = I18n.t('rrobots.list_locales_title')
|
323
|
+
puts title
|
324
|
+
puts "-"*title.size
|
325
|
+
I18n.backend.available_locales.each do |value|
|
326
|
+
puts " - #{value}"
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
$stdout.sync = true
|
331
|
+
|
332
|
+
|
333
|
+
ARGV.grep( /^-set-locale=(\w{2})/ )do |item|
|
334
|
+
x = $1.to_s
|
335
|
+
I18n.locale=x
|
336
|
+
ARGV.delete(item)
|
337
|
+
end
|
338
|
+
|
339
|
+
# look for query for robots internal list
|
340
|
+
ARGV.grep(/^(-list-internals)/) do |item|
|
341
|
+
list_internals
|
342
|
+
exit 0
|
343
|
+
end
|
344
|
+
|
345
|
+
# look for query for robots internal list
|
346
|
+
ARGV.grep(/^(-manual)/) do |item|
|
347
|
+
manual_file = "manual.rdoc"
|
348
|
+
manual_file = "manual_#{I18n.locale}.rdoc" if I18n.locale != 'en'
|
349
|
+
doc = "#{gem_path('doc')}/#{manual_file}"
|
350
|
+
RDoc.file_no_exit(doc)
|
351
|
+
exit 0
|
352
|
+
end
|
353
|
+
|
354
|
+
# look for query for locales avaible list
|
355
|
+
ARGV.grep(/^(-list-locales)/) do |item|
|
356
|
+
list_locales
|
357
|
+
exit 0
|
298
358
|
end
|
299
359
|
|
300
360
|
#look for timeout arg
|
@@ -317,6 +377,13 @@ with_toolboxes = true
|
|
317
377
|
ARGV.delete(item)
|
318
378
|
end
|
319
379
|
|
380
|
+
#look for with_mines arg
|
381
|
+
with_mines = false
|
382
|
+
ARGV.grep( /^(-with-mines)/ ) do |item|
|
383
|
+
with_mines = true
|
384
|
+
ARGV.delete(item)
|
385
|
+
end
|
386
|
+
|
320
387
|
#look for config arg
|
321
388
|
merge = true
|
322
389
|
ARGV.grep( /^(-ignore-config)/ )do |item|
|
@@ -372,7 +439,8 @@ robots.each do |bot1|
|
|
372
439
|
matches_per_round.times do |i|
|
373
440
|
puts "- Match #{i+1} of #{matches_per_round} -"
|
374
441
|
cmd = "rrobots -nogui -timeout=#{timeout} "
|
375
|
-
cmd += "-with-toolboxes " if with_toolboxes
|
442
|
+
cmd += "-with-toolboxes " if with_toolboxes
|
443
|
+
cmd += "-with-mines " if with_mines
|
376
444
|
cmd += "-ignore-config" if merge
|
377
445
|
cmd += "#{folder}/#{bot1} #{folder}/#{bot2}"
|
378
446
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
rrobots:
|
4
|
+
list_internals_title: List of avaibles internals robots
|
5
|
+
list_locales_title: List of avaible locales
|
6
|
+
match_limit_warning: match ends if only 1 bot/team left or dots get here-->|
|
7
|
+
battlefield:
|
8
|
+
robot_made_an_exception: '{{robot}} made an exception'
|
9
|
+
tkarena:
|
10
|
+
ai_name_dead: '{{ai_name}} dead'
|
11
|
+
draw: "Draw!"
|
12
|
+
no_team_wonn: ' won!'
|
13
|
+
no_team_won: '{{winner_name}} won!'
|
14
|
+
team_won: 'Team {{winner_team}} won!'
|
15
|
+
game_over: GAME OVER
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
fr:
|
3
|
+
rrobots:
|
4
|
+
list_internals_title: Liste des robots disponibles en interne
|
5
|
+
list_locales_title: Liste des locales disponibles
|
6
|
+
match_limit_warning: fin si 1 robot/equipe survi(e) ou ligne jusqu'ici -->|
|
7
|
+
battlefield:
|
8
|
+
robot_made_an_exception: '{{robot}} a lev� une exception'
|
9
|
+
tkarena:
|
10
|
+
ai_name_dead: '{{ai_name}} d�truit'
|
11
|
+
draw: Match nul !
|
12
|
+
no_team_won: '{{winner_name}} a gagn� !'
|
13
|
+
team_won: "L'�quipe {{winner_team}} a gagn� !"
|
14
|
+
game_over: FIN DU MATCH
|
data/config/rrobots.yml
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
--- !ruby/object:Configuration
|
2
2
|
battlefield:
|
3
|
-
:height: 800
|
4
3
|
:width: 800
|
4
|
+
:height: 800
|
5
5
|
bullets:
|
6
6
|
:speed: 30
|
7
|
+
filename: rrobots.yml
|
7
8
|
game:
|
8
9
|
:timeout: 50000
|
10
|
+
mines:
|
11
|
+
:with_mines: false
|
12
|
+
:bullet_energy_resistance: 2
|
13
|
+
:energy_hit_points: 20
|
9
14
|
robots:
|
15
|
+
:nb_mines: 3
|
16
|
+
:radar_mine_scanning_performance: 500
|
10
17
|
:energy_max: 100
|
11
18
|
toolboxes:
|
12
19
|
:energy_heal_points: 20
|
13
|
-
:with_toolboxes: false
|
14
20
|
:life_time: 200
|
21
|
+
:with_toolboxes: false
|
15
22
|
:spawning_chances: 100
|
data/doc/install.rdoc
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
= Installation
|
2
|
+
|
3
|
+
== Download
|
4
|
+
|
5
|
+
UG_RRobots could be download from the URL :
|
6
|
+
|
7
|
+
http://www.ultragreen.net/projects/rrobots/files
|
8
|
+
|
9
|
+
You could choose the Gem file or the TGZ fiile if you want to modify the project before to install it.
|
10
|
+
Files are sort by release
|
11
|
+
|
12
|
+
== Gem or Package creation
|
13
|
+
|
14
|
+
*Info* : this step is mandatory only if you choose to download TGZ sources
|
15
|
+
|
16
|
+
Exemple version 2.0 :
|
17
|
+
|
18
|
+
$ wget http://www.ultragreen.net/attachments/download/51/UG_RRobots-2.0.tgz
|
19
|
+
$ tar xvzf G_RRobots-2.0.tgz
|
20
|
+
$ cd UG_RRobots-2.0/
|
21
|
+
$ rake clean
|
22
|
+
$ rake clobber
|
23
|
+
$ rake gem
|
24
|
+
$ rake package # pour refaire le tgz
|
25
|
+
|
26
|
+
Gemfile or TGZ source are under the pkg Folder
|
27
|
+
|
28
|
+
If you create your gem, please do :
|
29
|
+
|
30
|
+
$ cd pkg
|
31
|
+
|
32
|
+
otherwise
|
33
|
+
|
34
|
+
$ wget http://www.ultragreen.net/attachments/download/52/UG_RRobots-2.0.gem
|
35
|
+
|
36
|
+
== Gem Installation
|
37
|
+
|
38
|
+
You should be root
|
39
|
+
|
40
|
+
$ sudo bash
|
41
|
+
# gem install UG_RRobots-2.0.gem
|
42
|
+
|
43
|
+
deinstallation :
|
44
|
+
|
45
|
+
$ sudo bash
|
46
|
+
# gem uninstall UG_RRobots
|
47
|
+
|
48
|
+
== Configuration
|
49
|
+
|
50
|
+
=== Config File Format
|
51
|
+
|
52
|
+
YAML file : rrobots.yaml
|
53
|
+
|
54
|
+
battlefield:
|
55
|
+
:width: 800
|
56
|
+
:height: 800
|
57
|
+
bullets:
|
58
|
+
:speed: 30
|
59
|
+
filename: rrobots.yml
|
60
|
+
game:
|
61
|
+
:timeout: 50000
|
62
|
+
mines:
|
63
|
+
:with_mines: false
|
64
|
+
:bullet_energy_resistance: 2
|
65
|
+
:energy_hit_points: 20
|
66
|
+
robots:
|
67
|
+
:nb_mines: 3
|
68
|
+
:radar_mine_scanning_performance: 500
|
69
|
+
:energy_max: 100
|
70
|
+
toolboxes:
|
71
|
+
:energy_heal_points: 20
|
72
|
+
:life_time: 200
|
73
|
+
:with_toolboxes: false
|
74
|
+
:spawning_chances: 100
|
75
|
+
|
76
|
+
|
77
|
+
=== Config file reading order and priority
|
78
|
+
|
79
|
+
in this order
|
80
|
+
|
81
|
+
* Code builtin values
|
82
|
+
* GEM_PATH/config/rrobots.yml (merge)
|
83
|
+
* PATH ('.') unless you have the -ignore-config for the rrobots command
|
84
|
+
|
85
|
+
the -argument -write-config create a clone of the configuration in PATH ('.') also named rrobots.yml
|