Created
March 19, 2015 20:54
-
-
Save purinkle/d0fc06c77ebaec25bfd0 to your computer and use it in GitHub Desktop.
This file contains 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
# -*- encoding: utf-8 -*- | |
# Keyboard: Sample Bot | |
# | |
# Special bot controlled with the keyboard | |
# | |
# Controls: | |
# w drive forward | |
# s drive backwards | |
# a rotate left | |
# d rotate right | |
# | |
# ↑ fire powerful shot | |
# ↓ fire week shot | |
# ← rotate turret left | |
# → rotate turret right | |
class RTanque::Bot | |
# def dead? | |
# if self.name != 'Barabbas!' | |
# true | |
# end | |
# end | |
end | |
class Barabbas < RTanque::Bot::Brain | |
include RTanque::Bot::BrainHelper | |
NAME = 'Barabbas!' | |
def tick! | |
if sensors.position.on_wall? | |
command.heading = sensors.heading + RTanque::Heading::HALF_ANGLE | |
end | |
command.radar_heading = sensors.radar_heading + MAX_RADAR_ROTATION | |
command.speed = 1 | |
if lock = sensors.radar.first | |
command.heading = lock.heading | |
command.radar_heading = lock.heading | |
command.turret_heading = lock.heading | |
command.speed = MAX_BOT_SPEED | |
command.fire(MAX_FIRE_POWER) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment