I, Developer


My RTanque bot

Written by John Moses on June 30, 2013

KCRuby is running a RTanque contest right now. I heard about this when Wes Garrison gave a presentation on Ruby at Cerner’s internal tech conference and gave a plug to KCRuby.

RTanque

RTanque is a tank game where you create your own tank (a bot) and target and shoot other tanks. It is based on Robotwar that is back from the 1970s. The underlying framework for RTanque is written in Ruby and uses the Gosu library , a 2d game platform that is available for IOS and soon Android. Your bots are written in Ruby and look like this:

 1 class Moses < RTanque::Bot::Brain
 2   NAME = 'Moses'
 3   include RTanque::Bot::BrainHelper
 4 
 5   TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 1.0
 6   
 7   def tick!
 8     self.evade
 9     if(self.nearest_target)
10       target = nearest_target
11       kill(target)
12     else
13       scan
14     end
15   end
16 
17   def evade
18     command.speed = MAX_BOT_SPEED
19     command.heading = sensors.heading + 0.02
20   end
21 
22   def kill(target)
23     self.command.radar_heading = target.heading
24     self.command.turret_heading = target.heading
25     if self.sensors.turret_heading.delta(target.heading).abs < TURRET_FIRE_RANGE
26       self.command.fire(MAX_FIRE_POWER)
27     end
28   end
29 
30   def nearest_target
31     self.sensors.radar.min { |a,b| a.distance <=> b.distance }
32   end
33 
34   def scan
35     self.command.radar_heading = self.sensors.radar_heading + MAX_RADAR_ROTATION
36   end
37 end

The RTanque repo has instructions on setting the game up. You will need version 1.9.2 of Ruby or higher. By default Mac has 1.8.7 installed, so you will have to use RVM to get it going. Here is a screenshot of the actual game in action.