Class: Rubots::Samples::Rotator
- Inherits:
-
Rubots::Strategy
- Object
- Rubots::Strategy
- Rubots::Samples::Rotator
- Defined in:
- lib/rubots/samples/rotator.rb
Overview
Rotates in place direction
Instance Method Summary collapse
- #command(me, targets) ⇒ Object
-
#initialize(map, me, targets) ⇒ Rotator
constructor
A new instance of Rotator.
- #name ⇒ Object
Methods inherited from Rubots::Strategy
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 |
#name ⇒ Object
19 20 21 |
# File 'lib/rubots/samples/rotator.rb', line 19 def name "Rotator" end |