diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2016-07-23 01:14:27 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2016-07-23 01:14:27 +0200 |
commit | e1ed22231d955eedf3895adf72fd3fbbeb133376 (patch) | |
tree | 7741d2c4cfa2eac191def2a272b1cfa7dad57d95 /binary_tree.py | |
download | maze-e1ed22231d955eedf3895adf72fd3fbbeb133376.tar.xz |
Initial commit
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
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 |