An interesting Bash for generating maze called ASCII maze:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1HI_4kv7Zgf9_1_Ts651sBX0ou18Uh7TfMgx9zTnURwbYWVgy5nOa4l-Edg7hcjinLWAbF71G5EW4fIHS89KkplMlWAeRVP3WBYkxQTk0Q_WkVaNZ5d8gDakfX_PSvx_GIW0FITa2DmI/s800/ASCII-maze.gif

It’s a port of Jamie Buck’s Recursive Backtracking‘s Ruby implementation, there are also other languages re-implementations, such as C, C#, or Groovy. I thought about porting to Python, but didn’t really think it’s worth doing.

The most important drawback is the performance as you should have guessed since it’s implemented in Bash, shell scripting isn’t made for mass calculations. With terminal size 80x25, it took 8.474 seconds to generate one maze, really really slow. The C implementation from the comment, only took 0.026 seconds, although I don’t think it implements correctly, the output maze seems off.

Unfortunately, I couldn’t time the original Ruby code since I don’t have Ruby or any other languages, they couldn’t be worse than Bash’s performance, right?

I thought about contribute to the Bash code for Unicode or even colors, but by looking at its performance, it’s not worth. The ASCII maze looks a bit of odd, if we have some Unicode to prettify maze, that would be perfect.

So what could this to be used for? It’s possible to use this as a screensaver or just for taking a screenshot, but you probably don’t want to use Bash.