Slashdot Mirror


How Does a Single Line of BASIC Make an Intricate Maze?

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.

18 of 438 comments (clear)

  1. Without the use of a loop!? by Anonymous Coward · · Score: 5, Insightful

    What is
    10 something: GOTO 10
    if not an (endless) loop?

    1. Re:Without the use of a loop!? by gl4ss · · Score: 4, 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.

      --
      world was created 5 seconds before this post as it is.
    2. Re:Without the use of a loop!? by Potor · · Score: 3, Insightful

      this is one of the stupidest /. stories ever -- it is not one line of code, and it is a loop, as you and many others point out.

    3. Re:Without the use of a loop!? by shitzu · · Score: 4, 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.

    4. Re:Without the use of a loop!? by swillden · · 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.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    5. Re:Without the use of a loop!? by Samantha+Wright · · Score: 5, Insightful

      It's called a display hack. 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.

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    6. Re:Without the use of a loop!? by The+Moof · · Score: 4, Insightful

      If you want to go that route, every program written in C can be condensed down to 1 line. Or any language where whitespace isn't significant.

  2. Sad day for slashdot... by Anonymous Coward · · Score: 5, Insightful

    ...when the summary does not know what a loop is.

  3. No loop? by chthon · · 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.

    1. Re:No loop? by Anonymous Coward · · 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?

  4. Some minor deficiencies by zmooc · · 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

    --
    0x or or snor perron?!
  5. Really? by Multiplicity · · 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.

    1. Re:Really? by Anonymous Coward · · 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."

  6. Not even that by Immerman · · 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.

    --
    --- Most topics have many sides worth arguing, allow me to take one opposite you.
  7. A simple Linux port by Sam+H · · Score: 2, Insightful

    strings /dev/urandom|tr -dc '/\'

    --
    God, root, what is difference ?
    1. Re:A simple Linux port by Sam+H · · Score: 5, Insightful

      Sorry, what was I thinking? This is obviously more elegant:

      tr -dc '/\' </dev/urandom

      --
      God, root, what is difference ?
  8. Re:Enterprise Java Version by Anonymous Coward · · 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.

  9. Re:Enterprise Java Version by Anonymous Coward · · Score: 2, Insightful

    Congrats for admitting you are a reddit user. Thats the first step towards recovery.