Skip to content

Instantly share code, notes, and snippets.

@timuruski
Created July 9, 2014 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timuruski/5a7d88c41c85237fe3d8 to your computer and use it in GitHub Desktop.
Save timuruski/5a7d88c41c85237fe3d8 to your computer and use it in GitHub Desktop.
class TanksForAllTheFish < RTanque::Bot::Brain
NAME = 'Tanks For All the Fish'
MAX_RANGE = 400.0
include RTanque::Bot::BrainHelper
def tick!
if targets_nearby?
# command.speed = 2.0
# command.heading = Random.rand(-1.0..1.0)
target = sensors.radar.sort_by(&:distance).first
command.radar_heading = target.heading
command.turret_heading = target.heading
command.fire 1
else
command.radar_heading = sensors.radar_heading + 0.2
end
# command.heading = sensors.heading - 0.10
# command.turret_heading = sensors.turret_heading + 0.10
# command.turret_heading = sensors.radar.first.heading
end
def targets_nearby?
sensors.radar.any? { |target|
target.distance < 500.0
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment