Class: Rubots::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/rubots/strategy.rb

Instance Method Summary collapse

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

#nameObject



18
19
20
# File 'lib/rubots/strategy.rb', line 18

def name
  "Unnamed robot"
end