-
-
Save edwingustafson/3a8778155c0402a8ab617bf287d3ba54 to your computer and use it in GitHub Desktop.
Maze generator in Java as executable script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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