Created
July 4, 2013 17:38
-
-
Save THEtheChad/5929288 to your computer and use it in GitHub Desktop.
Rtanque bot
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 Homer < RTanque::Bot::Brain | |
NAME = 'Homer' | |
include RTanque::Bot::BrainHelper | |
def tick! | |
skateboard | |
slingshot | |
mmmmmmmmmmmmmmmmmm_donuts | |
if someones_trying_to_steal_my_donut | |
ive_got_you | |
in_my_sites | |
else | |
scanning_the_room | |
end | |
end | |
def someones_trying_to_steal_my_donut | |
@target = nearest_target | |
end | |
def nearest_target | |
sensors.radar.min{ |a,b| a.distance <=> b.distance } | |
end | |
def slingshot | |
command.fire(3) | |
end | |
def skateboard | |
command.speed = MAX_BOT_SPEED | |
end | |
def in_my_sites | |
command.turret_heading = @target.heading | |
end | |
def ive_got_you | |
command.radar_heading = @target.heading | |
end | |
def scanning_the_room | |
command.radar_heading = sensors.radar_heading + MAX_RADAR_ROTATION | |
end | |
def mmmmmmmmmmmmmmmmmm_donuts | |
command.heading = sensors.heading + MAX_BOT_ROTATION | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment