How Does a Single Line of BASIC Make an Intricate Maze? 438
JameskPratt writes "This Slate article talks about a single line of code — 10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10 — and how it manages to create a complicated maze without the use of a loop, variables and without very complicated syntax." Now that amazing snippet of code is the basis of a book, and the book is freely downloadable.
Without the use of a loop!? (Score:5, Insightful)
What is
10 something: GOTO 10
if not an (endless) loop?
Sad day for slashdot... (Score:5, Insightful)
...when the summary does not know what a loop is.
No loop? (Score:5, Insightful)
No editors with programming experience perhaps.
The basic definition of a loop is a GOTO to a previous address! All the rest is syntax and optimisation.
Some minor deficiencies (Score:5, Insightful)
create a complicated maze with out the use of a loop
1. This is not necessarily a maze. It's noise. At best.
2. It's "without", not "with out"
3. There is a loop
Re:No loop? (Score:1, Insightful)
and it's not even a single line.
Everyone knows that : in BASIC starts a new line.
This is two lines.
Or are you going to suggest that simply s#\r\n## makes all programs a single line?
Really? (Score:5, Insightful)
Frontpage slashdot story with a 10 GOTO 10 and saying it's not a loop?
Dudes, just what the fuck. I ask you that.
Re:Without the use of a loop!? (Score:5, Insightful)
No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.
"an intricate combination of paths or passages in which it is difficult to find one's way or to reach the exit."
it is that. it's just not very amazing at all if you describe it as printing \ and / randomly.
Re:Without the use of a loop!? (Score:4, Insightful)
Re:Without the use of a loop!? (Score:5, Insightful)
And most importantly - its not a particularly amazing piece of code. I am not a programmer, but know how to write basic stuff in a few languages - and i do not find a TWO LINE LOOP that fills the screen with a choice between two characters that make up something that LOOKS LIKE A MAZE, but is not necessarily navigable not a least bit amazing.
Re:Without the use of a loop!? (Score:5, Insightful)
It sort of reminds me of similar little tricks used to generate landscapes and other such things... mandelbrot comes to mind.
Except that the Mandelbrot set, for example, really is much, much more interesting. It actually has a great deal of sophisticated structure, that's highly chaotic (in both typical and mathematical senses of the word) but not random at all. Not at all comparable to this example, whose output has no real structure at all, but just exploits the tendency of the human brain to find patterns whether or not they exist.
Not even that (Score:5, Insightful)
It certainly has the intricate path part down, but most people would take issue with a "maze" that lacks a beginning, end, or any guarantee that you can get from point A to B even if you consider obvious closed loops out of bounds.
A simple Linux port (Score:3, Insightful)
strings /dev/urandom|tr -dc '/\'
Re:Without the use of a loop!? (Score:5, Insightful)
It's called a display hack [wikipedia.org]. They're at least as old as the oscilloscope, and have always been a mainstay of the demoscene. The book provides little actual relevant history about the context of this snippet in that regard, only noting that the snippet itself derives from the C64 User's Manual.
Somewhat dismayingly, the bulk of the text ponders on criticism that presumes an intentional, carefully-planned artist:
10 PRINT picks up on aspects of "Mouse in the Maze." Its output is a regular arrangement of "walls" in a grid—akin to the display of that earlier program and similar to the arrangement of the stereotypical laboratory maze. "Mouse in the Maze" does not present the compelling creation of an inspired Daedalus, but a behaviorist experiment. This maze is a challenge to intelligence—not, however, a romantic, riddling intelligence, but a classically conditioned, animal kind. It also brings in the idea of the scientist, who may be indifferent to the struggles of the creatures lost in the maze.
This manner of thinking, now put on display nakedly in the context of something completely mathematical and involving no relevant human imagination, can plainly be seen to be philosophically inconsistent. The author has said that a very simple natural phenomenon is influenced by a complex work of art (specifically a TX-0 game from twenty or so years earlier), which indicates a profound metaphysical error.
Certainly it is worthwhile to talk about chaotic functions (like the R pentamino in Conway's Game of Life, in addition to the display hacks already mentioned) but attempting to critique them as if they were part of the artistic canon is intellectually dishonest.
Re:A simple Linux port (Score:5, Insightful)
Sorry, what was I thinking? This is obviously more elegant:
tr -dc '/\' </dev/urandom
Re:Really? (Score:3, Insightful)
What the fuck? I'll tell you what the fuck... Slashdot as it stands today is a sad, pale reflection of the Good Slashdot of Old.
The focus isn't "News for Nerds" anymore, it's "Bash Apple Good... and oh, here's some code too."
Re:Enterprise Java Version (Score:2, Insightful)
You realize the above is a joke right? Just because you can make it complicated isn't a reflection of the language. You could implement the java equivalent of the original program very tersely if you wanted to.
Re:Without the use of a loop!? (Score:5, Insightful)
Re:Enterprise Java Version (Score:2, Insightful)
Congrats for admitting you are a reddit user. Thats the first step towards recovery.