Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Books Graphics Programming Games

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.
This discussion has been archived. No new comments can be posted.

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

Comments Filter:
  • by Anonymous Coward on Saturday December 01, 2012 @02:51PM (#42155619)

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

  • by Anonymous Coward on Saturday December 01, 2012 @02:51PM (#42155623)

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

  • No loop? (Score:5, Insightful)

    by chthon ( 580889 ) on Saturday December 01, 2012 @02:51PM (#42155625) Journal

    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.

  • by zmooc ( 33175 ) <{ten.coomz} {ta} {coomz}> on Saturday December 01, 2012 @02:54PM (#42155651) Homepage

    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)

    by Anonymous Coward on Saturday December 01, 2012 @03:01PM (#42155735)

    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)

    by Multiplicity ( 2498210 ) on Saturday December 01, 2012 @03:02PM (#42155741)

    Frontpage slashdot story with a 10 GOTO 10 and saying it's not a loop?

    Dudes, just what the fuck. I ask you that.

  • by gl4ss ( 559668 ) on Saturday December 01, 2012 @03:19PM (#42155887) Homepage Journal

    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.

  • by Potor ( 658520 ) <farker1NO@SPAMgmail.com> on Saturday December 01, 2012 @03:21PM (#42155899) Journal
    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.
  • by shitzu ( 931108 ) on Saturday December 01, 2012 @03:29PM (#42155977)

    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.

  • by swillden ( 191260 ) <shawn-ds@willden.org> on Saturday December 01, 2012 @03:52PM (#42156181) Journal

    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)

    by Immerman ( 2627577 ) on Saturday December 01, 2012 @03:54PM (#42156189)

    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.

  • by Sam H ( 3979 ) <sam@zoy.org> on Saturday December 01, 2012 @03:56PM (#42156197) Homepage

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

  • by Samantha Wright ( 1324923 ) on Saturday December 01, 2012 @04:10PM (#42156313) Homepage Journal

    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.

  • by Sam H ( 3979 ) <sam@zoy.org> on Saturday December 01, 2012 @04:13PM (#42156349) Homepage

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

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

  • Re:Really? (Score:3, Insightful)

    by Anonymous Coward on Saturday December 01, 2012 @04:16PM (#42156365)

    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."

  • by Anonymous Coward on Saturday December 01, 2012 @04:27PM (#42156457)

    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.

  • by The Moof ( 859402 ) on Saturday December 01, 2012 @05:27PM (#42156755)
    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.
  • by Anonymous Coward on Saturday December 01, 2012 @11:56PM (#42158939)

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

E = MC ** 2 +- 3db

Working...