Skip to content

Instantly share code, notes, and snippets.

View kevinnio's full-sized avatar

Kevin Perez kevinnio

View GitHub Profile
@kevinnio
kevinnio / nivel_1_intermediate_rubywarrior.rb
Created May 7, 2014 20:54
Código del nivel 1, modo Intermediate de RubyWarrior
class Player
def play_turn(warrior)
warrior.walk! warrior.direction_of_stairs
end
end
@kevinnio
kevinnio / nivel_2_intermediate_rubywarrior.rb
Created May 7, 2014 20:56
Código del nivel 2, modo Intermediate de RubyWarrior
class Player
def play_turn(warrior)
direction = warrior.direction_of_stairs
warrior.feel(direction).empty? ? warrior.walk!(direction) : warrior.attack!(direction)
end
end
@kevinnio
kevinnio / nivel_3_intermediate_rubywarrior.rb
Last active August 29, 2015 14:01
Código del nivel 3, modo Intermediate de RubyWarrior
class Player
def initialize
@directions = [:backward, :left, :right, :forward]
end
def play_turn(warrior)
direction = warrior.direction_of_stairs
@directions.each do |d|
return warrior.bind! d if warrior.feel(d).enemy? and d != direction
end
@kevinnio
kevinnio / nivel_4_intermediate_rubywarrior.rb
Created May 7, 2014 23:09
Código del nivel 4, modo Intermediate de Ruby Warrior
class Player
def play_turn(warrior)
@dir = warrior.direction_of_stairs
if not enemies_around(warrior).empty?
warrior.bind! warrior.direction_of enemies_around(warrior).first
else
warrior.feel(@dir).empty? ? warrior.walk!(@dir) : warrior.attack!(@dir)
end
end
@kevinnio
kevinnio / nivel_5_intermediate_rubywarrior.rb
Created May 7, 2014 23:56
Código del nivel 5, modo Intermediate de Ruby Warrior
class Player
def play_turn(warrior)
@units, @enemies, @captives = warrior.listen, warrior.listen.select {|s| s.enemy?}, warrior.listen.select {|s| s.captive?}
[@enemies, @captives].each do |units|
next if units.empty?
act warrior, warrior.direction_of(units.first)
break
end
act warrior, warrior.direction_of_stairs if @units.empty?
end
@kevinnio
kevinnio / nivel_6_intermediate_rubywarrior.rb
Created May 8, 2014 00:01
Código del nivel 6, modo Intermediate de Ruby Warrior
class Player
def play_turn(warrior)
@units, @enemies, @captives = warrior.listen, warrior.listen.select {|s| s.enemy?}, warrior.listen.select {|s| s.captive?}
@hurry_captives = @captives.select {|s| s.ticking?}
[@hurry_captives, @enemies, @captives].each do |units|
next if units.empty?
act warrior, warrior.direction_of(units.first)
break
end
act warrior, warrior.direction_of_stairs if @units.empty?
@kevinnio
kevinnio / nivel_7_intermediate_rubywarrior.rb
Created May 8, 2014 00:08
Código del nivel 7, modo Intermediate de Ruby Warrior
class Player
def play_turn(warrior)
@units = warrior.listen
@enemies = @units.select {|s| s.enemy?}
@captives = @units.select {|s| s.captive?}
@hurry_captives = @captives.select {|s| s.ticking?}
[@hurry_captives, @enemies, @captives].each do |units|
next if units.empty?
act warrior, warrior.direction_of(units.first)
break
@kevinnio
kevinnio / nivel_9_intermediate_rubywarrior.rb
Created May 8, 2014 00:32
Código del nivel 9, modo Intermediate de Ruby Warrior
class Player
def play_turn(warrior)
@units = warrior.listen
@enemies = @units.select {|s| s.enemy?}
@captives = @units.select {|s| s.captive?}
@hurry_captives = @captives.select {|s| s.ticking?}
[@hurry_captives, @enemies, @captives].each do |units|
next if units.empty?
act warrior, warrior.direction_of(units.first)
@kevinnio
kevinnio / nivel_8_intermediate_rubywarrior.rb
Created May 8, 2014 00:34
Código del nivel 8, modo Intermediate de Ruby Warrior
class Player
def play_turn(warrior)
@units = warrior.listen
@enemies = @units.select {|s| s.enemy?}
@captives = @units.select {|s| s.captive?}
@hurry_captives = @captives.select {|s| s.ticking?}
[@hurry_captives, @enemies, @captives].each do |units|
next if units.empty?
act warrior, warrior.direction_of(units.first)
@kevinnio
kevinnio / gist:2de5a8262dafff6482a7
Created January 30, 2015 17:38
composer update -vvv : first time
Reading ./composer.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Reading /home/kevinkdpm/.composer/composer.json
Loading config file /home/kevinkdpm/.composer/composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Loading composer repositories with package information
Downloading https://packagist.org/packages.json