Implement fill function
This commit is contained in:
parent
59ec1cbb64
commit
f407a8e2a8
1 changed files with 14 additions and 1 deletions
15
maze.py
15
maze.py
|
|
@ -150,7 +150,20 @@ class Maze:
|
||||||
coordinates as tuples in the points list:
|
coordinates as tuples in the points list:
|
||||||
fill([(x1, y1), (x2, y2)])
|
fill([(x1, y1), (x2, y2)])
|
||||||
"""
|
"""
|
||||||
pass
|
if points is None:
|
||||||
|
points = []
|
||||||
|
for i in range((self.x//10)*(self.y//10)): # add random points
|
||||||
|
points.append((random.randrange(self.x), random.randrange(self.y)))
|
||||||
|
for i in range(len(points)): # add points to map
|
||||||
|
x, y = points[i]
|
||||||
|
self.set_cell(x, y, i)
|
||||||
|
for xn, yn in self.get_neighbours(x, y):
|
||||||
|
cell = self.get_cell(xn, yn)
|
||||||
|
if type(cell) is int and not cell == i:
|
||||||
|
self.replace(cell, i)
|
||||||
|
for x, y in points:
|
||||||
|
self.mark_adjacent(x, y)
|
||||||
|
self.points = points
|
||||||
|
|
||||||
def generate(self, x_start, y_start, x_end, y_end, gif_path=None):
|
def generate(self, x_start, y_start, x_end, y_end, gif_path=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue