Last active
August 29, 2015 13:56
-
-
Save refiute/9005786 to your computer and use it in GitHub Desktop.
RubyWarrior - https://www.bloc.io/ruby-warrior/#/ を攻略した時のソース
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 | |
def play_turn(warrior) | |
warrior.walk! | |
end | |
end |
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 | |
def play_turn(warrior) | |
if warrior.feel.enemy? then | |
warrior.attack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
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 | |
def initialize | |
@health = 20 | |
@rest_flag = false | |
end | |
def play_turn(warrior) | |
if warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
warrior.walk! :backward | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health | |
elsif warrior.feel.enemy? then | |
warrior.attack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
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
# ruby_warriior_lv3.rb と同じ | |
class Player | |
def initialize | |
@health = 20 | |
@rest_flag = false | |
end | |
def play_turn(warrior) | |
if warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
warrior.walk! :backward | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health | |
elsif warrior.feel.enemy? then | |
warrior.attack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
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 | |
def initialize | |
@health = 20 | |
@rest_flag = false | |
end | |
def play_turn(warrior) | |
if warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
warrior.walk! :backward | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health | |
elsif warrior.feel.captive? | |
warrior.rescue! | |
elsif warrior.feel.enemy? then | |
warrior.attack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
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 | |
def initialize | |
@turn = 0 | |
@health = 20 | |
@movement = :forward | |
@rest_flag = false | |
end | |
def turn | |
@movement = @movement==:forward ? :backward : :forward | |
end | |
def play_turn(warrior) | |
@turn += 1 | |
if @turn == 1 and !warrior.feel(:backward).wall? then | |
turn | |
elsif warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
turn | |
warrior.walk! @movement | |
turn | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health | |
elsif warrior.feel(@movement).wall? | |
turn | |
elsif warrior.feel(@movement).captive? | |
warrior.rescue! @movement | |
elsif warrior.feel(@movement).enemy? then | |
warrior.attack! @movement | |
else | |
warrior.walk! @movement | |
end | |
end | |
end |
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 | |
def initialize | |
@turn = 0 | |
@health = 20 | |
@rest_flag = false | |
end | |
def play_turn(warrior) | |
@turn += 1 | |
if @turn == 1 and !warrior.feel(:backward).wall? then | |
warrior.pivot! | |
elsif warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
warrior.walk! :backward | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health | |
elsif warrior.feel.wall? then | |
warrior.pivot! | |
elsif warrior.feel.captive? then | |
warrior.rescue! | |
elsif warrior.feel.enemy? then | |
warrior.attack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
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 | |
def initialize | |
@health = 20 | |
@turn = 0 | |
@rest_flag = false | |
end | |
def play_turn(warrior) | |
@turn += 1 | |
if @turn == 1 and !warrior.feel(:backward).wall? then | |
warrior.pivot! | |
elsif warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
warrior.walk! :backward | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health! | |
elsif warrior.feel.wall? | |
warrior.pivot! | |
elsif warrior.feel.captive? | |
warrior.rescue! | |
elsif warrior.look[1].captive? or warrior.look[2].captive? | |
warrior.walk! | |
elsif warrior.look[1].enemy? or warrior.look[2].enemy? | |
warrior.shoot! | |
elsif warrior.feel.enemy? | |
warrior.atack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
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 | |
def initialize | |
@health = 20 | |
@turn = 0 | |
@rest_flag = false | |
@can_clear = true | |
end | |
def play_turn(warrior) | |
@turn += 1 | |
if @turn == 1 and !warrior.feel(:backward).wall? then | |
warrior.pivot! | |
elsif warrior.health < 10 or @rest_flag | |
@rest_flag = true | |
if warrior.feel.enemy? or @health > warrior.health then | |
warrior.walk! :backward | |
else | |
warrior.rest! | |
end | |
if warrior.health == 20 then | |
@rest_flag = false | |
else | |
@rest_flag = true | |
end | |
@health = warrior.health | |
elsif warrior.feel.stairs? and @can_clear then | |
@can_clear = false | |
warrior.pivot! | |
elsif warrior.feel.wall? | |
warrior.pivot! | |
elsif warrior.feel.captive? | |
warrior.rescue! | |
elsif warrior.look[1].captive? or warrior.look[2].captive? | |
warrior.walk! | |
elsif warrior.look[1].enemy? or warrior.look[2].enemy? | |
warrior.shoot! | |
elsif warrior.feel.enemy? | |
warrior.atack! | |
else | |
warrior.walk! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment