Skip to content

Instantly share code, notes, and snippets.

@purinkle
Created March 19, 2015 20:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purinkle/d0fc06c77ebaec25bfd0 to your computer and use it in GitHub Desktop.
Save purinkle/d0fc06c77ebaec25bfd0 to your computer and use it in GitHub Desktop.
# -*- 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