Slashdot Mirror


SedSokoban

rsd writes: "Have you ever thought that sed is too limited and only useful to Regular Expression scripts? Well, verde666, who works for Conectiva, proved that it can be used for games too. He wrote a sokoban game named sedsokoban with sed. There is even a screenshot."

47 of 149 comments (clear)

  1. Don't mistake the tool for the skill... by BoBaBrain · · Score: 5, Insightful

    It's possible to sculpt Venus using only a nail file (and a lump of marble).
    That doesn't mean nail files are any more useful than we thought.

    --
    I am a Karma Library.
    1. Re:Don't mistake the tool for the skill... by hey! · · Score: 3, Interesting

      I still use sed on occaision, although there's really nothing you can do in sed that you can't do with 'perl -e ...'. Partly this is because se style re's were just burned into my impressionable young brain back in the days of System III, but also I think that sed really embodies the Unix tools philosophy -- build simple tools that do one thing extremely well.

      Of course this kind of hack shows that even simple tools can be used in unexpected ways. This is a good lesson to remember. This is a little OT, but I was thinking about this fact the other day when I was listening to people talk about placing blame for the security lapses on 9/11. One way to defeat security is to find behavioral possibilities inherent in the implementation of a system that aren't part of its design. In retrospect, it's easy to see you can smash a stack by putting machine language instructions into an unchecked buffer, but this attack was highly original the first time it was attempted. In retrospect, it easy to see that a large airliner loaded with fuel is a flying bomb, but to see this in advance is harder.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  2. It's a slippery slope... by marnanel · · Score: 4, Insightful

    Today it's Sokoban... beware, for before you know it it'll be Elite.

    --
    GROGGS: alive and well and living in
  3. Ummm....What? by Tranvisor · · Score: 3, Interesting

    First of all what is sed? Sorry for being late to the party here, but come on, I have no idea what this is about other then somebodies little text-like game?

    Mike, don't you think that you could have contributed like a sentence at the end saying something that would bring the picture a little more into the real world focus? Heck, I would settle for something like "Sed is normally used for ........ to do ..... Pretty interesting use of sed because ......"

    Just a thought.

    1. Re:Ummm....What? by anpe · · Score: 5, Informative

      Sed stands for Stream EDitor. It's part of the New Command-Line eXPerience(tm) that Microsoft ships with Microsoft Word (tm) so that the user can easily writte DOS-mode games while editing.

      If you really don't know what SED is, then Google's your friend : http://directory.google.com/Top/Computers/Software /Editors/SED/

    2. Re:Ummm....What? by marnanel · · Score: 5, Informative

      Sed is a stream editor-- it takes a file and modifies it according to your instructions (such as "add a space at the start of every line"). Here's a quick introduction, and here's the sed FAQ from comp.editors.

      --
      GROGGS: alive and well and living in
    3. Re:Ummm....What? by Fnord · · Score: 2

      Sed is a UNIX command that's mostly used for automated search and replace like editing of text files (to other unix heads who are screaming now, I know its more than that but I'm trying to simplify). It has a programming language built into it but its really cryptic and not nearly as usefull as the regexp search replace feature and so the vast majority of people don't use it, and writing a game out of it is just masochistic (somewhat like the guy that wrote a webserver in postscript). He didn't describe what it was because to anyone who's used unix its almost second nature. Too often people forget that a windows user or whatnot wouldn't have any exposure to such things.

    4. Re:Ummm....What? by FuegoFuerte · · Score: 4, Informative

      As people have now already said ( yah yah, I know... redundant. Shut up already...) sed is the Stream EDitor. Windows people probably would have no clue what sed is. People new to *nix systems probably would have no clue what sed is. It is often assumed though (possibly incorrectly, but I digress) that the main audience of /. is made up of people not in those 2 categories. (note that I'm not saying there's anything wrong with people not knowing what sed is, just that most people on /. would probably have enough exposure to *nix to know.)

      If you want to know more about sed, look at the man page, available http://linux.ctyme.com/man/man2377.htm

      Also, for anyone who doesn't know/can't figure it out, man page is short for MANual page. If you have any access to a *nix system, I hope you know about man. For those that may not, the man pages are a wonderful help utility provided with linux systems to give information about various programs, commands, etc. A user simply types `man [commandname]` and up pops a helpful page telling all about the command or program. In our case, it would be `man sed`.

      Slightly on a tangent, does anyone know of a help system for *nix similar to the old DOS help system (which MS has so helpfully removed and replaced with that stupid paperclip/dog/whatever)? It was nice to be able to simply browse the available commands, jump from help page to help page, etc. A similar thing for *nix could be nice at times.

      For something more on topic... nice hack. From what little I've played with sed, I can't imagine having the patience to write a game with it. The only question I have is, why?

    5. Re:Ummm....What? by bluebomber · · Score: 2

      Didn't some of the xman versions provide links from page to page?

    6. Re:Ummm....What? by aussersterne · · Score: 3, Informative

      I hope whoever moderated this to "informative" isn't taking it entirely seriously...

      sed stands for "Stream EDitor" yes, but it is not at all to do with Microsoft. sed has been a staple command used with Unix operating systems for a long, long time and you'll find details about using it in any good Unix book.

      --
      STOP . AMERICA . NOW
  4. Yes, but... by wedg · · Score: 2, Funny

    ...will it julianne fries?

    --
    Jake
    Dating: while( 1 ){ call_girl(); get_rejected(); drink_40(); } return 0;
  5. Not bad by John+Ineson · · Score: 2, Interesting
    But dc.sed takes some beating. Square roots with regexps anyone?

    (this is how it works)

  6. An excellent unix game package.. by sanermind · · Score: 2, Interesting

    Although admitedly this isn't on the topic of cool sed hacks...
    If you haven't heard of or tried it, [and like this sort of game], be sure to also look into
    rocksndiamonds, a truly excellent game for X. It not only has all the classic sokoban levels, but it also does an excellent implementation of Boulderdash, and also Emerald Mine [which I have fond memories of wasting huge amounts of time with on my old Amiga when I was a kid]. Excellent graphics to boot. Plus it's GPL. I've always been suprised that redhat dosen't provide it as an rpm, considering some of the marginal games that they do ship.

    --

    ---
    the pen is mightier than the sword, the sword is mightier than the court, the court is mightier than the pen.
  7. Re:Drawback by loren · · Score: 2, Interesting

    Would you prefer a sed binding for SDL?

    ;)

    (I probably shouldn't give him any ideas... )

    --

    Loren Osborn

    Software isn't software without source code. -- NASA
  8. No. by marnanel · · Score: 4, Informative

    Unfortunately not-- though I'm sure you could submit a patch if you felt like it. See the docs:

    #r h or <left-arrow> - move left
    #r j or <down-arrow> - move down
    #r k or <up-arrow> - move up
    #r l or <right-arrow> - move right

    There's a handler in there for the "p" key, though I'm still not sure what it's supposed to do. It seems to put sed into an infinite loop.

    --
    GROGGS: alive and well and living in
    1. Re:No. by knulleke · · Score: 2, Funny

      Obviously p is for pause

      --
      no sig error.
  9. Sokoban in Nethack by 6R1MM · · Score: 5, Informative

    I'd just like to point out that sokoban can be played inside nethack. It's actually a series of levels in the game called The Sokoban Tower. For those that don't know, nethack is an ASCII-based graphical RPG with movement controls inspired by vi.

    1. Re:Sokoban in Nethack by Ravagin · · Score: 3, Insightful

      And how! I was considering a facetious comment along the lines of "Hey, that looks like a nethack level..." but that would only work in a group of nethack players.

      Anyway, you left out the part about it being the best game in the world, etc. Diablo? Diablo is for people with short attention spans who like shiny graphics. Us hardcore gamers (with, er, 386s...) know where it's at. [/joking- play whatever you like, it's a theoretically free world]

      The curious ought to go to nethack.org and give it a shot. If you're new and using DOS/Win, try the graphics version. But whatever the interface, the game is highly addictive.

      --

      Karma: T-rexcellent.

    2. Re:Sokoban in Nethack by Speare · · Score: 2
      There is a sokoban puzzle in the middle of the text adventure game, Zork II. If you think Sokoban is challenging with a top-view graphical representation, try it in first-person prose. All you see is "a sandstone wall on your west, a sandstone wall on your south, and a marble wall on your east" and all you can try is "push the west wall."

      Heck, when you first encounter it, you don't even know it's a Sokoban puzzle. You just find these goofy walls. It's only after carefully exploring and mapping the free and open areas and the wall materials that you might see your map as something else. Finally you can start working out on paper what you need to do.

      I played this on an Apple II, and it's still available in the Infocom collection. Heck, play it on your Palm Pilot.

      --
      [ .sig file not found ]
    3. Re:Sokoban in Nethack by AJWM · · Score: 2

      For those that don't know, nethack is an ASCII-based graphical RPG with movement controls inspired by vi.

      To elaborate further, nethack is a latter-day version of hack, which in turn was a descendant of the original rogue . (Which, as the man said, is an ASCII/curses based RPG.)

      --
      -- Alastair
  10. Finally... by Constrain_Me · · Score: 2, Funny

    I've found a use for Cygwin ;)

  11. Tried it out by tuxlove · · Score: 2, Interesting

    This is totally cool. Very creative. Reminds me of the Towers of Hanoi vi script I've seen floating around. Also the maze generator/solver in vi script. The vi scripts are cool because they use parts of the screen to store variables. :)

    1. Re:Tried it out by DrSkwid · · Score: 4, Funny

      yes, such a refreshing change from using variables to store parts of the screen :)

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  12. Now what we need is... by po8 · · Score: 4, Interesting

    Consider the case of Andreas Junghanns, who wrote Rolling Stone, the world's top machine Sokoban solver, in C. I'm sure that even as you read this he is working on rewriting it in the Sokoban-friendly language sed.

    Or not.

  13. A wise man once said... by ct · · Score: 5, Funny

    To quote Chris Rock in Bigger and Blacker,

    "Just because I can drive a car with my feet - doesn't make it a good fucking idea".

    //ct

  14. Under OS X by rjamestaylor · · Score: 4, Interesting
    It runs under OS X (no Aqua support though...kidding) BUT not using Darwin/BSD's sed (/usr/bin/sed), rather using Fink's sed (/sw/bin/sed). Using the default sed, I get this error:
    • sed: 2266: ./sokoban.sed: unexpected EOF (pending }'s)
    Once again, GNU tools rule over BSD tools. Well, for gaming, anyway.
    --
    -- @rjamestaylor on Ello
  15. Re:Screenshot Mirror by ct · · Score: 4, Funny

    *DING!*DING!*DING! - We have a Winner!

    For a 2kb .png that's the worst attempt at cheap karma this week.

    //ct

  16. Never underestimate a scripting language... by seanadams.com · · Score: 2

    Here's something I made a while back in case anyone's interested:

    Perltris

    1. Re:Never underestimate a scripting language... by flegged · · Score: 2

      Yeah, I wrote Tetris (and a few others) in JavaScript (for DOM level 1 browsers - Mozilla or IE5 will work) a while back. I also wrote Tetris in C++ (source is here; works under Wine) when I was learning DirectX. The blocks.js became blocks.h with a few search and replaces.

      So Tetris is kindof my "Hello World" when learning a new language. I don't think I'll try to write it in sed though. :o)

      --

      "I think he was truly surprised at how little I cared about how big a market the Mac had" - Linus on Jobs
    2. Re:Never underestimate a scripting language... by Gid1 · · Score: 2
      So Tetris is kindof my "Hello World" when learning a new language.
      Me too, until I got a Cease and Desist order from the Tetris company! =(
  17. Doesn't work on Sun, either: by larien · · Score: 3, Interesting

    $ ./sokoban.sed
    Too many {'s$

    Bleh...

  18. Re:this'll show 'em by WWWWolf · · Score: 2, Insightful

    Hey, let's not be unfair. At least we Perl users have terminal control libraries and something that looks like a programming language. Besides, using sed for "real" programming is hard and challenging and people stand in awe, but using Perl for real programming is just fun and no one notices if you program something infinitely cool with it, because Perl was made so that infinitely cool things could be made easily.

    This hack is impressive because it was made in a toothless environment, not because it has not yet been implemented in some better language =)

  19. strange hacks hall of fame? by petis · · Score: 2, Interesting

    Is there such a thing as a sh-hof? In that case I would like to nominate the sed hack in the story, and this webserver written in postscript... :)

  20. Proof that sed can in fact do everything... by earthy · · Score: 2, Interesting
    Well, this seems as good a place as any to mention the sed script I wrote some 4 years ago that emulates a Turing machine. The script is actually capable of performing any calculation one can write a Turing machine program for... addition of two numbers is provided as an example.

    Oh, ofcourse, the sed Turing Machine is on the web as well. :)

    Owh, by the way, it's pretty readable sed code... it's had to be for me to finish it. :)

    Arthur

  21. Re:one word "REPTON" by jonr · · Score: 2

    Argh... Repton 2 was of course just pure evil. I never actually finished it. Must find it for my BBC emulator, Hmm... how to read 320K 5¼ floppies on a PC...

  22. SedSokoban? by InsaneCreator · · Score: 2

    Games for SED? Now I've seen everything. So what's next? Textmode quake 2?

  23. 512 byte sokoban by divec · · Score: 2

    I'm impressed that it's possible in sed. Here's a smaller one, in perl, but I dunno if it'll work on Win32.

    --

    perl -e 'fork||print for split//,"hahahaha"'

  24. tetris / sokoban in VIM by skt · · Score: 2

    that reminds me of the tetris game I played a while ago written in VIM's native scripting language. The tetris game is here IIRC. Heh, and when I was looking for that there seems to be a sokoban game in VIM too..

  25. Re:OK - now for 'Quake' written in bash by The+Wookie · · Score: 2

    #!/bin/bash
    /usr/local/bin/quake
    # :-)

  26. Not the only sed game by Fluffy+the+Cat · · Score: 3, Informative

    See http://www-jcsu.jesus.cam.ac.uk/~gsb29/sedgames.ht ml for sed versions of pong, noughts and crosses (tic tac toe in the US, I think), a webserver and a program for translating bf into C.

  27. Towers of Hanoi & Mandelbrot for vim by adadun · · Score: 2

    Linus Åkerlund's Towers of Hanoi implementation for vim. can be found here. He has also written a cool Mandelbrot set generator in vim that can be found on the same page.

  28. that ain't right by zerOnIne · · Score: 2

    it's pretty cool nonethe less, though ... reminds me off the jezzball and pong clones i saw written in zcode, the language used for the original zork series and other text-adventure games ...

    --
    09
  29. while we're at it: color in freebsd nethack? by hawk · · Score: 2
    I thought I had it working forever ago, and I know I used to have it on console (but not xterm) with debian.


    Not that I've ever had a tendency to move into my cat or any such thing . . .


    anyone know how to do this?


    hawk, who still needs to file the bug report in freebsd for nethack being a port rather than the base system (but will face the mkdir/rmdir spelling error bug first!)

    1. Re:while we're at it: color in freebsd nethack? by CoolVibe · · Score: 2
      You xterm-happy kid :) I usually would point you to the documemtation, but since this is somewhat less-obvious, I'll point it out here for you. Stick it in your tool chest, impress your friends, go far away places, meet interesting people, and kill them (to stay a little bit on topic) ;)

      Right, enough silly banter. Pay attention:

      Try this: (in bourne shell derivatives)

      TERM-xterm-color && export TERM

      Or this: (if you use the csh dialect)

      setenv TERM xterm-color

      As you will notice, more apps will be in color now, like mutt et al... Oh, you can have your colored ls(1) too. Check google on how to set that up.

    2. Re:while we're at it: color in freebsd nethack? by hawk · · Score: 2
      >You xterm-happy kid :)


      It's not my fault!


      The boss just won't spring for a 3x3 shelf of VT100's with a wrist-mount inertial switch to connect the keyboard, so I'm stuck with xterms, the *real* reason for using X.



      >I usually would point you to the documemtation,


      Been there, done that. TERM was already xterm-color. This now works, but it wasn't before. It may be that all the colors were used up (I have my drive in a loaner laptop, and only get 8 bit--and it's not worth hunting down an xf86config for the few days involved), or there may have bveen another funky interaction going on.


      But thanks.


      hawk

  30. Talk about fast progress... by wedg · · Score: 2

    ...I think the slashdotting this guy received inspired him.

    When I went here last night, there were two files, the .png screenshot and the original .sed script. Now there's 2 more versions out (0.0 and 0.1) and a contest to see who can solve each level in the fewest moves, along with a solution to level 1.

    Just in case all of you didn't bother to visit it, or didn't visit it twice, you should check it out: The contest makes for some fun gameplay.

    --
    Jake
    Dating: while( 1 ){ call_girl(); get_rejected(); drink_40(); } return 0;
  31. The best graphical version of Nethack... by Jagasian · · Score: 2

    Sure you can play the Nethack with its original ASCII based interface, but the game is far more sexy with a full SVGA Diablo-esque interface (see screenshots on bottom of linked page). Note this game is fully open source, and still actively developed... even after more than a decade! This game has been polished to perfection.