Live data from Hacker News

A single line of Basic sends readers into a labyrinth

slate.com

21–30 of 91 posts

Re: A single line of Basic sends readers into a labyrinth

#22
post #10

A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327

A slight modification to make it generate mostly solvable mazes: `yes 'c=(┻ ┫);printf ${c[RANDOM%2]}'|bash`

Re: A single line of Basic sends readers into a labyrinth

#23

Just to be clear...it doesn't generate a labyrinth. It generates something that looks like a labyrinth, but isn't one. It's just random forward and backward slashes.

The device you're on doesn't generate text. It looks like text, but it's really just red, green and blue dots.

I presume OP means that it may not have a 'solution'. i.e. i can't really navigate it like a 'proper' labyrinth.

Re: A single line of Basic sends readers into a labyrinth

#24
post #20
post #10

A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327

Ruby: echo 'loop do print ["\u2571","\u2572"].sample end'|ruby

This makes it slower, so it's more pleasant to watch:

echo 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'|ruby

Re: A single line of Basic sends readers into a labyrinth

#25
post #10

A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327

A slight modification to make it generate mostly solvable mazes: `yes 'c=(┻ ┫);printf ${c[RANDOM%2]}'|bash`

choosing from

  || __     # (2 pipes, one space, 2 bars)
seems to work pretty well, too

Re: A single line of Basic sends readers into a labyrinth

#26
post #5

Can this book not be available in digital form? Amazon and MIT Press only list the hardcover edition. http://mitpress.mit.edu/books/10-print-chr2055rnd1-goto-10-0

The article links to the book's (free) download page: http://10print.org

Thanks, I wonder who is the idiot who downvotes an honest question.

Still, I would pay $9.99 for mobi or epub. PDF is inconvenient for the Kindle and the iPad. Converting with Calibre is a chore, and rarely yields good results.

Re: A single line of Basic sends readers into a labyrinth

#28
Another fun example of a computer generating mezmerizingly complex art from simple code is that as a kid, I wrote a Langton's Ant implementation in QBASIC on a DOS machine (don't remember the version). IIRC this was using Graphics Mode 1 (320 x 200 pixel framebuffer), and I used PSET and PRESET to draw white and black pixels. This so far sounds ordinary but:

The cool thing was that I forgot to write the bounds check to make sure the ant stayed inside the framebuffer! So the ant would happily trundle off-screen, encounter arbitrary bits that were in that memory, and would often eventually return back on the screen from a different location. Or sometimes (probably due to encountering zeros offscreen) it would run a lap around the edge of the screen and then veer back inward.

Langton's Ant: http://en.wikipedia.org/wiki/Langtons_ant

Re: A single line of Basic sends readers into a labyrinth

#30
post #24
post #20

Earlier quoted context omitted.

Ruby: echo 'loop do print ["\u2571","\u2572"].sample end'|ruby

This makes it slower, so it's more pleasant to watch: echo 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'|ruby

Why piping to ruby? You have the -e operator for that:

    ruby -e 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'
Post reply on HN