| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 #!/usr/bin/env python | 
|  | 2 # -*- coding: utf-8 -*- | 
|  | 3 ## @brief Generate a simple maze pattern. | 
|  | 4 # | 
|  | 5 #Tip of the hat to both the original Commodore 64 program and the book | 
|  | 6 #"10 Print Chr$(205.5+rnd(1)); Goto 10" that it inspired. | 
|  | 7 # | 
|  | 8 #Note that this is neither the shortest nor the most faithful way to | 
|  | 9 #write this program in Python. Rather it is being used as a simple | 
|  | 10 #example for the doxypypy Doxygen input filter for Python and makes use | 
|  | 11 #of features like keyword arguments and generators and has a docstring | 
|  | 12 #that documents them both appropriately. | 
|  | 13 # | 
|  | 14 | 
|  | 15 | 
|  | 16 from sys import stdout | 
|  | 17 from random import choice | 
|  | 18 | 
|  | 19 | 
|  | 20 ## @brief     Generates a single block of a maze. | 
|  | 21 # | 
|  | 22 #    This simple generator randomly picks a character from a list (the two | 
|  | 23 #    diagonal lines by default) and returns it on each iteration. | 
|  | 24 # | 
|  | 25 # | 
|  | 26 # @param                blockOptions    The list of characters to choose from. | 
|  | 27 # | 
|  | 28 # @return | 
|  | 29 #        A single character chosen from blockOptions. | 
|  | 30 # | 
|  | 31 | 
|  | 32 def generateBlock(blockOptions=u"╱╲"): | 
|  | 33     while True: | 
|  | 34         yield choice(blockOptions) | 
|  | 35 | 
|  | 36 # Establish our block generator and generate a series of blocks. | 
|  | 37 blockGenerator = generateBlock() | 
|  | 38 blockCount = 0 | 
|  | 39 while blockCount < 3200: | 
|  | 40     blockCount += 1 | 
|  | 41     print(next(blockGenerator)), | 
|  | 42     # Deal with Python's extra space print weirdness. | 
|  | 43     stdout.softspace = False | 
| OLD | NEW | 
|---|