The stupid question is the question not asked | |
PerlMonks |
Maze and Snake!by chipmunk (Parson) |
on Aug 15, 2001 at 19:55 UTC ( [id://105074]=obfuscated: print w/replies, xml ) | Need Help?? |
You've probably seen a maze-solving program before. For example, there are many screen savers that draw a maze on the screen and then solve it.
Here are two companion scripts that implement this as a JAPH!
The first one is maze.pl, the maze-generating script. By default, it draws a 9 by 33 maze (21 characters by 70 characters), but you can also specify height and width on the command line, such as perl maze.pl 8 20 .
The second one is snake.pl, which solves a maze generated by maze.pl. It does the old trick of always following the right-hand wall.
You can pass the output from maze.pl directly into snake.pl (perl maze.pl | perl snake.pl) or you can save the maze to a file and solve it later (perl maze.pl > mymaze; perl snake.pl mymaze). A few caveats for these scripts:
The maze generating algorithm was taken from Games::MazeD2 by John M. Gamble. Enjoy!
Back to
Obfuscated Code
|
|