Skip to content

Instantly share code, notes, and snippets.

@johndel
Created March 24, 2013 13:59
Show Gist options
  • Save johndel/5232077 to your computer and use it in GitHub Desktop.
Save johndel/5232077 to your computer and use it in GitHub Desktop.
Test tank bot for RTanque. Still baby steps :)
class Baby < RTanque::Bot::Brain
NAME = 'baby'
include RTanque::Bot::BrainHelper
def tick!
test_sensors
if sensors.position.on_left_wall?
command.speed = 3
command.heading = Math::PI
command.radar_heading = Math::PI
command.turret_heading = Math::PI
command.fire(3000000000)
else
"eftase"
end
end
end
def test_sensors
p "sensor ticks: #{sensors.ticks}" # Integer
p "sensor health: #{sensors.health}" # Float
p "sensor position: #{sensors.position}" # RTanque::Point
p "sensor heading: #{sensors.heading.inspect}" # RTanque::Heading
p "sensor speed: #{sensors.speed}" # Float
p "sensor radar: #{sensors.radar_heading}" # RTanque::Heading
p "sensor turret: #{sensors.turret_heading}" # RTanque::Heading
#sensors.radar.each do |scanned_bot|
# p scanned_bot
# scanned_bot: RTanque::Bot::Radar::Reflection
# Reflection(:heading, :distance, :name)
#end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment