From: Dave Burt Date: 2004-11-04T23:08:51+09:00 Subject: Re: [SUMMARY] Sokoban (#5) "Ruby Quiz" ... > Well, how far did you get? I'm stuck on level 28 myself. > > As those of you who have now built Sokoban know, the game is quite trivial > to > implement. Here's a very brief solution from Dennis Ranke: (...) Wow! That's only 2 pages, about 0.08 small kLoC, or just over 1kB. > requiring you to push enter/return to send a move. While they do allow > you to > queue up a long line of moves, this tires my poor little fingers out, > especially > on involved levels. > > That begs the question, why did they use this approach? > > Portability, would be my guess. (...) Yes, I didn't like it, either. While standard input does confer the advantage of being able to save solutions and feed them in to your program using pipes or terminal cut/pasting, it still isn't my preference. If Ruby on Windows came with Curses, it would have been done that way. If I could be bothered learning Fox, it would have been done that way. How close is Fox to being "Swing for Ruby"? I ask because it works OK out of the one-click installer. The idea just popped into my head, what about using the Swing API itself? It's all lightweight itself, in Java, isn't it? Only 3 native classes, or something like that... I put no weight on this, though. > begin > require "Win32API" > def read_char > Win32API.new("crtdll", "_getch", [], "L").Call > end > rescue LoadError > def read_char > system "stty raw -echo" > STDIN.getc > ensure > system "stty -raw echo" > end > end (Saved for later use - thanks) Cheers, Dave