I’ve tried it and it’s really cool and entertaining. The code is also
pretty cool to look at, and it’s got tests and everything.
What is your opinion of it? How far can you go before you have to
actually think?
I’ve tried it and it’s really cool and entertaining. The code is also
pretty cool to look at, and it’s got tests and everything.
What is your opinion of it? How far can you go before you have to
actually think?
That looks really really cool. I’ll have to play with that this weekend.
Thanks!
Oh, definately, this is probably the best way to teach programing.
I tried cloning the latest git but adding
warrior.rest!
to player.rb and running gave:
Welcome to Ruby Warrior
[1] p - beginner - level 1 - score 0
[2] New Profile
Choose profile by typing the number: 1
Starting Level 1
turn 1 -
@ >
./rubywarrior/p-beginner/player.rb:3:in play_turn': undefined methodrest!’ for #<RubyWarrior::Turn:0x7f5f0ced1a58 @action=nil, @senses={}>
(NoMethodError)
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/units/warrior.rb:12:in play_turn' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/units/base.rb:72:inprepare_turn’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/level.rb:50:in play' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/level.rb:50:ineach’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/level.rb:50:in play' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/level.rb:46:intimes’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/level.rb:46:in play' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/game.rb:72:inplay_current_level’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/game.rb:63:in play_normal_mode' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/game.rb:23:instart’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/runner.rb:17:in
`run’
from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/rubywarrior:5
./rubywarrior/p-beginner/player.rb:3:in play_turn': undefined methodrest!’ for #<RubyWarrior::Turn:0x7f5f0ced1a58 @action=nil, @senses={}> (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/units/warrior.rb:12:in `play_turn’
…
What have I missed?
I dunno as I haven’t played with the code yet, but you’re calling rest!
on a Turn, not on the Warrior. Make sure your warrior variable (or
method call result?) is what you think it is.
./rubywarrior/p-beginner/player.rb:3:in play_turn': undefined methodrest!’ for #<RubyWarrior::Turn:0x7f5f0ced1a58 @action=nil,
@senses={}> (NoMethodError) from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/units/warrior.rb:12:in
`play_turn’
… What have I missed?
I dunno as I haven’t played with the code yet, but you’re calling
rest! on a Turn, not on the Warrior. Make sure your warrior variable
(or method call result?) is what you think it is.
Make sure you still have something like:
class Player def play_turn(warrior)
I just used something simple above because the example stuff gave me the
same problem - that is, using:
class Player
def play_turn(warrior)
if warrior.feel.enemy?
warrior.attack!
else
warrior.walk!
end
end
end
results in:
Welcome to Ruby Warrior
[1] p - beginner - level 1 - score 0
[2] New Profile
Choose profile by typing the number: 1
Starting Level 1
turn 1 -
@ >
./rubywarrior/p-beginner/player.rb:3:in play_turn': undefined methodfeel’ for #<RubyWarrior::Turn:0x7f4c176e0680 @action=nil, @senses={}>
(NoMethodError)
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/units/warrior.rb:12:in play_turn' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/units/base.rb:72:inprepare_turn’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/level.rb:50:in play' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/level.rb:50:ineach’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/level.rb:50:in play' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/level.rb:46:intimes’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/level.rb:46:in play' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/game.rb:72:inplay_current_level’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/game.rb:63:in play_normal_mode' from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/../lib/ruby_warrior/game.rb:23:instart’
from
/usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/…/lib/ruby_warrior/runner.rb:17:in
`run’
from /usr/lib/ruby/gems/1.8/gems/ruby-warrior/bin/rubywarrior:5
Not something I was expecting from something that is supposed to help
teach Ruby . .
else
[2] New Profile
Not something I was expecting from something that is supposed to help teach
Ruby . .
Well, what do you have in front of you? nothing, so you just need to
warrior.walk!
You’ll get the feel method later, you don’t need it yet as there is no
enemy. (enemies will be shown on the map)
Not something I was expecting from something that is supposed to help teach
Ruby . .
Well, what do you have in front of you? nothing, so you just need to
warrior.walk!
You’ll get the feel method later, you don’t need it yet as there is no
enemy. (enemies will be shown on the map)
Thanks - I didn’t realise that all the methods were not immediately
available - maybe the script should respond with something nicer than
the ugly error messages in this case?
Thanks - I didn’t realise that all the methods were not immediately
available - maybe the script should respond with something nicer than
the ugly error messages in this case?
That’s a good idea. If I have time, maybe I’ll try to submit a patch…
Or you could directly ask the developer
On Sat, Apr 10, 2010 at 2:45 AM, thunk [email protected] wrote:
Thunk
your threads are fun but I would appreciate if you respected other
threads, not everything can be fun, and you know depending on your
answer I will be treated as a stupid troll feeder or a nice guy, I put
my reputation into your hands, are you going to let me down?
Hahaha, I’ve been studying alot lately and once I finish my tests I’m
definately trying it out, I’ve been with some idea to create a game
where
you program stuff in order to do something but in a way that goes
mainstream(and maybe be a good way to learn how to program).
I’ve tried it and it’s really cool and entertaining. The code is also
pretty cool to look at, and it’s got tests and everything.
What is your opinion of it? How far can you go before you have to
actually think?
Hello guys! I consider RubyWarrior may be useful for learning. A have
reached for 6’th level (as beginner).
Now my code looks as following: http://good.net/_5pJ5Rurvz .
I can’t understand issue: if i call in method:
def roam_to_combat!
debug(“Entering roam_to_combat”)
state = :ws_combat @ini_health = health
debug(@ini_health)
warrior.attack!(cur_dir)
end
then it lacks to execute string “state = :ws_combat”.
But if i call
def roam_to_combat!
debug(“Entering roam_to_combat”)
self.state = :ws_combat # <-- here is difference @ini_health = health
debug(@ini_health)
warrior.attack!(cur_dir)
end
then it executes “state = :ws_combat” normally.
Why it didn’t execute “state =” without “self”?
Is it Ruby’s bug?
I got Ruby 1.8 installed.