Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

FYI for confused:

  * you face 'forward', which is to the right.
    .walk! or .walk!(:forward) is what you want until later.
  * you can feel walls: .feel.wall?
  * you can print: p "Feels: #{warrior.feel}"
  * add this to the bottom of your file to get .archer? and .wizard? methods on look:
    class RubyWarrior::Space
      def archer?
        self.unit.kind_of? RubyWarrior::Units::Archer
      end
      def wizard?
        self.unit.kind_of? RubyWarrior::Units::Wizard
      end
    end
Thanks for the original monkeypatch go to numle at http://news.ycombinator.com/item?id=3435382

It's beatable w/o hand-coding each action - I ended with a fairly-general setup that only took a couple changed lines to solve the last task (a should_shoot? method, basically). But the 'course' as a whole needs a LOT of work. And better documentation. And fixes for the missing methods. And a better progression - if you don't set up something fairly flexible early on, you'll be re-writing a lot each time; the steps don't encourage you to generalize very well. And / or hints as to how to design something good to do this - there are absolutely no suggestions, no learning, just 'tips' that tell you half the API available to you.

If anyone wants a cheat-sheet for my setup for the end: https://gist.github.com/1574167 though it was tweaked at each level slightly, and grew into that. Definitely not my best work, but it works.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: