Skip to content

Instantly share code, notes, and snippets.

@edwingustafson
Last active January 27, 2022 13:50
Show Gist options
  • Select an option

  • Save edwingustafson/3a8778155c0402a8ab617bf287d3ba54 to your computer and use it in GitHub Desktop.

Select an option

Save edwingustafson/3a8778155c0402a8ab617bf287d3ba54 to your computer and use it in GitHub Desktop.
Maze generator in Java as executable script
#!/usr/bin/env -S java --source 11
import java.util.Random;
import java.util.concurrent.TimeUnit;
/**
Based on the Commodore 64 single line maze generator
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
as described at https://10print.org/
Sample output:
$ ./Maze
╱╱╲╲╲╲╲╲╲╲╲╱╲╲╲╱╲╲╲╲╲╱╱╲╱╱╱╲╱╲╱╲╲╲╱╲╲╲╲╱╲╱╱╱╱╲╲╲╱╱╱╱╲╲╲╲╲╱╲╲
╲╱╲╱╲╱╲╱╲╱╲╲╱╲╱╱╱╱╲╱╲╱╱╲╲╱╲╲╱╲╱╱╲╲╱╱╱╱╲╱╱╲╱╲╱╱╱╱╲╱╱╲╲╱╱╲╱╲╱╲
╲╱╱╲╱╲╲╲╱╲╲╱╱╱╲╱╱╱╲╱╱╲╲╲╱╲╱╲╲╱╲╱╲╲╱╲╲╲╲╱╲╲╱╲╲╲╱╱╲╲╱╱╱╲╲╱╲╱╱╱
╲╲╱╲╱╲╱╱╲╱╲╱╱╲╱╲╲╲╱╲╱╲╲╲╲╲╲╲╲╲╱╲╲╱╱╱╱╲╲╱╱╲╲╲╲╱╲╱╱╲╲╱╱╱╲╱╱╱╱╱
╱╱╱╲╱╱╱╲╲╲╲╲╲╱╲╱╲╱╲╲╱╲╱╲╱╱╱╲╲╲╲╱╲╱╲╲╱╲╱╲╱╱╱╱╲╲╲╱╱╲╱╱╲╲╲╱╱╱╲╲
╲╱╲╲╲╲╱╲╲╱╱╲╱╱╲╲╱╱╲╲╱╲╲╲╲╱╱╲╲╱╱╲╱╱╱╱╱╱╱╲╱╲╲╲╲╱╱╱╱╱╱╲╱╲╲╱╱╲╲╱
╱╲╲╱╲╱╲╲╱╱╱╱╲╱╱╲╲╲╱╱╲╲╱╱╲╲╲╱╱╱╲╲╱╱╲╱╲╲╲╲╱╱╲╱╱╲╲╱╲╱╲╱╲╲╱╱╲╲╱╲
╱╱╱╱╲╲╲╱╲╱╱╲╱╱╱╲╱╱╱╲╲╲╱╲╱╲╲╲╲╱╲╱╲╱╱╲╱╲╱╲╱╱╲╲╱╱╲╲╲╲╲╱╱╲╲╲╱╱╱╱
╲╲╱╲╲╱╱╲╲╱╱╲╱╲╲╲╱╱╲╲╲╱╱╲╱╱╱╲╱╲╱╱╲^C
*/
class Maze {
static final char UP = '\u2571';
static final char DOWN = '\u2572';
static final Random random = new Random();
public static void main(final String args[]) throws InterruptedException {
for(;;) {
System.out.print(random.nextBoolean() ? UP : DOWN);
TimeUnit.MILLISECONDS.sleep(90);
}
}
}
// vi:syntax=java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment