Skip to content

Instantly share code, notes, and snippets.

@paulrogers
Last active October 22, 2015 18:52
Show Gist options
  • Save paulrogers/adbab0b52a43579e6f64 to your computer and use it in GitHub Desktop.
Save paulrogers/adbab0b52a43579e6f64 to your computer and use it in GitHub Desktop.
# class MyBot < RTanque::Bot::Brain
# NAME = 'my_bot'
# include RTanque::Bot::BrainHelper
# def tick!
# ## main logic goes here
# # use self.sensors to detect things
# # See http://rubydoc.info/github/awilliams/RTanque/master/RTanque/Bot/Sensors
# # use self.command to control tank
# # See http://rubydoc.info/github/awilliams/RTanque/master/RTanque/Bot/Command
# # self.arena contains the dimensions of the arena
# # See http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Arena
# end
# end
class MyBot < RTanque::Bot::Brain
NAME = 'paul_sohan_bot'
include RTanque::Bot::BrainHelper
# RTanque::Bot::Sensors =
# Struct.new(:ticks, :health, :speed, :position, :heading, :radar, :turret)
def tick!
sensors.ticks # Integer
sensors.health # Float
sensors.position # RTanque::Point
sensors.heading # RTanque::Heading
sensors.speed # Float
sensors.radar_heading # RTanque::Heading
sensors.turret_heading # RTanque::Heading
puts sensors.ticks
direction = (sensors.ticks % 360)
direction = direction * -1 if direction < 180
direction = direction / 360.0
puts "direction is #{direction}"
puts sensors.position
#if sensors.radar.size.nil?
# puts "No enemy found"
command.turret_heading = - Math::PI * direction
command.radar_heading = Math::PI * direction
new_heading = (sensors.position.y == sensors.position.arena.height) ? -(Math::PI / 2) : 0
puts "new heading is #{new_heading}"
command.heading = new_heading
command.speed = 2
#else
sensors.radar.each do |scanned_bot|
# RTanque::Bot::Radar::Reflection
# Reflection(:heading, :distance, :name)
puts scanned_bot.inspect
#command.turret_heading = scanned_bot.heading
#command.fire(3)
#end
end
# command.speed = 0
# command.heading = Math::PI
# command.radar_heading = Math::PI
# command.turret_heading = Math::PI
# command.fire(3)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment