maze.py: One more, just for fun

This is really just a scrappy little script, and not much of a program. But here goes: This is maze.py.

2014-01-27-lv-r1fz6-maze.py

And I’ll be darned if I can remember where it came from. 😕 To be clear, it’s not mine. I didn’t write it.

The intent, or the original illusion, was to connect the corners and it took on the appearance of a diagonal maze, with multicolored walls.

I say “original” because I replaced the diagonal characters with forward and back slashes. The other characters don’t appear in my console character set, so I just get multicolor boxes. 😦

All in all, probably not as convincing as the old Windows 3D maze screensaver, but maze.py has got moxie. I give it that.

Since there’s a next-to-zero percent chance that I might find the original script again, I leave it here for you to copy and paste.

#!/usr/bin/env python

from random import choice
from sys import stdout as o
from time import sleep

cols = ['\033[30m', '\033[31m', '\033[32m', '\033[33m', '\033[34m', '\033[35m', '\033[36m', '\033[37m']
endcol = '\033[0m'
l = ''
ch = u"/\\"

while True:
	l = "%s%s" % (choice(cols), choice(ch))
	o.flush()
	o.write(l)
	o.write(endcol)
	sleep(0.005)

Yes, it’s a python toy. There are some who say that python will drag down very old machines, and I can empathize with that. I’ve seen it happen.

Something tells me though, that if you run this on an old Pentium machine, it won’t be python that makes it seem slow. 😉

2 thoughts on “maze.py: One more, just for fun

  1. livibetter

    I think the true “original” is a shell script:

    yes ‘c=(╱ ╲);printf ${c[RANDOM%2]}’|bash

    I can’t remember where I first read it (maybe your old blog?), but I just searched it and found that one-liner. Say what? Colors? Here you go with my slight modification:

    yes ‘c=(╱ ╲);printf \\e[3$((1+RANDOM%6))m${c[RANDOM%2]}’|bash

Comments are closed.