Live data from Hacker News

A single line of Basic sends readers into a labyrinth

slate.com

71–80 of 91 posts

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

#71
post #62

Earlier quoted context omitted.

Interactive JavaScript version: http://js.do/samples/labyrinth

Hmm.. thats not a oneliner. Which is what makes the Basic version interesting in the first place. Also it differs in that it does not run continously. I shortened it a bit: http://js.do/code/154 Still not as elegant as the Basic version. This is one of the big downsides of how javascript is implemented in the browsers these days. There is no simple way to redraw the screen. You have to turn your whole program into a…

I won't claim this is elegant, but here's the same thing in one line:

for(i=1;i" : (Math.random()>0.5) ? '\u2571' : '\u2572');

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

#72
post #15

If you have a machine with a UTF-8 terminal and a recent-ish Perl (tested on Perl 5.10 + Mac OS X 10.6), you can play along at home by running: perl -e '$ |= 1; binmode(STDOUT, ":utf8"); while (1) { print chr(9585.5 + rand()); select(undef, undef, undef, 0.01); }'

This was the most beautiful one for me: http://cl.ly/image/3y0I2J2q421E

That gives me a gentle optical illusion - there's a sort of 3d effect going on and I can't tell which way is up or out or in or down.

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

#73
post #10

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

PowerShell for those on Windows: for (;;) { write-host -n (get-random ╱,╲) } Obviously this requires a font supporting those characters. MS Mincho seems to serve well: http://www.microsoft.com/typography/fonts/font.aspx?FMID=206

You can also just use for(){...}. No need for the semicolons there.

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

#74
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

I'm downloading it now. Would like to donate by buying but UK Amazon site lists it as out of stock.

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

#75
post #10

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

Perl 6, using Rakudo:

perl6 -e 'loop { print .roll.chr }'

In fact, perl6 -e 'loop { print .roll }' will work too if your terminal is set up properly.

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

#76

Python version: python -c 'import random; print "".join(random.choice(r"/\\") for i in range(80*24))'

Same thing, but with corner-to-corner unicode glyphs: python -c 'import random; print "".join(random.choice([u"\u2571",u"\u2572"]) for i in range(80*24))'

python -c "print ''.join(__import__('random').choice(u'\u2571\u2572') for i in range(80*24))"

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

#77
post #58

It may be somewhat interesting to analyze the properties of randomly-generated labyrinths of this type. For instance, some spaces are clearly enclosed. i.e., there is a finite border outside which you cannot escape. Some paths seem to run on for a very long time. Are all paths enclosed? If so, given a random point on a randomly generated maze, what is the average area of an enclosure?

I don't think a "corridor" ever forks, so it's not really a labyrinth where there are decisions to be made about which way to go, it's just a bunch of disjoint long, twisty hallways.

Add a space every now an then and it becomes a 'real' maze:

    #include 
    main() { for(;;) {printf(rand()%2 ? "╱":"╲"); if(rand()%100

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

#78

Earlier quoted context omitted.

I tried to like it. I bumped up the font size to 36 points. I slowed down the loop to .01 seconds. Unfortunately, it isn't remotely the same. The C64 had magic. I miss my old C64.

Try this: http://www.secretgeometry.com/apps/cathode/ Lots of fun. Use it to make old stuff like this feel more authentic, or just run your builds in it and tell your housemates you're haxxing teh gibson. TBH though the reason it doesn't feel the same is ultimately because you're not the person you were 20-30 years ago, whoever that was. Nothing to do with the code or its execution environment.

What a totally clever app. And extremely well done. Thanks for sharing! Brought joy to this not-so-old-but-old-enough child of the 80s :)

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

#80
post #62

Earlier quoted context omitted.

Interactive JavaScript version: http://js.do/samples/labyrinth

Hmm.. thats not a oneliner. Which is what makes the Basic version interesting in the first place. Also it differs in that it does not run continously. I shortened it a bit: http://js.do/code/154 Still not as elegant as the Basic version. This is one of the big downsides of how javascript is implemented in the browsers these days. There is no simple way to redraw the screen. You have to turn your whole program into a…

> ...not as elegant as the BASIC version

Beautiful statement. So much unintentional irony, and at the same time so very true in this context.

Post reply on HN