diff options
Diffstat (limited to 'binary_tree.py')
-rw-r--r-- | binary_tree.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/binary_tree.py b/binary_tree.py new file mode 100644 index 0000000..b125539 --- /dev/null +++ b/binary_tree.py @@ -0,0 +1,17 @@ +import random + + +class BinaryTree(object): + def on(grid): + for cell in grid.each_cell(): + neighbors = [] + if cell.north: + neighbors.append(cell.north) + if cell.east: + neighbors.append(cell.east) + + if neighbors: + neighbor = random.choice(neighbors) + cell.link(neighbor) + + return grid |