7 ms·
RubyWarrior - Bloc
- DanielRibeiro 13y agoDiscussion from yesterday: https://news.ycombinator.com/item?id=6110382 https://news.ycombinator.com/item?id=6110382
- joshuak 13y agoAkkk... sound... must... turn... off!!! Ok default sound way too loud, and at least on Safari the little speaker icon in the top left doesn't seem to do anything.
- phoboslab 13y agoVery cool! Proud to see that it's made with ImpactJS[1] (my game engine :)) [1] http://impactjs.com/ http://impactjs.com/
- nathas 13y agoHey! You made ImpactJS? That's very cool, but it's really hard to commit $99 to buy an engine when I can't even try it! It looks super-rad and I'd love to give it a shot, but it's a bit high of a bar for a casual game dev.
- phoboslab 13y agoIf you buy it and don't like it for whatever reason, I can give you a full refund within the first month. That's easier for me to handle than a separate trial license.
- hayksaakian 13y agoI never thought about it that way. Totally stealing that idea.
- oleganza 13y agoWould you accept Bitcoin as a payment? This way you won't lose money on fees during refund.
- lazerwalker 13y agoThat's the same way RubyMotion handles trials; it's great to see other developers adopting the same policy/model. (At least from an end-user standpont. Obviously, you should do your own testing for conversion rate/etc.)
- joemclarke 13y agoThis is awesome, glad to see I can put my ruby skills to good use playing a game!
- ulisesrmzroche 13y agoHow do you tell the character to stop on a space when walking? That monster keeps killing me.
- Hovertruck 13y agoif warrior.feel.enemy? warrior.attack! else warrior.walk! end
- Stratego 13y agoI really like how this manages to introduce some object-oriented principles stealthily while mostly focusing on linear logic. Great job!
- Bluestrike2 13y agoOk, that's kind of fun :).
- marcamillion 13y agoThis is VERY, VERY awesome. As a web-rubyist, this forces me to think in a different way than I normally would. Thank you for making this.
- saebekassebil 13y agoHad to implement a if not warrior return nil end in the play_turn method, to workaround a bug. But other than that, this is great!
- matthuggins 13y agoCool idea, but I don't think it makes sense for there to be both a Player class and a warrior object. They seem like they are/should be one in the same. At the very least, I think behind the scenes, the Player class should look more like this such that the warrior object is always available, and I don't need to pass it around from method to method that I define. e.g.: class Player attr_reader :warrior def initialize(warrior) @warrior = warrior end def play_turn # I can now access `warrior` here or in any other methods I write end end
- snikch 13y agoThe player object would represent the current person playing the game, i.e. you. The warrior represents the object on the screen. The player tells the warrior to take actions, so it makes sense that they're different objects. If there were multiple warriors then your code would no longer make sense, as the control logic would have to be changing the player_instance.warrior object.
- xentronium 13y ago> If there were multiple warriors then your code would no longer make sense, as the control logic would have to be changing the player_instance.warrior object. You need to keep previous state about warrior. E.g. delta health.
- stormbrew 13y agoYou could always just do that.
- hardwaresofton 13y agoFirst couple seconds was wondering where the hell the sound was coming from, rest of the seconds were in awe. Awesome job.
- lostdog 13y agoIt would be great if either `print` or `puts` worked.
- stormbrew 13y agoI have to admit I kind of like that it doesn't. All games have artificial constraints and I feel like keeping you from inspecting too much of the internal state is a reasonable one for this.
- roryokane 13y agoI would like it to debug my own code. You are more aware of the artificial nature of the variables you create, so it’s not as world-breaking to inspect their contents. I saved a `health_change` variable in my code, and decided what to do based on that, but the warrior did the wrong thing. I wanted to see if my variable was being set correctly by printing it each turn, but I couldn’t. My normal tool for understanding what was going on is missing, so I was forced to guess at the bug. I finally got it to work by reversing the order of two terms in my formula for `health_change`, but it was a lot harder to understand what was going on when I could only guess at or simulate the values of the variables.
- deleted 13y ago[deleted]
- gpxl 13y agoThis is a lot of fun. Well done! :)
- mmanfrin 13y agoThis is really great, but it would be even better if it showed where the error it's finding is located. I am getting some weird errors that I can't spot-find.
- jtms 13y agojust play the original: you can use a the text editor of your choice, run in terminal, run with or without animation (nearly instant), and you have full debugging capabilities via puts. Also you get the rogue-like ascii graphics which is the original inspiration for the game.
- hayksaakian 13y agoIt would be cool if the game commited your code to a github repo every level. This way you could see your own progress, and see what solutions other came up with without bugging them.
- rpicard 13y agoMaybe a gist would be appropriate?
- stormbrew 13y agoFeature request: After you've beaten it once let you go through all levels with the same code. Right now it doesn't let you use the features it hasn't told you about.
- nonrecursive 13y agoOh man, I love this! I especially loved this: "warrior.feel.empty?". Allova sudden my RubyWarrior's getting all existential!
- hcarvalhoalves 13y agoHad a lot of fun with my rusty Ruby on this game. Here's my solution to beat level 3 onwards: https://gist.github.com/hcarvalhoalves/6096888 https://gist.github.com/hcarvalhoalves/6096888
- teh_klev 13y agoGreat...but how about turning down the music volume. It's 2:20am here, I opened the page and had a trouser changing moment and woke up the neighbours.
- hayksaakian 13y agoThey should also add the intermediate levels as well https://github.com/ryanb/ruby-warrior/tree/master/towers/intermediate https://github.com/ryanb/ruby-warrior/tree/master/towers/int...
- chrischen 13y agoYou should do a score based on the number of lines of code or characters you have to use.
- twelvechairs 13y agoNicely made. Some frustrations: - while, until, retry (and others?) not allowed. - not being able to see the class of something. Its more ruby style to do 'space.is_a?(Enemy)' than 'space.enemy?'. This would also help to build case statements rather than lots of ifs. - no 'print' or 'puts'. How am I supposed to know what 'look' returns when it never really tells me? - I prefer a single set of rules rather than adding rules as you go. When first I have to use :backward but later this becomes basically redundant as 'pivot' is added, it just makes me frustrated in having to refactor. Same thing for feel/look.
- epidemian 13y agoHehe, i feel identified with some of these frustrations, but i think it's better the way it is. > Its more ruby style to do 'space.is_a?(Enemy)' than 'space.enemy?'. This would also help to build case statements rather than lots of ifs. But that would require to explain that an Enemy class/module (and possibly others) exists. With the presented interface you can/should only care about Warrior and Place. Much simpler. > no 'print' or 'puts'. How am I supposed to know what 'look' returns when it never really tells me? With Ruby's Array methods. Warrior#look returns an Array of at most 3 Places. What else should you know? > I prefer a single set of rules rather than adding rules as you go. When first I have to use :backward but later this becomes basically redundant as 'pivot' is added, it just makes me frustrated in having to refactor. Same thing for feel/look. That happened to me too, but i think it adds to the sense of progress and discovery throughout the game. Like most games, you don't start with all the tools and abilities at your disposal. And you can always ask respond_to? if you want an algorithm that works for all level ;)
- twelvechairs 13y agoNot just to you but to other comments too on the 'is_a?' issue: The basic issue is that this is supposed to be a 'learn ruby' tool but rather than use the ruby class system (a fundamental thing to learn for beginners) to define what is in a Place they have used a custom non-class-based system instead. The result of this is that rather than allowing the user to choose their own way to do things (remembering that ruby is a 'there is more than one way to do things' language), it prescribes certain ways of working (or at least makes them easier than others). I'm not saying everyone should program the way I do but I want to write a simple 'case warrior.feel; when Enemy;x; when Stairs;y; when Empty...' statement which is usually pretty clear and logical ruby but is prevented by this structure.
- epidemian 13y agoThis 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.
- vicks711 13y agoGreat concept.
- soheil 13y agokneel down before the warrior (all levels): https://gist.github.com/syasrebi/6097679 https://gist.github.com/syasrebi/6097679
- patrickdavey 13y agoI aint kneeling before any warrior that shoots captives (level 8!)
- Lord_DeathMatch 13y ago"undefined method `elements' for [:return0]:Array" Marvelous
- jasonm23 13y agodon't use `return` in your functions.
- lcedp 13y agoI made it. It was great!
- StavrosK 13y agoOh goddamn, this is amazing. As someone who hasn't even seen Ruby code before, you could include a bit more on the syntax of conditional/loop constructs (if/while/etc), but it's amazing. I'll send this to my non-programmer friends right now.
- jtms 13y agoI am really disappointed that Ryan Bates is not being STRONGLY credited anywhere on this page... this is just a graphical wrapper on his original creation. https://github.com/ryanb/ruby-warrior https://github.com/ryanb/ruby-warrior
- matthuggins 13y agoHuh, how about that.
- endlessvoid94 13y agoIt's in the footer...
- jtms 13y agoah so it is... was below the fold and I didn't see it :-/
- jimparkins 13y agoAs someone who has never done any development in Ruby. I loved the idea and wanted to use. However what makes it not accessible is that you give no instruction initially on the structure of Ruby syntax. This means that I would need to follow another book or tutorial. Please consider drip feeding the player a syntax cheat sheet that will help with each level .
- lcedp 13y agoDoes anyone know more games like this? Thanks.
- innguest 13y agoThis is very cool. I hope others copy your idea - very nice way to marry programming with games.