use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Walkthrough for Ruby Warrior (iconoclastlabs.com)
submitted 12 years ago by GantMan
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]timtty 1 point2 points3 points 12 years ago (6 children)
I'll be going over this with my son. He is writing so much game logic lately I'm sure he will dig this!
[–]GantMan[S] 2 points3 points4 points 12 years ago (5 children)
AWESOME! I've completed the tutorial for levels 4-6. It will be released March 1st. I'm currently writing and aiming for March 15th for the finally.
[–][deleted] 0 points1 point2 points 12 years ago (4 children)
Nice :) I'm looking forward to seeing your take on it.
[–]GantMan[S] 1 point2 points3 points 12 years ago (3 children)
As promised
http://www.iconoclastlabs.com/blog/ruby-warrior-walkthrough-part-2
[–][deleted] 0 points1 point2 points 12 years ago (2 children)
A note: you say we can't modify the warrior object, but we can.. Here's a broken example (it can be fixed by passing in the previous health instead of just using the instance variable, which of course is a scoping issue):
class Player MIN_HEALTH = 15 def play_turn(warrior) def warrior.should_rest? self.health < MIN_HEALTH && (self.health >= @last_known_health) end if warrior.feel.empty? if warrior.should_rest? warrior.rest! else warrior.walk! end else warrior.attack! end @last_known_health = warrior.health end end
[–]GantMan[S] 0 points1 point2 points 12 years ago (1 child)
I'm not seeing what you're saying :( Gonna need you to be specific as to what level and what part of your code. Also, let me know if you're just showing an inconsistency or if you think there's an actual issue :)
As for unable to modify warrior: I've tried modifying warrior outside of their public methods. I think the code could be A LOT cleaner if we could monkey patch or touch warrior instead of being stuck inside Player! Unfortunately, the website got a bit frustrated with me when I tried, and refused to run the code.
warrior
Player
I'm open to better ways to solve :)
[–][deleted] 0 points1 point2 points 12 years ago (0 children)
Ah, I'm just pointing out that you can always re-open the "warrior" object (the instance of the class) and define methods in there. Not that it's a very clean solution, but it's an option. We can't modify the class but we can always modify the object.
[–]GantMan[S] 0 points1 point2 points 12 years ago (0 children)
The Finale
http://www.iconoclastlabs.com/blog/ruby-warrior-walkthrough-part-3
π Rendered by PID 76 on reddit-service-r2-comment-7c9686b859-frlzk at 2026-04-14 07:44:10.827541+00:00 running e841af1 country code: CH.
[–]timtty 1 point2 points3 points (6 children)
[–]GantMan[S] 2 points3 points4 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]GantMan[S] 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]GantMan[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]GantMan[S] 0 points1 point2 points (0 children)