Created
July 28, 2013 12:05
-
-
Save Bondrake/6098344 to your computer and use it in GitHub Desktop.
My RubyWarrrior level 9 (https://www.bloc.io/ruby-warrior/#/warriors/10954/levels/9) solution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
attr_accessor :started, :firstkill | |
def play_turn(warrior) | |
if not @started | |
@started = true | |
warrior.pivot! | |
elsif warrior.look.select{|space| space.enemy?}.length > 0 | |
warrior.shoot! | |
elsif warrior.look.select{|space| space.enemy?}.length == 0 and not @firstkill | |
@firstkill = true | |
warrior.pivot! | |
elsif warrior.feel.captive? | |
warrior.rescue! | |
elsif warrior.feel.wall? | |
warrior.pivot! | |
else | |
warrior.walk! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment