Skip to content

Instantly share code, notes, and snippets.

@slashmili
Created December 3, 2013 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slashmili/7769412 to your computer and use it in GitHub Desktop.
Save slashmili/7769412 to your computer and use it in GitHub Desktop.
class Meeow < RTanque::Bot::Brain
NAME = 'meeow'
include RTanque::Bot::BrainHelper
@health = 100.00
def tick!
command.heading = sensors.heading + Math::PI/rand
target = sensors.radar.first
if target and target[:name] != NAME
command.turret_heading = target[:heading]
command.speed = 3
command.fire(3)
case target[:distance].to_i
when 1..200
command.fire(5)
when 201..400
command.fire(3)
else
command.fire(2)
end
else
command.radar_heading = sensors.radar_heading + Math::PI/2
command.speed = rand * 100
end
if sensors.health.to_f < @health.to_f
escape!
end
command.speed = MAX_BOT_SPEED
@health = sensors.health
end
def escape!
command.speed = MAX_BOT_SPEED
command.heading = sensors.heading + Math::PI/rand
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment