Skip to content

Instantly share code, notes, and snippets.

@jimmynguyc
Created August 2, 2017 05:40
Show Gist options
  • Save jimmynguyc/3ff1d98cccaa5de1b471bc80bcd735ea to your computer and use it in GitHub Desktop.
Save jimmynguyc/3ff1d98cccaa5de1b471bc80bcd735ea to your computer and use it in GitHub Desktop.
RTRT#42
class JimmyBot < RTanque::Bot::Brain
NAME = 'jimmy_bot'
include RTanque::Bot::BrainHelper
def tick!
@current_heading ||= nil
@current_turret_heading ||= nil
command.speed = 3.0
command.heading = sensors.radar_heading + 10.0
command.radar_heading = sensors.radar_heading + 10.0
command.turret_heading = sensors.turret_heading + 10.0
command.fire(1.0)
# reset_target_heading_if_there_already
# move_away_from_wall
#
# first_target = sensors.radar.first
# @current_turret_heading = first_target&.heading if first_target&.heading
# command.fire(10)
end
def reset_target_heading_if_there_already
@current_heading = nil if @current_heading == sensors.heading
end
def move_away_from_wall
if sensors.position.on_wall?
direction = [-1, 1].sample
@current_heading ||= sensors.heading + (direction * RTanque::Heading.new(Math::PI * rand()))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment