UG_RRobots 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/bin/rrobots +202 -0
  2. data/bin/tournament +413 -0
  3. data/config/rrobots.yml +15 -0
  4. data/contribs/allbots.rb +0 -0
  5. data/doc/manual.rdoc +126 -0
  6. data/doc/manual_fr.rdoc +129 -0
  7. data/images/explosion00.gif +0 -0
  8. data/images/explosion01.gif +0 -0
  9. data/images/explosion02.gif +0 -0
  10. data/images/explosion03.gif +0 -0
  11. data/images/explosion04.gif +0 -0
  12. data/images/explosion05.gif +0 -0
  13. data/images/explosion06.gif +0 -0
  14. data/images/explosion07.gif +0 -0
  15. data/images/explosion08.gif +0 -0
  16. data/images/explosion09.gif +0 -0
  17. data/images/explosion10.gif +0 -0
  18. data/images/explosion11.gif +0 -0
  19. data/images/explosion12.gif +0 -0
  20. data/images/explosion13.gif +0 -0
  21. data/images/explosion14.gif +0 -0
  22. data/images/red_body000.gif +0 -0
  23. data/images/red_body010.gif +0 -0
  24. data/images/red_body020.gif +0 -0
  25. data/images/red_body030.gif +0 -0
  26. data/images/red_body040.gif +0 -0
  27. data/images/red_body050.gif +0 -0
  28. data/images/red_body060.gif +0 -0
  29. data/images/red_body070.gif +0 -0
  30. data/images/red_body080.gif +0 -0
  31. data/images/red_body090.gif +0 -0
  32. data/images/red_body100.gif +0 -0
  33. data/images/red_body110.gif +0 -0
  34. data/images/red_body120.gif +0 -0
  35. data/images/red_body130.gif +0 -0
  36. data/images/red_body140.gif +0 -0
  37. data/images/red_body150.gif +0 -0
  38. data/images/red_body160.gif +0 -0
  39. data/images/red_body170.gif +0 -0
  40. data/images/red_body180.gif +0 -0
  41. data/images/red_body190.gif +0 -0
  42. data/images/red_body200.gif +0 -0
  43. data/images/red_body210.gif +0 -0
  44. data/images/red_body220.gif +0 -0
  45. data/images/red_body230.gif +0 -0
  46. data/images/red_body240.gif +0 -0
  47. data/images/red_body250.gif +0 -0
  48. data/images/red_body260.gif +0 -0
  49. data/images/red_body270.gif +0 -0
  50. data/images/red_body280.gif +0 -0
  51. data/images/red_body290.gif +0 -0
  52. data/images/red_body300.gif +0 -0
  53. data/images/red_body310.gif +0 -0
  54. data/images/red_body320.gif +0 -0
  55. data/images/red_body330.gif +0 -0
  56. data/images/red_body340.gif +0 -0
  57. data/images/red_body350.gif +0 -0
  58. data/images/red_radar000.gif +0 -0
  59. data/images/red_radar010.gif +0 -0
  60. data/images/red_radar020.gif +0 -0
  61. data/images/red_radar030.gif +0 -0
  62. data/images/red_radar040.gif +0 -0
  63. data/images/red_radar050.gif +0 -0
  64. data/images/red_radar060.gif +0 -0
  65. data/images/red_radar070.gif +0 -0
  66. data/images/red_radar080.gif +0 -0
  67. data/images/red_radar090.gif +0 -0
  68. data/images/red_radar100.gif +0 -0
  69. data/images/red_radar110.gif +0 -0
  70. data/images/red_radar120.gif +0 -0
  71. data/images/red_radar130.gif +0 -0
  72. data/images/red_radar140.gif +0 -0
  73. data/images/red_radar150.gif +0 -0
  74. data/images/red_radar160.gif +0 -0
  75. data/images/red_radar170.gif +0 -0
  76. data/images/red_radar180.gif +0 -0
  77. data/images/red_radar190.gif +0 -0
  78. data/images/red_radar200.gif +0 -0
  79. data/images/red_radar210.gif +0 -0
  80. data/images/red_radar220.gif +0 -0
  81. data/images/red_radar230.gif +0 -0
  82. data/images/red_radar240.gif +0 -0
  83. data/images/red_radar250.gif +0 -0
  84. data/images/red_radar260.gif +0 -0
  85. data/images/red_radar270.gif +0 -0
  86. data/images/red_radar280.gif +0 -0
  87. data/images/red_radar290.gif +0 -0
  88. data/images/red_radar300.gif +0 -0
  89. data/images/red_radar310.gif +0 -0
  90. data/images/red_radar320.gif +0 -0
  91. data/images/red_radar330.gif +0 -0
  92. data/images/red_radar340.gif +0 -0
  93. data/images/red_radar350.gif +0 -0
  94. data/images/red_turret000.gif +0 -0
  95. data/images/red_turret010.gif +0 -0
  96. data/images/red_turret020.gif +0 -0
  97. data/images/red_turret030.gif +0 -0
  98. data/images/red_turret040.gif +0 -0
  99. data/images/red_turret050.gif +0 -0
  100. data/images/red_turret060.gif +0 -0
  101. data/images/red_turret070.gif +0 -0
  102. data/images/red_turret080.gif +0 -0
  103. data/images/red_turret090.gif +0 -0
  104. data/images/red_turret100.gif +0 -0
  105. data/images/red_turret110.gif +0 -0
  106. data/images/red_turret120.gif +0 -0
  107. data/images/red_turret130.gif +0 -0
  108. data/images/red_turret140.gif +0 -0
  109. data/images/red_turret150.gif +0 -0
  110. data/images/red_turret160.gif +0 -0
  111. data/images/red_turret170.gif +0 -0
  112. data/images/red_turret180.gif +0 -0
  113. data/images/red_turret190.gif +0 -0
  114. data/images/red_turret200.gif +0 -0
  115. data/images/red_turret210.gif +0 -0
  116. data/images/red_turret220.gif +0 -0
  117. data/images/red_turret230.gif +0 -0
  118. data/images/red_turret240.gif +0 -0
  119. data/images/red_turret250.gif +0 -0
  120. data/images/red_turret260.gif +0 -0
  121. data/images/red_turret270.gif +0 -0
  122. data/images/red_turret280.gif +0 -0
  123. data/images/red_turret290.gif +0 -0
  124. data/images/red_turret300.gif +0 -0
  125. data/images/red_turret310.gif +0 -0
  126. data/images/red_turret320.gif +0 -0
  127. data/images/red_turret330.gif +0 -0
  128. data/images/red_turret340.gif +0 -0
  129. data/images/red_turret350.gif +0 -0
  130. data/images/toolbox.gif +0 -0
  131. data/lib/battlefield.rb +102 -0
  132. data/lib/bullets.rb +39 -0
  133. data/lib/configuration.rb +26 -0
  134. data/lib/explosions.rb +20 -0
  135. data/lib/overloads.rb +10 -0
  136. data/lib/robot.rb +122 -0
  137. data/lib/robotrunner.rb +260 -0
  138. data/lib/tkarena.rb +197 -0
  139. data/lib/toolboxes.rb +28 -0
  140. data/robots/BillDuck.rb +92 -0
  141. data/robots/BotOne.rb +39 -0
  142. data/robots/DuckBill.rb +384 -0
  143. data/robots/DuckBill04.rb +330 -0
  144. data/robots/DuckToEndAllDucks.rb +140 -0
  145. data/robots/EdgeBot.rb +203 -0
  146. data/robots/HuntingDuck.rb +74 -0
  147. data/robots/HyperactiveDuck.rb +15 -0
  148. data/robots/Killer.rb +58 -0
  149. data/robots/Kite.rb +193 -0
  150. data/robots/KoDuck.rb +57 -0
  151. data/robots/LinearShooter.rb +279 -0
  152. data/robots/LuckyDuck.rb +83 -0
  153. data/robots/MoxonoM.rb +85 -0
  154. data/robots/MsgBot.rb +13 -0
  155. data/robots/NervousDuck.rb +13 -0
  156. data/robots/Polisher.rb +15 -0
  157. data/robots/RomBot.rb +514 -0
  158. data/robots/RoomPainter.rb +205 -0
  159. data/robots/Rrrkele.rb +48 -0
  160. data/robots/Seeker.rb +57 -0
  161. data/robots/ShootingStation.rb +15 -0
  162. data/robots/SittingDuck.rb +18 -0
  163. data/robots/SniperDuck.rb +277 -0
  164. data/robots/WallPainter.rb +224 -0
  165. metadata +220 -0
@@ -0,0 +1,224 @@
1
+ # WallPainter
2
+ # written by Jannis Harder (jix) in 2005
3
+
4
+ require 'robot'
5
+
6
+ # avoid clashes with other state robots
7
+
8
+ module WallPainterTools
9
+
10
+ # a state based robot
11
+ class StateRobot
12
+ include Robot
13
+
14
+ def initialize(*)
15
+ super
16
+ @mode = :idle
17
+ @sec_modes = []
18
+ init
19
+ end
20
+
21
+ # set mode for next tick
22
+ def next_mode new_mode
23
+ if has_mode? new_mode
24
+ @mode = new_mode
25
+ else
26
+ warn "Robot #{self.class} switched to unknown mode :#{new_mode}!"
27
+ @mode = :idle
28
+ end
29
+ end
30
+
31
+ # activate a secondary mode
32
+ def add_sec_mode new_mode
33
+ if has_mode? new_mode
34
+ @sec_modes << new_mode
35
+ else
36
+ warn "Robot #{self.class} switched to unknown secondary mode :#{new_mode}!"
37
+ end
38
+ end
39
+
40
+ # activate some secondary modes
41
+ def add_sec_modes *modes
42
+ modes.flatten.each do |new_mode|
43
+ add_sec_mode new_mode
44
+ end
45
+ end
46
+
47
+ # deactivate a secondary mode
48
+ def del_sec_mode old_mode
49
+ @sec_modes.delete old_mode
50
+ end
51
+
52
+ # deactivate some secondary modes
53
+ def del_sec_modes *modes
54
+ modes.flatten.each do |old_mode|
55
+ del_sec_mode old_mode
56
+ end
57
+ end
58
+
59
+ # test for a mode
60
+ def has_mode? new_mode
61
+ respond_to? new_mode.to_s<<'_tick'
62
+ end
63
+
64
+ # set new mode and tick it once
65
+ def mode new_mode
66
+ next_mode new_mode
67
+ tick @events
68
+ end
69
+
70
+ # tick a mode
71
+ def tick_mode temp_mode
72
+ send temp_mode.to_s<<'_tick'
73
+ end
74
+
75
+ # default tick
76
+ def idle_tick
77
+ end
78
+
79
+ # processing
80
+ def tick events
81
+ @events = events
82
+ tick_mode @mode
83
+ @sec_modes.each do |smode|
84
+ tick_mode smode
85
+ end
86
+ end
87
+
88
+
89
+ attr_reader :events
90
+
91
+ end
92
+
93
+ end
94
+
95
+ class WallPainter < WallPainterTools::StateRobot
96
+
97
+ def init
98
+ next_mode :find_wall
99
+ add_sec_modes :aim, :scan, :fire
100
+ @scan_range = 2
101
+ @tracking = 0
102
+ @fire = [nil]*2
103
+ @flip_flop = true
104
+ end
105
+
106
+ #helpers
107
+
108
+ def offset(heading_a,heading_b)
109
+ my_offset = heading_a-heading_b % 360
110
+ my_offset = my_offset -360 if my_offset > 180
111
+ my_offset
112
+ end
113
+
114
+ def nth?(n)
115
+ time % n == 0
116
+ end
117
+
118
+ #ticks
119
+
120
+ def find_wall_tick
121
+ if heading == 180
122
+ mode :go_to_wall
123
+ else
124
+ turn 180-heading
125
+ end
126
+ end
127
+
128
+ def go_to_wall_tick
129
+ left = x - size
130
+ if left <= 0
131
+ mode :turn_upwards
132
+ elsif left > velocity
133
+ accelerate(1)
134
+ elsif left < velocity
135
+ stop
136
+ end
137
+ end
138
+
139
+ def turn_upwards_tick
140
+ stop
141
+ if heading == 90
142
+ mode :paint
143
+
144
+ else
145
+ turn 90-heading
146
+ end
147
+ end
148
+
149
+ def scan_tick
150
+ @scan_range = [@scan_range,10].min
151
+
152
+ radar_offset = offset(radar_heading,gun_heading)
153
+ if nth? 2
154
+ turn_radar -@scan_range-radar_offset
155
+ else
156
+ turn_radar +@scan_range-radar_offset
157
+ end
158
+ end
159
+
160
+ def fire_tick
161
+ if x = @fire.pop
162
+ fire x
163
+ end
164
+ if scanned = events['robot_scanned'].first
165
+ away = scanned.first
166
+ str = [0.1,800.0/away].max
167
+ @fire << str
168
+ else
169
+ @fire << nil
170
+ end
171
+
172
+ end
173
+
174
+ def aim_tick
175
+
176
+ if scanned = events['robot_scanned'].first
177
+ away = scanned.first
178
+ @scan_range = 1.2
179
+
180
+ @last_offset = offset(radar_heading,gun_heading)
181
+ turn_gun(@last_offset)
182
+ @tracking = 10
183
+ elsif @tracking == 0
184
+ @scan_range += 0.1
185
+ if @flip_flop
186
+ turn_gun(20)
187
+ else
188
+ turn_gun(-20)
189
+ end
190
+ #puts gun_heading
191
+ if offset(gun_heading,0).abs > 90
192
+ @flip_flop = offset(gun_heading,0) < 0
193
+ end
194
+ else
195
+ @tracking-=1
196
+ @last_offset*=-2
197
+ turn_gun(@last_offset)
198
+ end
199
+
200
+ end
201
+
202
+ def paint_tick
203
+ if y <= size
204
+ sign = -1
205
+ left = 100
206
+ elsif y + size >= battlefield_height
207
+ sign = 1
208
+ left = 100
209
+ elsif velocity > 0
210
+ left = y - size
211
+ sign = 1
212
+ else
213
+ left = battlefield_height - y - size
214
+ sign = -1
215
+ end
216
+
217
+ if left < velocity
218
+ stop
219
+ elsif left > velocity
220
+ accelerate(sign)
221
+ end
222
+ end
223
+
224
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: UG_RRobots
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.2"
5
+ platform: ruby
6
+ authors:
7
+ - "Simon Kr\xC3\xB6ger, Romain GEORGES"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-18 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Ultragreen RRobots Fork
17
+ email: dev@ultragreen.net
18
+ executables:
19
+ - rrobots
20
+ - tournament
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - doc/manual.rdoc
25
+ - doc/manual_fr.rdoc
26
+ files:
27
+ - bin/rrobots
28
+ - bin/tournament
29
+ - lib/battlefield.rb
30
+ - lib/bullets.rb
31
+ - lib/configuration.rb
32
+ - lib/explosions.rb
33
+ - lib/overloads.rb
34
+ - lib/robot.rb
35
+ - lib/robotrunner.rb
36
+ - lib/tkarena.rb
37
+ - lib/toolboxes.rb
38
+ - images/explosion00.gif
39
+ - images/explosion01.gif
40
+ - images/explosion02.gif
41
+ - images/explosion03.gif
42
+ - images/explosion04.gif
43
+ - images/explosion05.gif
44
+ - images/explosion06.gif
45
+ - images/explosion07.gif
46
+ - images/explosion08.gif
47
+ - images/explosion09.gif
48
+ - images/explosion10.gif
49
+ - images/explosion11.gif
50
+ - images/explosion12.gif
51
+ - images/explosion13.gif
52
+ - images/explosion14.gif
53
+ - images/red_body000.gif
54
+ - images/red_body010.gif
55
+ - images/red_body020.gif
56
+ - images/red_body030.gif
57
+ - images/red_body040.gif
58
+ - images/red_body050.gif
59
+ - images/red_body060.gif
60
+ - images/red_body070.gif
61
+ - images/red_body080.gif
62
+ - images/red_body090.gif
63
+ - images/red_body100.gif
64
+ - images/red_body110.gif
65
+ - images/red_body120.gif
66
+ - images/red_body130.gif
67
+ - images/red_body140.gif
68
+ - images/red_body150.gif
69
+ - images/red_body160.gif
70
+ - images/red_body170.gif
71
+ - images/red_body180.gif
72
+ - images/red_body190.gif
73
+ - images/red_body200.gif
74
+ - images/red_body210.gif
75
+ - images/red_body220.gif
76
+ - images/red_body230.gif
77
+ - images/red_body240.gif
78
+ - images/red_body250.gif
79
+ - images/red_body260.gif
80
+ - images/red_body270.gif
81
+ - images/red_body280.gif
82
+ - images/red_body290.gif
83
+ - images/red_body300.gif
84
+ - images/red_body310.gif
85
+ - images/red_body320.gif
86
+ - images/red_body330.gif
87
+ - images/red_body340.gif
88
+ - images/red_body350.gif
89
+ - images/red_radar000.gif
90
+ - images/red_radar010.gif
91
+ - images/red_radar020.gif
92
+ - images/red_radar030.gif
93
+ - images/red_radar040.gif
94
+ - images/red_radar050.gif
95
+ - images/red_radar060.gif
96
+ - images/red_radar070.gif
97
+ - images/red_radar080.gif
98
+ - images/red_radar090.gif
99
+ - images/red_radar100.gif
100
+ - images/red_radar110.gif
101
+ - images/red_radar120.gif
102
+ - images/red_radar130.gif
103
+ - images/red_radar140.gif
104
+ - images/red_radar150.gif
105
+ - images/red_radar160.gif
106
+ - images/red_radar170.gif
107
+ - images/red_radar180.gif
108
+ - images/red_radar190.gif
109
+ - images/red_radar200.gif
110
+ - images/red_radar210.gif
111
+ - images/red_radar220.gif
112
+ - images/red_radar230.gif
113
+ - images/red_radar240.gif
114
+ - images/red_radar250.gif
115
+ - images/red_radar260.gif
116
+ - images/red_radar270.gif
117
+ - images/red_radar280.gif
118
+ - images/red_radar290.gif
119
+ - images/red_radar300.gif
120
+ - images/red_radar310.gif
121
+ - images/red_radar320.gif
122
+ - images/red_radar330.gif
123
+ - images/red_radar340.gif
124
+ - images/red_radar350.gif
125
+ - images/red_turret000.gif
126
+ - images/red_turret010.gif
127
+ - images/red_turret020.gif
128
+ - images/red_turret030.gif
129
+ - images/red_turret040.gif
130
+ - images/red_turret050.gif
131
+ - images/red_turret060.gif
132
+ - images/red_turret070.gif
133
+ - images/red_turret080.gif
134
+ - images/red_turret090.gif
135
+ - images/red_turret100.gif
136
+ - images/red_turret110.gif
137
+ - images/red_turret120.gif
138
+ - images/red_turret130.gif
139
+ - images/red_turret140.gif
140
+ - images/red_turret150.gif
141
+ - images/red_turret160.gif
142
+ - images/red_turret170.gif
143
+ - images/red_turret180.gif
144
+ - images/red_turret190.gif
145
+ - images/red_turret200.gif
146
+ - images/red_turret210.gif
147
+ - images/red_turret220.gif
148
+ - images/red_turret230.gif
149
+ - images/red_turret240.gif
150
+ - images/red_turret250.gif
151
+ - images/red_turret260.gif
152
+ - images/red_turret270.gif
153
+ - images/red_turret280.gif
154
+ - images/red_turret290.gif
155
+ - images/red_turret300.gif
156
+ - images/red_turret310.gif
157
+ - images/red_turret320.gif
158
+ - images/red_turret330.gif
159
+ - images/red_turret340.gif
160
+ - images/red_turret350.gif
161
+ - images/toolbox.gif
162
+ - config/rrobots.yml
163
+ - doc/manual.rdoc
164
+ - doc/manual_fr.rdoc
165
+ - contribs/allbots.rb
166
+ - robots/BillDuck.rb
167
+ - robots/BotOne.rb
168
+ - robots/DuckBill.rb
169
+ - robots/DuckBill04.rb
170
+ - robots/DuckToEndAllDucks.rb
171
+ - robots/EdgeBot.rb
172
+ - robots/HuntingDuck.rb
173
+ - robots/HyperactiveDuck.rb
174
+ - robots/Killer.rb
175
+ - robots/Kite.rb
176
+ - robots/KoDuck.rb
177
+ - robots/LinearShooter.rb
178
+ - robots/LuckyDuck.rb
179
+ - robots/MoxonoM.rb
180
+ - robots/MsgBot.rb
181
+ - robots/NervousDuck.rb
182
+ - robots/Polisher.rb
183
+ - robots/RomBot.rb
184
+ - robots/RoomPainter.rb
185
+ - robots/Rrrkele.rb
186
+ - robots/Seeker.rb
187
+ - robots/ShootingStation.rb
188
+ - robots/SittingDuck.rb
189
+ - robots/SniperDuck.rb
190
+ - robots/WallPainter.rb
191
+ has_rdoc: true
192
+ homepage: http://www.ultragreen.net/projects/rrobots
193
+ licenses: []
194
+
195
+ post_install_message:
196
+ rdoc_options: []
197
+
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: "0"
205
+ version:
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: "0"
211
+ version:
212
+ requirements: []
213
+
214
+ rubyforge_project:
215
+ rubygems_version: 1.3.5
216
+ signing_key:
217
+ specification_version: 3
218
+ summary: Ultragreen RRobots Fork with new features like toolboxes, config file, gemified
219
+ test_files: []
220
+