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/doc/install_fr.rdoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= Installation
|
2
|
+
|
3
|
+
== Téléchargement
|
4
|
+
|
5
|
+
UG_RRobots peut se télécharger depuis :
|
6
|
+
|
7
|
+
http://www.ultragreen.net/projects/rrobots/files
|
8
|
+
|
9
|
+
On choisit, soit le Gem déja construit, soit le tar.gz si on veut modifier le projet avant installation
|
10
|
+
Les fichiers sont classés par Release
|
11
|
+
|
12
|
+
== création
|
13
|
+
|
14
|
+
*Remarque* : Cette étape n'est necessaire que si on choisit de télécharger les 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
|
+
le gem et le tgz sont dans le sous-répertoire pkg
|
27
|
+
si vous installez depuis le gem fraîchement crée la partie wget du Rubygem est à remplacer par la commande
|
28
|
+
|
29
|
+
$ cd pkg
|
30
|
+
|
31
|
+
sinon pour récupéré le gem
|
32
|
+
|
33
|
+
$ wget http://www.ultragreen.net/attachments/download/52/UG_RRobots-2.0.gem
|
34
|
+
|
35
|
+
== Installation gem
|
36
|
+
|
37
|
+
On doit être root pour installer :
|
38
|
+
|
39
|
+
$ sudo bash
|
40
|
+
# gem install UG_RRobots-2.0.gem
|
41
|
+
|
42
|
+
Pour désinstaller :
|
43
|
+
|
44
|
+
$ sudo bash
|
45
|
+
# gem uninstall UG_RRobots
|
46
|
+
|
47
|
+
|
48
|
+
== Configuration
|
49
|
+
|
50
|
+
=== Format du fichier
|
51
|
+
|
52
|
+
fichier YAML : 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
|
+
=== priorité de lecture des fichiers
|
78
|
+
|
79
|
+
UG_RRobots possède toutes ses valeurs par défaut en dur dans le code , la configuration par défaut écrite dans :
|
80
|
+
|
81
|
+
GEM_PATH/config/rrobots.yml
|
82
|
+
|
83
|
+
est identique à ces valeurs, mais on peut la modifier.
|
84
|
+
Grâce à l'argument -write-config de la commande rrobots on peut cloner cette config dans le path ou on execute le jeu.
|
85
|
+
Si on n'utilise pas l'argument -ignore-config, Le jeu lit ensuite (merge) les différences entre les valeurs par défaut, puis celle de la config principale, puis celle du fichier dans le PATH.
|
86
|
+
Sinon, le fichier de config dans le PATH est ignoré.
|
data/doc/manual.rdoc
CHANGED
@@ -57,8 +57,10 @@ By including Robot you get all this methods to controll your bot:
|
|
57
57
|
- *turn_gun*(_degrees_) turns the gun (and the radar), max 30 degrees per tick
|
58
58
|
- *turn_radar*(_degrees_) turns the radar, max 60 degrees per tick
|
59
59
|
- *dead* true if you are dead
|
60
|
-
- *say*(_msg_)
|
61
|
-
- *broadcast*(_msg_)
|
60
|
+
- *say*(_msg_) shows msg above the robot on screen
|
61
|
+
- *broadcast*(_msg_) broadcasts msg to all bots (they recieve 'broadcasts' events with the msg and rough direction)
|
62
|
+
- *team_broadcast*(_msg_) team_broadcasts msg to all bots in your team (they recieve 'team_broadcasts' events with the msg and rough direction)
|
63
|
+
- *drop_mine* Drop a mine next to the robot, every robots could drop 3 mines by default
|
62
64
|
|
63
65
|
These methods are intentionally of very basic nature, you are free to
|
64
66
|
unleash the whole power of ruby to create higher level functions.
|
@@ -68,58 +70,22 @@ Some words of explanation: The gun is mounted on the body, if you turn
|
|
68
70
|
the body the gun will follow. In a simmilar way the radar is mounted on
|
69
71
|
the gun. The radar scans everything it sweeps over in a single tick (100
|
70
72
|
degrees if you turn your body, gun and radar in the same direction) but
|
71
|
-
will report only the distance of scanned robots, not the angle. If you
|
73
|
+
will report only the distance of scanned robots, scanned toolboxes or scanned mines, not the angle. If you
|
72
74
|
want more precission you have to turn your radar slower.
|
73
75
|
UG RRobots Fork introduce toolboxes, toolboxes could spawn during a match and if a robot run over it, the toolbox heal it of a default value of 20 energy point.
|
74
|
-
Toolboxes could be scan separatly of the robots (events keys
|
76
|
+
Toolboxes could be scan separatly of the robots (events keys toolbox_scanned)
|
75
77
|
The toolbox mode is optionnal
|
78
|
+
Mines could be scan separatly (events keys mine_scanned)
|
79
|
+
|
80
|
+
Mines could be dropped by robots, scan by others robots and kill with Bullets with à default energy > 2
|
76
81
|
|
77
82
|
RRobots is implemented in pure ruby using a tk ui and should run on all
|
78
83
|
platforms that have ruby and tk. (until now it's tested on windows, OS X
|
79
84
|
and several linux distributions)
|
80
85
|
|
81
|
-
|
82
|
-
|
83
|
-
<pre>
|
84
|
-
ruby rrobots.rb [resolution] [#match] [-nogui] [-speed=<N>] [-with-toolboxes] [-timeout=<N>] <FirstRobotClassName[.rb]> <SecondRobotClassName[.rb]> <...>
|
85
|
-
|
86
|
-
[resolution] (optional) should be of the form 640x480 or 800*600.
|
87
|
-
default is 800x800
|
88
|
-
[match] (optional) to replay a match, put the match# here, including
|
89
|
-
the #sign.
|
90
|
-
[-nogui] (optional) run the match without the gui, for highest possible
|
91
|
-
speed.(ignores speed value if present)
|
92
|
-
[-speed=<N>] (optional, defaults to 1) updates GUI after every N ticks.
|
93
|
-
The higher the N, the faster the match will play.
|
94
|
-
[-timeout=<N>] (optional, default 50000) number of ticks a match will
|
95
|
-
last at most.
|
96
|
-
[-ignore-config] (optional) to ignore the config file YAML present in the path.
|
97
|
-
[-write-config] (optional) to write the config in YAML in a file in the path.
|
98
|
-
[-with-toolboxes] (optional) to accept the spawning of healing toolboxes (randomly).
|
99
|
-
</pre>
|
100
|
-
|
101
|
-
the names of the rb files have to match the class names of the robots (up to 8 robots)
|
102
|
-
|
103
|
-
e.g.
|
104
|
-
'ruby rrobots.rb SittingDuck NervousDuck'
|
105
|
-
or
|
106
|
-
'ruby rrobots.rb 600x600 #1234567890 SittingDuck NervousDuck'
|
107
|
-
|
108
|
-
=== If you want to run a tournament call:
|
109
|
-
|
110
|
-
<pre>
|
111
|
-
ruby tournament.rb [-timeout=<N>] [-matches=<N>] [-with-toolboxes] (-dir=<Directory> | <RobotClassName[.rb]>+)
|
112
|
-
|
113
|
-
[-timeout=<N>] (optional, default 10000) number of ticks a match
|
114
|
-
will last at most.
|
115
|
-
[-matches=<N>] (optional, default 2) how many times each robot
|
116
|
-
fights every other robot.
|
117
|
-
-dir=<Directory> All .rb files from that directory will be
|
118
|
-
matched against each other.
|
119
|
-
[-ignore-config] (optional) to ignore the config file YAML present in the path.
|
120
|
-
[-with-toolboxes] (optional) to accept the spawning of healing toolboxes (randomly).
|
121
|
-
</pre>
|
86
|
+
== Usage
|
122
87
|
|
88
|
+
:include:usage.rdoc
|
123
89
|
|
124
90
|
the names of the rb files have to match the class names of the robots.
|
125
91
|
Each robot is matched against each other 1on1. The results are available
|
data/doc/manual_fr.rdoc
CHANGED
@@ -19,7 +19,7 @@ Tous les robots ont les même caractéristiques, et tant que le joueur n'a pas c
|
|
19
19
|
|
20
20
|
=== il pourrait ressembler à ceci :
|
21
21
|
|
22
|
-
<code
|
22
|
+
<code class="ruby">
|
23
23
|
require 'robot'
|
24
24
|
class NervousDuck
|
25
25
|
include Robot
|
@@ -61,9 +61,11 @@ En incluant le module Ruby Robot vous récupérez les méthodes indispensable po
|
|
61
61
|
- *turn_gun*(_degres_) : tourne votre canon et donc votre radar (max 30 degrés par tick)
|
62
62
|
- *turn_radar*(_degres_) : tourne votre radar (max 60 degrés par tick)
|
63
63
|
- *dead* : renvoie vrai si vous êtes mort
|
64
|
+
- *drop_mine* : pose une mine sous le robot (une mine ne peut pas abimer le robot qui l'a posée)
|
64
65
|
|
65
66
|
* *say*(_msg_) : affiche un message sur l'écran en mode GUI/TK au dessus de votre robot.
|
66
|
-
* *broadcast*(_msg_) : envoie un message à tous les robots sur le champs de bataille, une clef '*broadcast*' est ajouté au hachage '*events*' avec le message
|
67
|
+
* *broadcast*(_msg_) : envoie un message à tous les robots sur le champs de bataille, une clef '*broadcast*' est ajouté au hachage '*events*' avec le message et la direction
|
68
|
+
- *team_broadcast*(_msg_) envoie un message à tous les robots de votre equipe sur le champs de bataille, une clef '*team_broadcast*' est ajouté au hachage '*events*' avec le message et la direction
|
67
69
|
|
68
70
|
Cette liste de méthode est volontairement réduite et basique, à la charge du joueur créer ses propres méthodes de haut niveau grace à la puissance de Ruby.
|
69
71
|
(exemple : move_to, fire_at, etc...)
|
@@ -73,56 +75,19 @@ Cette liste de méthode est volontairement réduite et basique, à la charge du
|
|
73
75
|
- Le canon est monté sur le corps du robot, donc si vous bougez le robot le canon suit.
|
74
76
|
Pareil pour le radar, qui se trouve sur le canon.
|
75
77
|
|
76
|
-
- Le radar scan tout se qui trouve sur le rayon de déplacement cumulé du robot, du canon et du radar lui même (mouvement relatif du radar) sur un '*tick*' donné, mais ne renvoi que la distance vers le/les objets scannés (clef *
|
78
|
+
- Le radar scan tout se qui trouve sur le rayon de déplacement cumulé du robot, du canon et du radar lui même (mouvement relatif du radar) sur un '*tick*' donné, mais ne renvoi que la distance vers le/les objets scannés (clef *robot_scanned* avec la distance en valeur pour les robots, clef toolbox_scanned avec la distance en valeur pour les boites à outils, clef *mine_scanned*) ceci fait donc un angles d'incertitude maximum de 100°, pour pouvoir être précis il faut bouger votre radar plus doucement.
|
77
79
|
|
78
80
|
- UG RRobots Fork introduit les boites à outils, elle sont donc détectables par le radar, lorsqu'un robot passe sur l'une d'elle, il récupère des points d'energie (20 par défaut).
|
79
81
|
Les boites à outils apparaissent de façon aléatoire et reste pour une durée définie ( 200 ticks par défaut), chaque tick elle ont la même chance (faible) d'apparaître (1 sur 100 par défaut)
|
82
|
+
Les mines déposables peuvent être détecté par les autres robots si il sont suffisamment près d'elle, et dans l'axe du radar (défaut 500 px)
|
83
|
+
Les mines sont destructible par l'abus du canon d'un robot de force > (par défaut 2).
|
80
84
|
|
81
|
-
UG RRobots Fork comme la version d'origine est implémenté en Ruby pur avec une Interface Graphique TK et peut tourner sur de nombreuses plateformes qui possèdent Ruby et TK, le moteur du jeu en lui même peu très bien se passer de TK.
|
85
|
+
UG RRobots Fork, comme la version d'origine, est implémenté en Ruby pur avec une Interface Graphique TK et peut tourner sur de nombreuses plateformes qui possèdent Ruby et TK, le moteur du jeu en lui même peu très bien se passer de TK.
|
82
86
|
UG RRobots Fork à été testé sur Windows, la plus part des distributions Linux, FreeBSD et Windows
|
83
87
|
|
84
|
-
== Utilisation
|
88
|
+
== Utilisation des commandes
|
85
89
|
|
86
|
-
|
87
|
-
ruby rrobots.rb [resolution] [#match] [-nogui] [-speed=<N>] [-timeout=<N>] [-with-toolboxes] <RobotClassName[.rb]> <RobotClassName[.rb]> <...>
|
88
|
-
|
89
|
-
[resolution] (optionel) doit être de la forme 640x480 ou 800*600.
|
90
|
-
800x800 par défaut
|
91
|
-
[match] (optionel) pour rejouer un match, préciser un numéro de match , avec le signe
|
92
|
-
# devant.
|
93
|
-
[-nogui] (optionel) lance le match sans GUI/TK, ignore -speed
|
94
|
-
[-with-toolboxes] (optionel) active l'apparition de boite à outils et leurs détections.
|
95
|
-
[-speed=<N>] (optionel, défaut 1) rafraîchit la GUI après N ticks.
|
96
|
-
Plus N est grand, plus le match s'affichera vite.
|
97
|
-
[-timeout=<N>] (optionel, defaut 50000) nombre de ticks maximum d'un match
|
98
|
-
[-ignore-config] (optional) pour ignorer la config au format YAML dan un fichier dans le path.
|
99
|
-
[-write-config] (optional) pour ecrire la config au format YAML dan un fichier dans le path.
|
100
|
-
</pre>
|
101
|
-
|
102
|
-
* le fichier d'un robot doit avoir le même nom que la Classe du Robot
|
103
|
-
* (jusqu'à 8 robots)
|
104
|
-
|
105
|
-
exemple :
|
106
|
-
|
107
|
-
ruby rrobots.rb SittingDuck NervousDuck'
|
108
|
-
|
109
|
-
ou
|
110
|
-
|
111
|
-
ruby rrobots.rb 600x600 #1234567890 SittingDuck NervousDuck'
|
112
|
-
|
113
|
-
== Utilisation du moteur de tournoi :
|
114
|
-
|
115
|
-
Pas besoin de TK
|
116
|
-
|
117
|
-
<pre>
|
118
|
-
ruby tournament.rb [-timeout=<N>] [-matches=<N>] (-dir=<Directory> | <RobotClassName[.rb]>+)
|
119
|
-
|
120
|
-
[-timeout=<N>] (optionel, defaut 50000) nombre de ticks maximum d'un match
|
121
|
-
[-with-toolboxes] (optionel) active l'apparition de boite à outils et leurs détections.
|
122
|
-
[-matches=<N>] (optionel, defaut 2) nombre de rounds par match entre deux robots
|
123
|
-
-dir=<Directory> tout les fichiers .rb dans le répertoire seront considérents comme des robots concurents
|
124
|
-
[-ignore-config] (optional) pour ignorer la config au format YAML dan un fichier dans le path.
|
125
|
-
</pre>
|
90
|
+
:include:usage_fr.rdoc
|
126
91
|
|
127
92
|
- le fichier d'un robot doit avoir le même nom que la Classe du Robot
|
128
93
|
- les robots s'affrontes un contre un
|
data/doc/usage.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
=== rrobots
|
2
|
+
|
3
|
+
USAGE: rrobots [resolution] [#match] [-nogui] [-speed=<N>] [-timeout=<N>] [-teams=<N>] [-with-toolboxes] [-with-mines] [-set-locale=<locale>]
|
4
|
+
<FirstRobotClassName[.rb]> <SecondRobotClassName[.rb]> <...>
|
5
|
+
or : rrobots [-set-locale=<locale>] -list-internals
|
6
|
+
or : rrobots [-set-locale=<locale>] -list-locales
|
7
|
+
or : rrobots [-set-locale=<locale>] -manual
|
8
|
+
or : rrobots [-set-locale=<locale>]
|
9
|
+
|
10
|
+
without arguments : give this usage page
|
11
|
+
|
12
|
+
* [-list-internals] (exclusive) give the list of avaibles internals Robots.
|
13
|
+
* [resolution] (optional) should be of the form 640x480 or 800*600. default is 800x800.
|
14
|
+
* [match] (optional) to replay a match, put the match# here, including the #sign.
|
15
|
+
* [-nogui] (optional) run the match without the gui, for highest possible speed.(ignores speed value if present).
|
16
|
+
* [-speed=<N>] (optional, defaults to 1) updates GUI after every N ticks. The higher the N, the faster the match will play.
|
17
|
+
* [-timeout=<N>] (optional, default 50000) number of ticks a match will last at most.
|
18
|
+
* [-teams=<N>] (optional) split robots into N teams. Match ends when only one team has robots left.
|
19
|
+
* [-with-toolboxes] (optional) to accept the spawning of healing toolboxes (randomly).
|
20
|
+
* [-ignore-config] (optional) to ignore the config file present in the path.
|
21
|
+
* [-write-config] (optional) to write the config in a file in the path.
|
22
|
+
* [-set-locale] (optional) force a locale if avaible in locales list.
|
23
|
+
* [-list-locales] (exclusive) list avaible locale.
|
24
|
+
* [-manual] (exclusive) give the manual page of RRobots.
|
25
|
+
* [-with-mines] (optional) to accept the dropping of mines by the robots (default 3).
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
The names of the rb files have to match the class names of the robots
|
30
|
+
(up to 8 robots)
|
31
|
+
|
32
|
+
e.g. 'rrobots SittingDuck NervousDuck'
|
33
|
+
or 'rrobots 600x600 #1234567890 SittingDuck NervousDuck'
|
34
|
+
|
35
|
+
=== tournament
|
36
|
+
|
37
|
+
USAGE : tournament [-timeout=<N>] [-matches=<N>] [-with-toolboxes] [-with-mines] [-set-locale=<locale>]
|
38
|
+
(-dir=<Directory> | <RobotClassName[.rb]>+)
|
39
|
+
or : tournament [-set-locale=<locale>] -list-locales
|
40
|
+
or : tournament [-set-locale=<locale>] -manual
|
41
|
+
or : tournament [-set-locale=<locale>]
|
42
|
+
|
43
|
+
without arguments : give this usage page
|
44
|
+
|
45
|
+
* [-timeout=<N>] (optional, default 10000) number of ticks a match will last at most.
|
46
|
+
* [-matches=<N>] (optional, default 2) how many times each robot fights every other robot.
|
47
|
+
* -dir=<Directory> All .rb files from that directory will be matched against each other.
|
48
|
+
* [-ignore-config] (optional) to ignore the config file YAML present in the path.
|
49
|
+
* [-with-toolboxes] (optional) to accept the spawning of healing toolboxes (randomly).
|
50
|
+
* [-set-locale] (optional) force a locale if avaible in locales list.
|
51
|
+
* [-list-locales] (exclusive) list available locales.
|
52
|
+
* [-manual] (exclusive) donne la page de manuel du projet RRobots.
|
53
|
+
* [-list-internals] (exclusive) give the list of avaibles internals Robots.
|
54
|
+
* [-with-mines] (optional) to accept the dropping of mines by the robots (default 3).
|
55
|
+
|
56
|
+
This mode doesn't need the TK engine
|
data/doc/usage_fr.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
=== rrobots
|
2
|
+
|
3
|
+
USAGE: rrobots [resolution] [#match] [-nogui] [-speed=<N>] [-timeout=<N>] [-teams=<N>] [-with-toolboxes] [-with-mines] [-set-locale=<locale>]
|
4
|
+
<FirstRobotClassName[.rb]> <SecondRobotClassName[.rb]> <...>
|
5
|
+
ou : rrobots [-set-locale=<locale>] -list-internals
|
6
|
+
ou : rrobots [-set-locale=<locale>] -list-locales
|
7
|
+
ou : rrobots [-set-locale=<locale>] -manual
|
8
|
+
ou : rrobots [-set-locale=<locale>]
|
9
|
+
|
10
|
+
Sans arguments : donne cette page d'usage de la commande
|
11
|
+
|
12
|
+
|
13
|
+
* [-list-internals] (exclusif) donne la liste des robots disponible en interne.
|
14
|
+
* [resolution] (optionel) de la forme 640x480 ou 800x600. (defaut 800x800).
|
15
|
+
* [match] (optionel) pour rejouer un match, nommage du format #nombre, enregistre ou rejoue un match.
|
16
|
+
* [-nogui] (optionel) execute le match sans GUI, pour maximiser la vitesse.(ignores l'argument speed si il est présent).
|
17
|
+
* [-speed=<N>] (optionel, défaut to 1) maj de la GUI après N ticks. Plus N est grand plus le match est rapide.
|
18
|
+
* [-timeout=<N>] (optionel, défaut 50000) nombre de tick max d'un match.
|
19
|
+
* [-teams=<N>] (optionel) découpe en N équipes. le match s'arrête quand il ne reste plus qu'un robots ou en timeout.
|
20
|
+
* [-with-toolboxes] (optionel) pour accepter l'apparition de boite à outils (aleatoire).
|
21
|
+
* [-ignore-config] (optionel) pour ignorer la lecture de la configuration dans le fichier YAML du path.
|
22
|
+
* [-write-config] (optionel) pour écrire un dump de la configuration dans le fichier YAML du path.
|
23
|
+
* [-set-locale] (optionel) force une locale.
|
24
|
+
* [-list-locales] (exclusif) liste les locales disponibles.
|
25
|
+
* [-manual] (exclusif) donne la page de manuel du projet RRobots
|
26
|
+
* [-with-mines] (optionel) accepte le dépôt de mines parl les robots (default 3).
|
27
|
+
|
28
|
+
Remarques :
|
29
|
+
* le fichier d'un robot doit avoir le même nom que la Classe du Robot
|
30
|
+
* (jusqu'à 8 robots)
|
31
|
+
|
32
|
+
Exemple :
|
33
|
+
|
34
|
+
$ rrobots SittingDuck NervousDuck'
|
35
|
+
|
36
|
+
ou
|
37
|
+
|
38
|
+
$ rrobots 600x600 #1234567890 SittingDuck NervousDuck'
|
39
|
+
|
40
|
+
|
41
|
+
=== tournament
|
42
|
+
|
43
|
+
USAGE : tournament [-timeout=<N>] [-matches=<N>] [-with-toolboxes] [-with-mines] [-set-locale=<locale>]
|
44
|
+
(-dir=<Directory> | <RobotClassName[.rb]>+)
|
45
|
+
ou : tournament [-set-locale=<locale>] -list-locales
|
46
|
+
ou : tournament [-set-locale=<locale>] -manual
|
47
|
+
ou : tournament [-set-locale=<locale>]
|
48
|
+
|
49
|
+
Sans arguments : donne cette page d'usage de la commande
|
50
|
+
|
51
|
+
* [-timeout=<N>] (optionel, defaut 10000) nombre de tick max d'un match.
|
52
|
+
* [-matches=<N>] (optionel, defaut 2) nombre de face à face par couple de 2 robots.
|
53
|
+
* -dir=<Directory> tout les fichiers .rb de ce répertoire s'affronte par match réciproque.
|
54
|
+
* [-ignore-config] (optionel) pour ignorer la lecture de la configuration dans le fichier YAML du path.
|
55
|
+
* [-with-toolboxes] (optionel) active le mode d'apparition de boites à outils.
|
56
|
+
* [-set-locale] (optionel) force un locale.
|
57
|
+
* [-list-locales] (exclusif) liste les locales disponibles.
|
58
|
+
* [-manual] (exclusif) donne la page de manuel du projet RRobots.
|
59
|
+
* [-list-internals] (exclusif) donne la liste des robots disponible en interne.
|
60
|
+
* [-with-mines] (optionel) accepte le dépôt de mines parl les robots (default 3).
|
61
|
+
|
62
|
+
Ce mode n'a pas besoin de TK
|
63
|
+
|
data/lib/battlefield.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'toolboxes'
|
2
|
+
require 'explosions'
|
3
|
+
require 'bullets'
|
4
|
+
require 'mines'
|
1
5
|
|
2
6
|
class Battlefield
|
3
7
|
attr_reader :width
|
@@ -7,15 +11,16 @@ class Battlefield
|
|
7
11
|
attr_reader :bullets
|
8
12
|
attr_reader :explosions
|
9
13
|
attr_reader :toolboxes
|
14
|
+
attr_reader :mines
|
10
15
|
attr_reader :time
|
11
16
|
attr_reader :seed
|
12
17
|
attr_reader :timeout # how many ticks the match can go before ending.
|
13
18
|
attr_reader :game_over
|
14
|
-
attr_reader :toolboxes
|
15
19
|
attr_reader :with_toolboxes
|
20
|
+
attr_reader :with_mines
|
16
21
|
attr_reader :config
|
17
22
|
|
18
|
-
def initialize width, height, timeout, seed, with_toolboxes, merge, write_config
|
23
|
+
def initialize width, height, timeout, seed, with_toolboxes, with_mines, merge, write_config
|
19
24
|
filename = "rrobots.yml"
|
20
25
|
@config = Configuration::new
|
21
26
|
@path_prefix = gem_path('config')
|
@@ -36,6 +41,8 @@ class Battlefield
|
|
36
41
|
@time = 0
|
37
42
|
@robots = []
|
38
43
|
@toolboxes = []
|
44
|
+
@mines = []
|
45
|
+
@with_mines = (self.config.mines[:with_mines] != with_mines)? with_mines : self.config.mines[:with_mines]
|
39
46
|
@with_toolboxes = (self.config.toolboxes[:with_toolboxes] != with_toolboxes)? with_toolboxes : self.config.toolboxes[:with_toolboxes]
|
40
47
|
@teams = Hash.new{|h,k| h[k] = [] }
|
41
48
|
@bullets = []
|
@@ -56,6 +63,8 @@ class Battlefield
|
|
56
63
|
@explosions << object
|
57
64
|
when Toolbox
|
58
65
|
@toolboxes << object
|
66
|
+
when Mine
|
67
|
+
@mines << object
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
@@ -66,6 +75,9 @@ class Battlefield
|
|
66
75
|
toolboxes.delete_if{|toolbox| toolbox.dead}
|
67
76
|
toolboxes.each{|toolbox| toolbox.tick}
|
68
77
|
|
78
|
+
mines.delete_if{|mine| mine.dead}
|
79
|
+
mines.each{|mine| mine.tick}
|
80
|
+
|
69
81
|
bullets.delete_if{|bullet| bullet.dead}
|
70
82
|
bullets.each{|bullet| bullet.tick}
|
71
83
|
|
@@ -75,7 +87,7 @@ class Battlefield
|
|
75
87
|
begin
|
76
88
|
robot.send :internal_tick unless robot.dead
|
77
89
|
rescue Exception => bang
|
78
|
-
puts
|
90
|
+
puts I18n.t('battlefield.robot_made_an_exception', :robot => robot)
|
79
91
|
puts "#{bang.class}: #{bang}", bang.backtrace
|
80
92
|
robot.instance_eval{@energy = -1}
|
81
93
|
end
|
@@ -91,9 +103,10 @@ class Battlefield
|
|
91
103
|
|
92
104
|
def state
|
93
105
|
{:explosions => explosions.map{|e| e.state},
|
94
|
-
:bullets
|
95
|
-
:toolboxes
|
96
|
-
:
|
106
|
+
:bullets => bullets.map{|b| b.state},
|
107
|
+
:toolboxes => toolboxes.map{|t| t.state},
|
108
|
+
:mines => mines.map{|m| m.state},
|
109
|
+
:robots => robots.map{|r| r.state}}
|
97
110
|
end
|
98
111
|
|
99
112
|
def spawning_toolboxes
|