rtanque 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/.gitignore +22 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +34 -0
  4. data/.travis.yml +11 -0
  5. data/.yardopts +4 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.ci +6 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +120 -0
  10. data/Rakefile +1 -0
  11. data/bin/rtanque +108 -0
  12. data/lib/rtanque.rb +40 -0
  13. data/lib/rtanque/arena.rb +8 -0
  14. data/lib/rtanque/bot.rb +117 -0
  15. data/lib/rtanque/bot/brain.rb +50 -0
  16. data/lib/rtanque/bot/brain_helper.rb +23 -0
  17. data/lib/rtanque/bot/command.rb +23 -0
  18. data/lib/rtanque/bot/radar.rb +54 -0
  19. data/lib/rtanque/bot/sensors.rb +33 -0
  20. data/lib/rtanque/bot/turret.rb +14 -0
  21. data/lib/rtanque/configuration.rb +46 -0
  22. data/lib/rtanque/explosion.rb +23 -0
  23. data/lib/rtanque/gui.rb +24 -0
  24. data/lib/rtanque/gui/bot.rb +42 -0
  25. data/lib/rtanque/gui/draw_group.rb +30 -0
  26. data/lib/rtanque/gui/explosion.rb +25 -0
  27. data/lib/rtanque/gui/shell.rb +20 -0
  28. data/lib/rtanque/gui/window.rb +51 -0
  29. data/lib/rtanque/heading.rb +172 -0
  30. data/lib/rtanque/match.rb +67 -0
  31. data/lib/rtanque/match/tick_group.rb +50 -0
  32. data/lib/rtanque/movable.rb +51 -0
  33. data/lib/rtanque/normalized_attr.rb +69 -0
  34. data/lib/rtanque/point.rb +140 -0
  35. data/lib/rtanque/runner.rb +88 -0
  36. data/lib/rtanque/shell.rb +40 -0
  37. data/lib/rtanque/version.rb +3 -0
  38. data/resources/images/body.png +0 -0
  39. data/resources/images/bullet.png +0 -0
  40. data/resources/images/explosions/explosion2-1.png +0 -0
  41. data/resources/images/explosions/explosion2-10.png +0 -0
  42. data/resources/images/explosions/explosion2-11.png +0 -0
  43. data/resources/images/explosions/explosion2-12.png +0 -0
  44. data/resources/images/explosions/explosion2-13.png +0 -0
  45. data/resources/images/explosions/explosion2-14.png +0 -0
  46. data/resources/images/explosions/explosion2-15.png +0 -0
  47. data/resources/images/explosions/explosion2-16.png +0 -0
  48. data/resources/images/explosions/explosion2-17.png +0 -0
  49. data/resources/images/explosions/explosion2-18.png +0 -0
  50. data/resources/images/explosions/explosion2-19.png +0 -0
  51. data/resources/images/explosions/explosion2-2.png +0 -0
  52. data/resources/images/explosions/explosion2-20.png +0 -0
  53. data/resources/images/explosions/explosion2-21.png +0 -0
  54. data/resources/images/explosions/explosion2-22.png +0 -0
  55. data/resources/images/explosions/explosion2-23.png +0 -0
  56. data/resources/images/explosions/explosion2-24.png +0 -0
  57. data/resources/images/explosions/explosion2-25.png +0 -0
  58. data/resources/images/explosions/explosion2-26.png +0 -0
  59. data/resources/images/explosions/explosion2-27.png +0 -0
  60. data/resources/images/explosions/explosion2-28.png +0 -0
  61. data/resources/images/explosions/explosion2-29.png +0 -0
  62. data/resources/images/explosions/explosion2-3.png +0 -0
  63. data/resources/images/explosions/explosion2-30.png +0 -0
  64. data/resources/images/explosions/explosion2-31.png +0 -0
  65. data/resources/images/explosions/explosion2-32.png +0 -0
  66. data/resources/images/explosions/explosion2-33.png +0 -0
  67. data/resources/images/explosions/explosion2-34.png +0 -0
  68. data/resources/images/explosions/explosion2-35.png +0 -0
  69. data/resources/images/explosions/explosion2-36.png +0 -0
  70. data/resources/images/explosions/explosion2-37.png +0 -0
  71. data/resources/images/explosions/explosion2-38.png +0 -0
  72. data/resources/images/explosions/explosion2-39.png +0 -0
  73. data/resources/images/explosions/explosion2-4.png +0 -0
  74. data/resources/images/explosions/explosion2-40.png +0 -0
  75. data/resources/images/explosions/explosion2-41.png +0 -0
  76. data/resources/images/explosions/explosion2-42.png +0 -0
  77. data/resources/images/explosions/explosion2-43.png +0 -0
  78. data/resources/images/explosions/explosion2-44.png +0 -0
  79. data/resources/images/explosions/explosion2-45.png +0 -0
  80. data/resources/images/explosions/explosion2-46.png +0 -0
  81. data/resources/images/explosions/explosion2-47.png +0 -0
  82. data/resources/images/explosions/explosion2-48.png +0 -0
  83. data/resources/images/explosions/explosion2-49.png +0 -0
  84. data/resources/images/explosions/explosion2-5.png +0 -0
  85. data/resources/images/explosions/explosion2-50.png +0 -0
  86. data/resources/images/explosions/explosion2-51.png +0 -0
  87. data/resources/images/explosions/explosion2-52.png +0 -0
  88. data/resources/images/explosions/explosion2-53.png +0 -0
  89. data/resources/images/explosions/explosion2-54.png +0 -0
  90. data/resources/images/explosions/explosion2-55.png +0 -0
  91. data/resources/images/explosions/explosion2-56.png +0 -0
  92. data/resources/images/explosions/explosion2-57.png +0 -0
  93. data/resources/images/explosions/explosion2-58.png +0 -0
  94. data/resources/images/explosions/explosion2-59.png +0 -0
  95. data/resources/images/explosions/explosion2-6.png +0 -0
  96. data/resources/images/explosions/explosion2-60.png +0 -0
  97. data/resources/images/explosions/explosion2-61.png +0 -0
  98. data/resources/images/explosions/explosion2-62.png +0 -0
  99. data/resources/images/explosions/explosion2-63.png +0 -0
  100. data/resources/images/explosions/explosion2-64.png +0 -0
  101. data/resources/images/explosions/explosion2-65.png +0 -0
  102. data/resources/images/explosions/explosion2-66.png +0 -0
  103. data/resources/images/explosions/explosion2-67.png +0 -0
  104. data/resources/images/explosions/explosion2-68.png +0 -0
  105. data/resources/images/explosions/explosion2-69.png +0 -0
  106. data/resources/images/explosions/explosion2-7.png +0 -0
  107. data/resources/images/explosions/explosion2-70.png +0 -0
  108. data/resources/images/explosions/explosion2-71.png +0 -0
  109. data/resources/images/explosions/explosion2-8.png +0 -0
  110. data/resources/images/explosions/explosion2-9.png +0 -0
  111. data/resources/images/grass.png +0 -0
  112. data/resources/images/radar.png +0 -0
  113. data/resources/images/turret.png +0 -0
  114. data/rtanque.gemspec +33 -0
  115. data/sample_bots/camper.rb +79 -0
  116. data/sample_bots/keyboard.rb +50 -0
  117. data/sample_bots/seek_and_destroy.rb +51 -0
  118. data/screenshots/battle_1.png +0 -0
  119. data/screenshots/battle_2.png +0 -0
  120. data/spec/rtanque/bot_spec.rb +239 -0
  121. data/spec/rtanque/heading_spec.rb +279 -0
  122. data/spec/rtanque/match_spec.rb +36 -0
  123. data/spec/rtanque/normalized_attr_spec.rb +90 -0
  124. data/spec/rtanque/point_spec.rb +196 -0
  125. data/spec/rtanque/radar_spec.rb +87 -0
  126. data/spec/rtanque/shell_spec.rb +35 -0
  127. data/spec/rtanque_spec.rb +6 -0
  128. data/spec/spec_helper.rb +51 -0
  129. data/templates/bot.erb +11 -0
  130. metadata +310 -0
@@ -0,0 +1,6 @@
1
+ require "spec_helper"
2
+
3
+ describe RTanque do
4
+ let(:bot){ RTanque::Bot.new(@arena, TestBrain) }
5
+ # TODO: integration tests
6
+ end
@@ -0,0 +1,51 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'rtanque'
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ # Run specs in random order to surface order dependencies. If you find an
14
+ # order dependency and want to debug it, you can fix the order by providing
15
+ # the seed, which is printed after each run.
16
+ # --seed 1234
17
+ config.order = 'random'
18
+
19
+ config.expect_with :rspec do |c|
20
+ # disable the `should` syntax
21
+ c.syntax = :expect
22
+ end
23
+
24
+ config.before(:all) do
25
+ @arena = RTanque::Arena.new(100, 100)
26
+ RTanque::Configuration.config do
27
+ raise_brain_tick_errors false # errors should be correctly captured
28
+ end
29
+ end
30
+
31
+ module BrainHelper
32
+ def on_brain_tick!(&block)
33
+ Class.new(RTanque::Bot::Brain).tap do |test_brain|
34
+ test_brain.send(:define_method, :tick!, &block)
35
+ end
36
+ end
37
+
38
+ def brain_bot(&tick)
39
+ RTanque::Bot.new(@arena, on_brain_tick!(&tick))
40
+ end
41
+ end
42
+ config.include BrainHelper
43
+
44
+ module BotHelper
45
+ def mockbot(x = 0, y = 0, name = 'testbot')
46
+ double('bot', :position => RTanque::Point.new(x, y, @arena), :name => name, :arena => @arena)
47
+ end
48
+ end
49
+
50
+ config.include BotHelper
51
+ end
data/templates/bot.erb ADDED
@@ -0,0 +1,11 @@
1
+ class <%= @bot_class_name %> < RTanque::Bot::Brain
2
+ NAME = '<%= @bot_name %>'
3
+ include RTanque::Bot::BrainHelper
4
+
5
+ def tick!
6
+ ## main logic goes here
7
+ # use self.sensors to detect things
8
+ # use self.command to control tank
9
+ # self.arena contains the dimensions of the arena
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,310 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtanque
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Williams
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gosu
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.7.45
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.45
30
+ - !ruby/object:Gem::Dependency
31
+ name: configuration
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: octokit
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.23.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.23.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: thor
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.17.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.17.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.13.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.13.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-mocks
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.13.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 2.13.0
126
+ description: ! 'RTanque is a game for programmers. Players program the brain of a
127
+ tank and then send their tank+brain into battle with other tanks. All tanks are
128
+ otherwise equal.
129
+
130
+
131
+ Rules of the game are simple: Last bot standing wins. Gameplay is also pretty simple.
132
+ Each tank has a base, turret and radar, each of which rotate independently. The
133
+ base moves the tank, the turret has a gun mounted to it which can fire at other
134
+ tanks, and the radar detects other tanks in its field of vision.
135
+
136
+
137
+ Have fun competing against friends'' tanks or the sample ones included. Maybe you''ll
138
+ start a small league at your local Ruby meetup.'
139
+ email:
140
+ - pwnfactory@gmail.com
141
+ executables:
142
+ - rtanque
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - .gitignore
147
+ - .rspec
148
+ - .rvmrc
149
+ - .travis.yml
150
+ - .yardopts
151
+ - Gemfile
152
+ - Gemfile.ci
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - bin/rtanque
157
+ - lib/rtanque.rb
158
+ - lib/rtanque/arena.rb
159
+ - lib/rtanque/bot.rb
160
+ - lib/rtanque/bot/brain.rb
161
+ - lib/rtanque/bot/brain_helper.rb
162
+ - lib/rtanque/bot/command.rb
163
+ - lib/rtanque/bot/radar.rb
164
+ - lib/rtanque/bot/sensors.rb
165
+ - lib/rtanque/bot/turret.rb
166
+ - lib/rtanque/configuration.rb
167
+ - lib/rtanque/explosion.rb
168
+ - lib/rtanque/gui.rb
169
+ - lib/rtanque/gui/bot.rb
170
+ - lib/rtanque/gui/draw_group.rb
171
+ - lib/rtanque/gui/explosion.rb
172
+ - lib/rtanque/gui/shell.rb
173
+ - lib/rtanque/gui/window.rb
174
+ - lib/rtanque/heading.rb
175
+ - lib/rtanque/match.rb
176
+ - lib/rtanque/match/tick_group.rb
177
+ - lib/rtanque/movable.rb
178
+ - lib/rtanque/normalized_attr.rb
179
+ - lib/rtanque/point.rb
180
+ - lib/rtanque/runner.rb
181
+ - lib/rtanque/shell.rb
182
+ - lib/rtanque/version.rb
183
+ - resources/images/body.png
184
+ - resources/images/bullet.png
185
+ - resources/images/explosions/explosion2-1.png
186
+ - resources/images/explosions/explosion2-10.png
187
+ - resources/images/explosions/explosion2-11.png
188
+ - resources/images/explosions/explosion2-12.png
189
+ - resources/images/explosions/explosion2-13.png
190
+ - resources/images/explosions/explosion2-14.png
191
+ - resources/images/explosions/explosion2-15.png
192
+ - resources/images/explosions/explosion2-16.png
193
+ - resources/images/explosions/explosion2-17.png
194
+ - resources/images/explosions/explosion2-18.png
195
+ - resources/images/explosions/explosion2-19.png
196
+ - resources/images/explosions/explosion2-2.png
197
+ - resources/images/explosions/explosion2-20.png
198
+ - resources/images/explosions/explosion2-21.png
199
+ - resources/images/explosions/explosion2-22.png
200
+ - resources/images/explosions/explosion2-23.png
201
+ - resources/images/explosions/explosion2-24.png
202
+ - resources/images/explosions/explosion2-25.png
203
+ - resources/images/explosions/explosion2-26.png
204
+ - resources/images/explosions/explosion2-27.png
205
+ - resources/images/explosions/explosion2-28.png
206
+ - resources/images/explosions/explosion2-29.png
207
+ - resources/images/explosions/explosion2-3.png
208
+ - resources/images/explosions/explosion2-30.png
209
+ - resources/images/explosions/explosion2-31.png
210
+ - resources/images/explosions/explosion2-32.png
211
+ - resources/images/explosions/explosion2-33.png
212
+ - resources/images/explosions/explosion2-34.png
213
+ - resources/images/explosions/explosion2-35.png
214
+ - resources/images/explosions/explosion2-36.png
215
+ - resources/images/explosions/explosion2-37.png
216
+ - resources/images/explosions/explosion2-38.png
217
+ - resources/images/explosions/explosion2-39.png
218
+ - resources/images/explosions/explosion2-4.png
219
+ - resources/images/explosions/explosion2-40.png
220
+ - resources/images/explosions/explosion2-41.png
221
+ - resources/images/explosions/explosion2-42.png
222
+ - resources/images/explosions/explosion2-43.png
223
+ - resources/images/explosions/explosion2-44.png
224
+ - resources/images/explosions/explosion2-45.png
225
+ - resources/images/explosions/explosion2-46.png
226
+ - resources/images/explosions/explosion2-47.png
227
+ - resources/images/explosions/explosion2-48.png
228
+ - resources/images/explosions/explosion2-49.png
229
+ - resources/images/explosions/explosion2-5.png
230
+ - resources/images/explosions/explosion2-50.png
231
+ - resources/images/explosions/explosion2-51.png
232
+ - resources/images/explosions/explosion2-52.png
233
+ - resources/images/explosions/explosion2-53.png
234
+ - resources/images/explosions/explosion2-54.png
235
+ - resources/images/explosions/explosion2-55.png
236
+ - resources/images/explosions/explosion2-56.png
237
+ - resources/images/explosions/explosion2-57.png
238
+ - resources/images/explosions/explosion2-58.png
239
+ - resources/images/explosions/explosion2-59.png
240
+ - resources/images/explosions/explosion2-6.png
241
+ - resources/images/explosions/explosion2-60.png
242
+ - resources/images/explosions/explosion2-61.png
243
+ - resources/images/explosions/explosion2-62.png
244
+ - resources/images/explosions/explosion2-63.png
245
+ - resources/images/explosions/explosion2-64.png
246
+ - resources/images/explosions/explosion2-65.png
247
+ - resources/images/explosions/explosion2-66.png
248
+ - resources/images/explosions/explosion2-67.png
249
+ - resources/images/explosions/explosion2-68.png
250
+ - resources/images/explosions/explosion2-69.png
251
+ - resources/images/explosions/explosion2-7.png
252
+ - resources/images/explosions/explosion2-70.png
253
+ - resources/images/explosions/explosion2-71.png
254
+ - resources/images/explosions/explosion2-8.png
255
+ - resources/images/explosions/explosion2-9.png
256
+ - resources/images/grass.png
257
+ - resources/images/radar.png
258
+ - resources/images/turret.png
259
+ - rtanque.gemspec
260
+ - sample_bots/camper.rb
261
+ - sample_bots/keyboard.rb
262
+ - sample_bots/seek_and_destroy.rb
263
+ - screenshots/battle_1.png
264
+ - screenshots/battle_2.png
265
+ - spec/rtanque/bot_spec.rb
266
+ - spec/rtanque/heading_spec.rb
267
+ - spec/rtanque/match_spec.rb
268
+ - spec/rtanque/normalized_attr_spec.rb
269
+ - spec/rtanque/point_spec.rb
270
+ - spec/rtanque/radar_spec.rb
271
+ - spec/rtanque/shell_spec.rb
272
+ - spec/rtanque_spec.rb
273
+ - spec/spec_helper.rb
274
+ - templates/bot.erb
275
+ homepage: https://github.com/awilliams/RTanque
276
+ licenses:
277
+ - MIT
278
+ post_install_message:
279
+ rdoc_options: []
280
+ require_paths:
281
+ - lib
282
+ required_ruby_version: !ruby/object:Gem::Requirement
283
+ none: false
284
+ requirements:
285
+ - - ! '>='
286
+ - !ruby/object:Gem::Version
287
+ version: '0'
288
+ required_rubygems_version: !ruby/object:Gem::Requirement
289
+ none: false
290
+ requirements:
291
+ - - ! '>='
292
+ - !ruby/object:Gem::Version
293
+ version: '0'
294
+ requirements: []
295
+ rubyforge_project:
296
+ rubygems_version: 1.8.25
297
+ signing_key:
298
+ specification_version: 3
299
+ summary: RTanque is a game for programmers. Players program the brain of a tank and
300
+ then send their tank into battle against other tanks.
301
+ test_files:
302
+ - spec/rtanque/bot_spec.rb
303
+ - spec/rtanque/heading_spec.rb
304
+ - spec/rtanque/match_spec.rb
305
+ - spec/rtanque/normalized_attr_spec.rb
306
+ - spec/rtanque/point_spec.rb
307
+ - spec/rtanque/radar_spec.rb
308
+ - spec/rtanque/shell_spec.rb
309
+ - spec/rtanque_spec.rb
310
+ - spec/spec_helper.rb