Class: Rubots::Samples::Rotator

Inherits:
Rubots::Strategy show all
Defined in:
lib/rubots/samples/rotator.rb

Overview

Rotates in place direction

Instance Method Summary collapse

Methods inherited from Rubots::Strategy

#get_command

Constructor Details

#initialize(map, me, targets) ⇒ Rotator

Returns a new instance of Rotator.



5
6
7
# File 'lib/rubots/samples/rotator.rb', line 5

def initialize(map, me, targets)
  @direction = :left
end

Instance Method Details

#command(me, targets) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/rubots/samples/rotator.rb', line 9

def command(me, targets)
  if @direction == :left
    @direction = :right if me.angle == 270
    rotate_to 270
  else
    @direction = :left if me.angle == 89
    rotate_to 89
  end
end

#nameObject



19
20
21
# File 'lib/rubots/samples/rotator.rb', line 19

def name
  "Rotator"
end