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.
What is
10 something: GOTO 10
if not an (endless) loop?
...when the summary does not know what a loop is.
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.
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”.)
That....is.....a loop.......
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?!
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 );
}
}
Things you think are in the Constitution, but are not.
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.
Frontpage slashdot story with a 10 GOTO 10 and saying it's not a loop?
Dudes, just what the fuck. I ask you that.
This article fails in English and fails in the content. Booya.
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.
when there's a perl module for that:
http://search.cpan.org/~jgamble/Games-Maze-1.08/lib/Games/Maze.pm
"The problem with socialism is eventually you run out of other people's money" - Thatcher.
From page 4 of the book:
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.
perl -e 'while (1) { print rand() > .5 ? "/" : "\\" }';
Quick, claim it doesn't have a loop and write a book. :)
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.
Wow. Who would have known that the code for Diablo is so simple.
Sorry, what was I thinking? This is obviously more elegant:
tr -dc '/\' </dev/urandom
God, root, what is difference ?
int main(){for(;;)putchar("\\/"[rand()%2]);}
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.