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.

86 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 Nutria · · Score: 4, Informative

      That's exactly what I thought... Maybe JameskPratt isn't a very good programmer.

      --
      "I don't know, therefore Aliens" Wafflebox1
    2. Re:Without the use of a loop!? by thestudio_bob · · Score: 2

      print REPLY; goto PARENT;

      --
      The real Sig captains the Northwestern. This one captains /.
    3. Re:Without the use of a loop!? by Anonymous Coward · · Score: 5, Informative

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

    4. 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.
    5. 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.

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

    7. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 3, Informative

      " it is not one line of code"

      Actualy, it absolutely is just one line of code. You are confusing the number of statements with the number of lines. In BASIC, as in many languages, you can have multiple statements and operation in a single line of code. Those statements do indeed however constitute an infinite loop, however.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    8. Re:Without the use of a loop!? by Endophage · · Score: 2

      Submitter was a moron. From the book: "For a one-line program that loops forever..." also "...it uses GOTO 10 to loop back..."

    9. Re: Without the use of a loop!? by Anonymous Coward · · Score: 4, Funny

      Pratt by name . . .

    10. Re:Without the use of a loop!? by erroneus · · Score: 4, Interesting

      I think there is a bit of a story in the fact that while in function, it is extremely simple though in result/appearance it creates what most perceive to be a complex maze of passages. The code puts out random positive space objects while the mind sees a single, complex negative space.

      It sort of reminds me of similar little tricks used to generate landscapes and other such things... mandelbrot comes to mind.

    11. Re:Without the use of a loop!? by stokessd · · Score: 5, Funny

      The code puts out random positive space objects while the mind sees a single, complex negative space.

      Sadly, that's the way I'm seeing slashdot these days...

    12. Re:Without the use of a loop!? by Black+Parrot · · Score: 5, Funny

      Maybe he's trolling to see who will admit that they know BASIC.

      --
      Sheesh, evil *and* a jerk. -- Jade
    13. 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.
    14. Re:Without the use of a loop!? by Sique · · Score: 2

      No. This would make it a solvable maze. So it's just a maze, or "a puzzle consisting of a complicated network of paths or passages".

      --
      .sig: Sique *sigh*
    15. Re:Without the use of a loop!? by MightyMartian · · Score: 4, Funny

      Much like a televangelist or politician then.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    16. Re:Without the use of a loop!? by Nutria · · Score: 2

      What programmer doesn't know/can't figure out rudimentary BASIC?

      --
      "I don't know, therefore Aliens" Wafflebox1
    17. 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!
    18. Re:Without the use of a loop!? by NFN_NLN · · Score: 3, Informative

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      I disagree, I think this finally proves the existence of god. ;)

    19. Re:Without the use of a loop!? by egcagrac0 · · Score: 2

      I can't think of any processors that don't have a JUMP or equivalent. So, assembly/machine code.

      Intercal has COME FROM, which is basically the same thing.

    20. Re:Without the use of a loop!? by Anonymous Coward · · Score: 3, Informative

      The difference between a maze and a labyrinth is that the goal of a maze is to get from the entrance to the exit. The goal of a labyrinth on the other hand is to get to the center. If there is no entrance and there is no exit, it isn't a maze by strict definition, but a set of paths.

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

    22. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 2

      " every program written in C can be condensed down to 1 line"

      This would be true if it were not for the pre-processor. You cannot, for example #include multiple external files on the same line or have multiple #defines on the same line. As far as "going that route" goes, the only route I took was making factually correct statements to correct the factually erroneous ones repeated far too many times on this subject. This isn't open to interpretation, unless you happen to be a C interpreter* that is ;-)

      * Before some idiot tries to point out that C is a compiled language, you should be aware that there are in fact C interpreters. Nothing about the language makes it intrinsically compile only, just as BASIC can be compiled even though it is typically an interpreted language.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    23. Re:Without the use of a loop!? by egcagrac0 · · Score: 4, Informative
      #include
      main() { ten: printf("%c", (rand()%2)?47:92); goto ten; }

      The preprocessor include directive is on a separate line, but that's really not part of the program.

    24. Re:Without the use of a loop!? by narcc · · Score: 5, Interesting

      Indeed, it isn't exactly rocket science -- zillions of kids under 10 picked up the basics of BASIC from type-in programs in kids books and magazines back in the 80's.

      What bugs me most is that instead of doing the obvious (making a binary tree maze) it's some weird artifact of how the / and \ combine on-screen that makes something that vaguely resembles a maze -- full of loops (no big deal) large winding sections without any junctions (bad), and isolations (terrible!).

      Just for fun:

      IBM PC users! You can modify the C64 program in the summary to both run on your micro and produce a binary tree maze with this simple change: PRINT CHR$(220 + INT(RND(1)*2) );

      You won't be able to get the same effect with alternating forward- and back-slashes with something like PRINT CHR$(47 + INT(RND(1)*2)*45); as they don't connect at all -- neither on the same line nor between lines.

    25. Re:Without the use of a loop!? by Anonymous Coward · · Score: 5, Funny

      The code puts out random positive space objects while the mind sees a single, complex negative space.

      I don't even see the random positive space objects anymore. I just see blonde, brunette, redhead...

    26. Re:Without the use of a loop!? by Richy_T · · Score: 2

      I was thinking of posting something like the GP's post but after reading yours, I went to check and you're right. Spectrum Basic had multi-statement lines. ZX81 basic didn't though so there may be some validity though it can rightfully be regarded as very far from a standard basic with many missing features.

    27. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 3, Informative

      Actually, you almost understood the implications. "One line of code" is in fact meaningless. It is one of the many reasons why using LOCs as a metric when assessing the quality and productivity of a codebase and its team is not a particularly useful approach.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    28. Re:Without the use of a loop!? by Dan+East · · Score: 3, Informative

      That's be cause you don't appreciate the context in which this code came to exist. Back in the early eighties, to be able to generate such visually impressive and complex looking imagery with so little code, was quite an amazing thing. I, for one, wish I would have known that bit of code back then as a ten year old. It certainly would have beaten my usual "10 PRINT "DAN WAS HERE!!! "; 20 GOTO 10" that I would type into the C64s, TI-99/4As, Atari 800s, and other computers on display at K-Mart and Sears.

      For the sake of completeness, here is a version that works with the syntax (and character set) of another home computer of the era, the TI-99/4A


      10 PRINT CHR$(INT(RND+.5)*45+47);
      20 GOTO 10

      The code is a little more complex because the forward and backward slash characters are not contiguous in the TI's character set (47 and 92). The result visually isn't as good because the TI's character glyphs are more spaced out than the C64's. However it does work - I tested it in the emulator (with standard TI BASIC, doesn't required Extended BASIC).

      --
      Better known as 318230.
    29. Re:Without the use of a loop!? by Dan+East · · Score: 5, Interesting

      A simple addition makes the TI-99/4A version look visually just like the C64's. That is to simply define the forward and backward slash characters to look more the C64's and span the whole area of the character's bitmap.


      10 CALL CHAR(47, "C0E070381C0E0703")
      20 CALL CHAR(92, "03070E1C3870E0C0")
      30 PRINT CHR$(INT(RND+.5)*45+47);
      40 GOTO 30

      Finally, if we're going to go to the trouble of defining character images, then we might as well use contiguous character codes so we don't need the extra math. We could use the C64's exact values, however the TI's character set only has 128 characters. So we'll use values 100 less than the C64 version. Also, the TI rounds floating values to integers, whereas the C64 simply truncates them. So we don't need to add .5 to the random value.


      10 CALL CHAR(105, "C0E070381C0E0703")
      20 CALL CHAR(106, "03070E1C3870E0C0")
      30 PRINT CHR$(105+RND);
      40 GOTO 30

      --
      Better known as 318230.
    30. Re:Without the use of a loop!? by Dan+East · · Score: 5, Informative

      And finally, here's a screenshot in case anyone actually cares what the TI version looks like.

      http://dexsoft.com/slashdot/ti_screenshot.png

      --
      Better known as 318230.
    31. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 2

      I picked the one out that I actually thought might prove you right (Sinclair), and imagine my surprise when I was able to prove you wrong with the first link I clicked. Pay careful attention to the example program which includes multi-statement lines like: 170 LET in=1: IF r$="y" THEN GO TO 210 and 510 IF qf>nq-1 THEN PRINT "I'm sure your animal is very", "interesting, but I don't have","room for it just now.": GO TO 800

      I accept your apology.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    32. Re:Without the use of a loop!? by narcc · · Score: 5, Interesting

      A binary tree maze algorithm will generate a "perfect maze" (no loops, isolations, and only a single path between any two cells), though you need a long hallway along two sides (depending on which edges you use for walls).

      Mazes with square cells share edges, so by assuming some rules about the outside walls of a maze, you can represent each cell in a maze with only two bits. You need only store, for example, just the south and west walls of each cell.

      To make a binary tree maze, first assume an outer wall and a long hall (no south walls) in the first column, and along the bottom row (no west walls). For all remaining cells, randomly add a west or south wall. You don't need any information about adjacent cells -- just flip a coin and draw a wall for each remaining cell. This will produce a "perfect maze". It's pretty cool.

      The code I posed will generate a binary tree maze, though it won't show the two long halls. (In this case, the program uses west and south walls, so the halls will be the in the first column and the along the bottom row.)

      The lameness filter doesn't want me to show you an example. Still, it's pretty easy to make a nice binary tree maze generator yourself. Give it a try and you'll see how it works.

      For fun, you can make four binary tree mazes and arrange them so that you have two long halls (one East to West, the other North to South) intersecting at the center of the maze, just by choosing which pair of walls to randomly generate in each quadrant. It makes a much more interesting looking maze without adding much complexity (just figure out which quadrant the current cell is in) and retaining all of the properties of a perfect maze.

      I hope that helps.

    33. Re:Without the use of a loop!? by Tablizer · · Score: 2

      and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      Just replace those slashes with parentheses, and you have a Lisp writer!

    34. Re:Without the use of a loop!? by FrangoAssado · · Score: 2

      It might generate a warning on some compilers, but it's a perfectly valid C program. In fact, since this program uses rand without declaration, it might as well use printf.

      Nothing prevents one from doing this, though:

      int rand(void); int printf(const char * restrict f, ...); main() { ten: printf("%c", (rand()%2)?47:92); goto ten; }

      (Remove the "restrict" before "f" for C89)

      In general, though, ISO C doesn't require translators (the technical name the ISO uses for C compilers/interpreters) to accept lines greater than some limit (509 in ISO C89, 4095 in ISO C99), so technically it's debatable whether it's possible to write every C program as a one-liner: you *could*, but a compiler might correctly not accept it.

    35. Re:Without the use of a loop!? by mrbester · · Score: 2

      Note the second paragraph of that page, where it mentions that the version of Sinclair BASIC used on the Spectrum was an *update* of what was used in the ZX80 / ZX81 (which was also called Sinclair BASIC funnily enough). Also note that I mentioned *1981* and that the Spectrum 16K came out in *1982* . Get it now?

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    36. Re:Without the use of a loop!? by FrangoAssado · · Score: 2

      OK, now it's clear that you have absolutely no idea what you're talking about -- you might want to read the C standard, or at least test it on a compiler.

      If you're interested to learn, here's a general explanation:

      The function declarations usually present in header files just tell the compiler what are the parameters accepted by the function, and what is the function return value. In C (not C++), these declarations are not required. If a function with no declaration is called, the compiler/interpreter/whatever uses an "implicit declaration" -- most compilers will give a warning saying that's what they're doing. An implicit declaration assumes that the function returns an int and receives the arguments that were passed in the call, with some promotions: for example, char is converted to int, float is converted to double, and so on (I don't remember all of the promotions rules, and I can't be bothered looking them up).

      An #include directive has nothing to do with the linker, except in some non-standard extensions by compilers (e.g. Visual Studio has the #pragma comment(lib, "library.lib"), which tells the linker to link with "library.lib") which are found on some header files.

      Note that some header files have more than just function declarations -- some also define macros (e.g. NULL). If you use them, you *must* include the header or define the macros yourself (e.g., #define NULL (void*)0): macros don't have an "implicit declaration". Of course, you might just expand the macros yourself (e.g., use (void*)0 instead of NULL): in this case, you obviously don't need to include the header.

    37. Re:Without the use of a loop!? by narcc · · Score: 4, Interesting

      Try something like this. (Keeping with the BASIC theme)

      10 CLS
      20 W = 10
      30 H = 10
      40 RANDOMIZE TIMER
      50 FOR I = 1 TO W: PRINT " __"; : NEXT I
      60 PRINT ""
      70 FOR I = 1 TO H
      80 PRINT "| ";
      90 FOR J = 1 TO W - 1
      100 IF INT(RND(1) * 2) = 0 THEN PRINT " __"; ELSE PRINT "| ";
      110 NEXT J
      120 PRINT "|"
      130 NEXT I
      140 PRINT "|";
      150 FOR I = 1 TO W - 1: PRINT "__ "; : NEXT I
      160 PRINT "__|"

      Lines 20 and 30 specify the width and height of the maze
      Lines 50 and 60 draw the north outer wall of the maze
      Lines 70 - 130 draw the maze by randomly drawing either a west or south wall.
      Line 80 draws the first cell in a row, which won't have a south wall, to make a long empty hall
      Line 120 draws the east-most outer wall at the end of each row
      Lines 140 - 160 draw the last row, just a long empty hall.

      You'll see that the maze has no loops or isolations. Every cell is reachable from every other cell by a single path.

      Hope that helps. Happy maze making!

    38. Re:Without the use of a loop!? by swillden · · Score: 2

      Firstly, the actual maze produced isn't random but is a visualisation of the pseudo-random algorithm used in C64 basic. Who's to say that this doesn't contain structure just as complex as that of the mandelbrot set?

      Doesn't matter. Try it with a different PRNG, or a TRNG, and you'll get the same maze-like effect, because the effect comes from the pattern-matching ability of the human mind, not from any real patterns in the slashes.

      Secondly, the mandelbrot set may not really contain the structures that we see at all. All those lovely spirals and so-on might just be floating-point artifacts. No-one knows for sure.

      Not true. The colors are representations of how many iterations it takes for the point to escape the unit circle (which shows that its absolute value will increase without bound). In portions of the edges of the set (the set itself is the points which remain bounded -- those are indeed hard to be certain of) the number of iterations is small, and it's easy to prove that the limits of the floating point representation are not being tested. Once you get "deeper", of course, floating point error becomes more significant. But the patterns don't change, which is itself interesting.

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

      AH NO! My entire box of tractor feed paper is GONE! You Bastard!!!

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

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

    1. Re:Sad day for slashdot... by Zero__Kelvin · · Score: 5, Funny

      Worse yet is the fact that the editors don't either.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    2. Re:Sad day for slashdot... by Trepidity · · Score: 4, Interesting

      Also, it can't string together a single grammatically correct sentence. Complete failure on both technical and English levels!

      The book is, however, quite interesting (just go straight to the open-access PDF and skip the mediocre Slate article).

  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 Zero__Kelvin · · Score: 5, Informative

      "Everyone knows that : in BASIC starts a new line."

      Nobody knows that, because it is untrue. The : is a statement separator, not a line seperator. That 10 you see is the line number. Notice that there are no other line numbers. Make an error on either side of the colon and the interpreter will give you the exact same complaint: Syntax error in line 10. You can verify this by looking for the line " In BASIC it's used as a separator between the statements or instructions in a single line." on Wikipedia, or use your Google-Fu to verify it thousands of other ways.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  4. 10 ... : GOTO 10 is a loop by Mneme · · Score: 5, Informative

    it manages to create a complicated maze with out the use of a loop, variables and without very complicate syntax

    It's very cool the way this code draws a maze, but there's obviously a loop there.

    (And it's “without” not “with out”, and “complicated” not “complicate”.)

    1. Re: 10 ... : GOTO 10 is a loop by Lobachevsky · · Score: 4, Interesting

      it's not a maze, it's a pattern of random forward and backward slashes, "/" and "\". There's no guarantee that a path exists anywhere near the top to anywhere near the bottom. In fact, because it's random, you'd be blocked off at some point.

    2. Re: 10 ... : GOTO 10 is a loop by narcc · · Score: 2

      In fact, because it's random, you'd be blocked off at some point.

      Nonsense. See: Binary tree mazes.

      Also, I recommend that you look at other maze generation algorithms (especially Eller's Algorithm) as you can easily create a random yet solvable maze where there is exactly one path between any two cells -- no loops or isolations. In the case of Eller's Algorithm, you can create a random maze of any length that has this property without keeping the entire maze in memory -- just a single line!

  5. Without the use of a loop? by Anonymous Coward · · Score: 3, Informative

    That....is.....a loop.......

  6. 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?!
  7. Goto Makes a Loop by dcollins · · Score: 2

    Re: "it manages to create a complicated maze with out the use of a loop"

    --
    We know where leadership by an anti-intellectual "strongman" who scapegoats minorities and likes boisterous rallies goes
  8. Enterprise Java Version by Mr.+Sketch · · Score: 5, Funny

    package enterprise;

    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    import java.util.Collections;
    import java.util.Map.Entry;
    import java.util.Random;
    import java.util.SortedMap;
    import java.util.TreeMap;

    public class Maze {
    private final WallFactory<Double> wallFactory;
    private final EntropyGenerator entropyGenerator;

    public Maze( WallFactory<Double> wallFactory, EntropyGenerator entropyGenerator ) {
    this.wallFactory = wallFactory;
    this.entropyGenerator = entropyGenerator;
    }

    public void visit( MazeVisitor visitor ) throws MazeException {
    while( true ) {
    MazeWall wall = wallFactory.createMazeWall( entropyGenerator.getNewEntropyValue() );
    wall.visit( visitor );
    }
    }

    public interface MazeWall {
    /**
    * @param visitor
    * @throws IOException
    */
    void visit( MazeVisitor visitor ) throws MazeException;
    }

    public static class LeftDiagonalWall implements MazeWall {
    @Override
    public void visit( MazeVisitor visitor ) throws MazeException {
    visitor.visit( this );
    }
    }

    public static class RightDiagonalWall implements MazeWall {
    @Override
    public void visit( MazeVisitor visitor ) throws MazeException {
    visitor.visit( this );
    }
    }

    public interface MazeVisitor {
    void visit( LeftDiagonalWall leftDiagonalWall ) throws MazeException;

    void visit( RightDiagonalWall rightDiagonalWall ) throws MazeException;
    }

    public interface WallFactory<T> {
    /**
    * @param value
    * @return the MazeWall
    * @throws MazeException
    */
    MazeWall createMazeWall( T value ) throws MazeException;
    }

    public static class StrategyWallFactory<T> implements WallFactory<T> {
    private WallRepartitionStrategy<T> wallRepartitionStrategy;

    public StrategyWallFactory( WallRepartitionStrategy<T> wallRepartitionStrategy ) {
    this.wallRepartitionStrategy = wallRepartitionStrategy;
    }

    @Override
    public MazeWall createMazeWall( T value ) throws MazeException {
    Class<? extends MazeWall> wallClassForValue = wallRepartitionStrategy.getWallClassForValue( value );
    try {
    return wallClassForValue.newInstance();
    } catch( InstantiationException | IllegalAccessException e ) {
    throw new MazeException( "Cannot create MazeWall instance", e );
    }
    }

    1. Re:Enterprise Java Version by CockMonster · · Score: 2

      InstantiationException.IllegalAccessException cannot be resolved to a type Maze.java /Maze/src line 76 Java Problem Syntax error on token "|", . expected Maze.java /Maze/src line 76 Java Problem The method lineSeparator() is undefined for the type System Maze.java /Maze/src line 139 Java Problem

    2. Re:Enterprise Java Version by phantomfive · · Score: 2

      His point is the vast majority of enterprise Java is shitty code. If you write code that looks like that, please reconsider your coding methods.

      --
      "First they came for the slanderers and i said nothing."
    3. 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.

    4. Re:Enterprise Java Version by Tumalu · · Score: 2

      And here's a more compact Java version:

      class Maze{public static void main(String[] args){while (true){for(int i=0;i<40;i++)System.out.print(Math.random()<.5?"/":"\\");System.out.println();}}}

      A bit verbose perhaps, but it's really not that much different than the version in the article. It's not the Java language that leads to the kind of verbosity that you see in enterprise code, but rather the conventions (and often the frameworks).

    5. Re:Enterprise Java Version by joss · · Score: 3, Interesting

      Actually, when the code is idiomatic, it is a reflection on that language/frameworks that go with it. Having spent a bad 5 years in enterprise java trenches I can vouch for the realism of that code. It gave me flashbacks. I'm still fucking shivering.

      --
      http://rareformnewmedia.com/
    6. Re:Enterprise Java Version by narcc · · Score: 5, Informative

      Plagiarizer. You stole this from reddit -- from the same post linked from Nick Montfort's blog.

      Enterprise Java Version:
      http://www.reddit.com/r/programming/comments/142jix/10_print_chr_2055_rnd_1_goto_10_how_a_single_line/c79elxn

      You shouldn't take credit for the work of others. That +5 funny is a filthy dirty lie.

    7. Re:Enterprise Java Version by Richy_T · · Score: 3, Funny

      Perl version: Search CPAN, someone's bound to have written a maze module.

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

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

  9. Without looping? by sidragon.net · · Score: 2

    How does this not use a loop?

  10. Perl analogue by Okian+Warrior · · Score: 5, Interesting

    Don't have a Commodore Basic interpreter? this Perl 1-liner will do the same thing:

    print ["/","\\"]->[rand(2)] while 1;

    It has no start or end point, and for two arbitrary points you can't guarantee that a path exists.

    ...but it definitely *looks* like a maze, so that's what it must be. The authors said so, after all...

  11. 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: 2, Funny

      It's a step up from the plastic on Mars story a few days ago.

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

  12. Multi-Fail by SuperCharlie · · Score: 3, Interesting

    This article fails in English and fails in the content. Booya.

    1. Re:Multi-Fail by Chelloveck · · Score: 4, Interesting

      The article reads to me like a sophomore-level paper deconstructing some insignificant piece of drivel and claiming great insights into human nature.

      "What can this one line -- '10 PRINT,' to use the authors' shorthand -- teach us about software, and culture at large?"

      Damn! And that's just the review, I can't even imagine what the actual 294-page book must be like. Next up I expect a 500-page treatise on Vogon poetry.

      --
      Chelloveck
      I give up on debugging. From now on, SIGSEGV is a feature.
  13. Python version by tepples · · Score: 5, Interesting
    The Python version is two non-comment lines:

    #!/usr/bin/env python
    # DataGlyphs simulator by Damian Yerrick
    from random import choice
    while True: print "".join(choice('/\\') for i in range(40))

  14. Reminded me of DataGlyphs by tepples · · Score: 4, Informative

    It's just randomly printing forward and backward slashes, which line up because of the font. It's nifty, but hardly amazing.

    And in fact, it appears Slashdot ran an article on this a decade ago when it was called DataGlyphs.

  15. /., in collaboration with the Erowid Vault by Press2ToContinue · · Score: 2

    /., in collaboration with the Erowid Vault. brings you "get high and watch this code run." Wow, it's so cool.

    --
    Sent from my ENIAC
  16. Yes Captain by Anonymous Coward · · Score: 2, Funny

    that's what our sensors are picking up.

  17. 80s Flashback by JoeCommodore · · Score: 2

    I remember doing that in 1980something on the PET (maybe not that line, but the logic was the same). IIRC it was a type-in along with a bunch of other cheap BASIC graphics routines in a Creative Computing - later I'm sure it showed up in RUN or Transactor for the VIC/64.

    It was cool for maybe a couple hours... along with thoughts of what games could I use it with (that's how we developed game ideas old-school style, starting with cool little snippets like this.)

    --
    "Enjoy what you're doing! If it becomes drudgery, you're doing it wrong!" - Jim Butterfield
  18. Bah why write the code... by ducomputergeek · · Score: 3, Informative
    --
    "The problem with socialism is eventually you run out of other people's money" - Thatcher.
  19. A meditation by LihTox · · Score: 3, Informative

    From page 4 of the book:

    This book is unusual in its focus on a single line of code, an extremely concise BASIC program that is simply called 10 PRINT throughout. Studies of individual, unique works abound in the humanities. Roland Barthes’s S/Z, Samuel Beckett’s Proust, Rudolf Arnheim’s Genesis of a Painting: Picasso’s Guernica, Stuart Hall et al.’s Doing Cultural Studies: The Story of the Sony Walkman, and Michel Foucault’s Ceci n’est pas une pipe all exemplify the sort of close readings that deepen our understanding of cultural production, cultural phenomena, and the Western cultural tradition. While such literary texts, paintings, and consumer electronics may seem significantly more complex than a one-line BASIC program, undertaking a close study of 10 PRINT as a cultural artifact can be as fruitful as close readings of other telling cultural artifacts have been.

    In short, this is not a programming book, but it appears to be a book of cultural anthropology about programming. Or perhaps a meditation which starts with one simple starting point and branching out in many different directions. Criticizing the program "10 PRINT" as trivial rather misses the point, I should think.

  20. Re:Tricks with Slash and Backslash by discord5 · · Score: 3, Funny

    perl -e 'while (1) { print rand() > .5 ? "/" : "\\" }';

    Quick, claim it doesn't have a loop and write a book. :)

  21. 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.
  22. 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 ?
  23. Diablo by dmomo · · Score: 3, Funny

    Wow. Who would have known that the code for Diablo is so simple.

  24. Re:It's 2012 by Tough+Love · · Score: 2

    It eventually fills up the galaxy with ascii chars and the world ends.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
  25. Fun bit of computing history there by AllanNienhuis · · Score: 2

    This type of thing has a pretty honourable history. Back in the day, there was actually a (small?) subculture of enthusiasts who experimented with one-line or two-line basic programs (I'm sure this was the case with other platforms/languages as well). Similar to the whole demogroup scene I guess - a way of experimenting and showing off. Each line number of a basic program was limited to I think 256 characters. It could have as many statements (separated by colons) as desired. Some folks would go so far as to 'poke' machine code instructions and then jmp/execute that machine code, but I think that was frowned upon a bit as that seemed a bit like cheating... :) There were contests and so on, and popular magazines like 'Nibble' would regularly publish these mini-programs which thousands of us would type into our computers. In doing so many of us became fascinated by what was possible, even if it promoted a rather unhealthy obfuscated code style... Naturally today with almost unlimited computing resources available to every programmer, this isn't amazing at all. But back then, this sort of thing _was_ pretty amazing - even if this isn't a particularly shining example of it. Some folks were able to generate real, playable games, or amazing visual animation effects in less than 500 bytes of source. It makes me want to drag out the old Apple II emulator and play around! Man, I wish I hadn't sold that old doorstop apple II... :)

    --
    Don't judge me based on my high slashdot user id!
  26. i prefer c over basic by hanz88 · · Score: 3, Interesting

    int main(){for(;;)putchar("\\/"[rand()%2]);}

  27. Book not so bad by HuguesT · · Score: 2

    The book is worth reading, it retells many things from the beginning of personal computing, exploring subjects along the way. the 10 PRINT one-liner is the motivation but not the topic.

    Cheers.

  28. An explanation of the code by Anonymous Coward · · Score: 2, Informative

    If you need help with the code, here's a simple explanation:

    The RND(1) function will return a floating point value between 0 and 1 (technically, this is 0 to 0.999... but let's just call it 0 to 1). So the part of the code that says 205.5 + RND(1) simply returns a value somewhere between 205.5 and 206.5. Assuming the RND(1) function is a good random number generator, that means half of the numbers will be between 205.5 and 205.9999..., and half will be between 206.0 and 206.5.

    The CHR$() function pulls a single character from the Commodore 64's PETSCII table. The address is always an integeter, so if you ask for CHR$(205.999), that's the same as CHR$(205). Similarly, asking for CHR$(206.5) is the same as CHR$(206).

    In the PETSCII table, character 205 is a single backslash, and character 206 is a single forward slash. So what the code is doing is very simple: it simply prints either a forward slash or a backslash, and keeps doing it because it loops back to itself.

    This same code won't work on Linux or Windows/DOS because in the ASCII table, the forward slash is 057, and the backslash is 134. For ASCII systems, you'd need to (basically) flip a coin and print "\" if heads, and "/" if tails.

    And that's all it does. There's no magic. No guarantee it is even a solvable maze. It just looks pretty.

    -jh

  29. Re:anyone have the postscript version? by narcc · · Score: 2

    Here you go:

    http://peter.sorotokin.com/maze/Maze.html

    It's just below the java applet.

  30. Re:Record breaking by Psychotria · · Score: 3, Funny

    It seems as if every single user on Slashdot felt they had to chime in to alert the world that 10 GOTO 10 is in fact a loop, as if everybody else hadn't already made that point.

    The thing is, GOTO 10 is a loop. Therefore it's not without a loop. QED.