Class: Rubots::Strategy
- Inherits:
-
Object
- Object
- Rubots::Strategy
- Defined in:
- lib/rubots/strategy.rb
Direct Known Subclasses
Rubots::Samples::Artillery, Rubots::Samples::Rotator, Rubots::Samples::SittingDuck, Rubots::Samples::TargetFinder
Instance Method Summary collapse
-
#command(me, targets) ⇒ Object
When get_command is out of commands, it calls this, which will queue commands.
-
#get_command(me, targets) ⇒ Object
Called by the Robot to get a command.
-
#initialize(map, me, targets) ⇒ Strategy
constructor
A new instance of Strategy.
- #name ⇒ Object
Constructor Details
#initialize(map, me, targets) ⇒ Strategy
Returns a new instance of Strategy.
3 4 |
# File 'lib/rubots/strategy.rb', line 3 def initialize(map, me, targets) end |
Instance Method Details
#command(me, targets) ⇒ Object
When get_command is out of commands, it calls this, which will queue commands
14 15 16 |
# File 'lib/rubots/strategy.rb', line 14 def command(me, targets) # Implement in subclass end |
#get_command(me, targets) ⇒ Object
Called by the Robot to get a command
7 8 9 10 11 |
# 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 ⇒ Object
18 19 20 |
# File 'lib/rubots/strategy.rb', line 18 def name "Unnamed robot" end |