3 ms·
This should win every level (given enough tries): def play_turn(warrior) m = warrior.methods.grep(/.!$/).sample warrior.send(m, *([nil, :backward].sa
by epidemian 13y ago
This should win every level (given enough tries):
def play_turn(warrior)
m = warrior.methods.grep(/.!$/).sample
warrior.send(m, *([nil, :backward].sample if m != :rest!))
end
(that sucker of :rest! that doesn't accept a direction argument!)
It's kind of amusing to see the warrior do random stuff like shooting arrows backwards and pivoting back in the worst possible moments. Too bad that Run button repeats the same movements if you didn't edit the source code somehow.
Great game and concept BTW!
- aperley 13y agoThe sandbox probably always initializes with the same random seed.
- epidemian 13y agoNo, it seems to be a client-side thing. If no edit was made in the code editor since last run it doesn't make the request to https://www.bloc.io/api/v1/ruby_warrior_players/:id https://www.bloc.io/api/v1/ruby_warrior_players/:id (which seems to be the one that returns the warrior and enemy movements). Repeating the same request in cURL multiple times does return different results.
- matthuggins 13y agoHaha, I didn't play long enough to realize all the methods ended with a bang, this is awesome.