rrobots
Home
Rules
Examples
Screenshots
Download
Forum
Rubyforge

Examples


Well, I'm still here.
But I don't know for how long.
That's as much certainty as anyone can give me.
But I've got some good news: I no longer have any fear of death.
But... I am in a pretty lonely place.
[Chloe]

These bots wan't be around for long if matched against 'real' bots, but they are quite explanatory:

NervousDuck:
require 'robot'

class NervousDuck
  include Robot

  def tick events
    turn_radar 1 if time == 0
    turn_gun 30 if time < 3
    accelerate 1
    turn 2
    fire 3 unless events['robot_scanned'].empty?
  end
end

SittingDuck:
require 'robot'
class SittingDuck
  include Robot
  def tick events
   turn_radar 5 if time == 0
    fire 3 unless events['robot_scanned'].empty?
    turn_gun 10  

    @last_hit = time unless events['got_hit'].empty?
    if @last_hit && time - @last_hit < 20
      accelerate(1)
    else
      stop   
    end
  end
end