Created
December 3, 2013 13:50
-
-
Save slashmili/7769412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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