class Rubots::Strategy
Public Class Methods
new(map, me, targets)
click to toggle source
# File lib/rubots/strategy.rb, line 3 def initialize(map, me, targets) end
Public Instance Methods
command(me, targets)
click to toggle source
When get_command
is out of commands, it calls this, which will queue commands
# File lib/rubots/strategy.rb, line 14 def command(me, targets) # Implement in subclass end
get_command(me, targets)
click to toggle source
Called by the Robot
to get a command
# File lib/rubots/strategy.rb, line 7 def get_command(me, targets) @command_queue ||= [] command(me, targets) if @command_queue.empty? @command_queue.shift || Command::DoNothing.new end
name()
click to toggle source
# File lib/rubots/strategy.rb, line 18 def name "Unnamed robot" end
Protected Instance Methods
do_nothing()
click to toggle source
# File lib/rubots/strategy.rb, line 40 def do_nothing @command_queue << Command::DoNothing.new end
fire()
click to toggle source
# File lib/rubots/strategy.rb, line 36 def fire @command_queue << Command::Fire.new end
rotate_gun_to(angle)
click to toggle source
# File lib/rubots/strategy.rb, line 28 def rotate_gun_to(angle) @command_queue << Command::RotateGunTo.new(angle) end
rotate_to(angle)
click to toggle source
# File lib/rubots/strategy.rb, line 24 def rotate_to(angle) @command_queue << Command::RotateTo.new(angle) end
throttle(throttle)
click to toggle source
# File lib/rubots/strategy.rb, line 32 def throttle(throttle) @command_queue << Command::Throttle.new(throttle) end