Skip to content

Instantly share code, notes, and snippets.

@chadbailey59
Created May 6, 2014 00:26
Show Gist options
  • Save chadbailey59/11550679 to your computer and use it in GitHub Desktop.
Save chadbailey59/11550679 to your computer and use it in GitHub Desktop.
class Derpbot9000 < RTanque::Bot::Brain
NAME = 'derpbot9000'
include RTanque::Bot::BrainHelper
def tick!
turn_randomly
command.speed = MAX_BOT_SPEED
command.turret_heading = sensors.turret_heading - 0.1
command.fire(0.1)
end
def turn_randomly
@ticker ||= 0
options = [0.1, 0.0, -0.1]
@offset ||= options.sample
if sensors.ticks > @ticker
# set a new turn direction: left, right, or straight
@offset = options.sample
@ticker = @ticker + rand(120) + 120
end
new_heading = sensors.heading.radians + @offset
command.heading = RTanque::Heading.new(new_heading)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment