Created
July 22, 2015 01:36
-
-
Save timuruski/3efe4601f2825179dc90 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
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