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