def fall(self, limx, direction, matrix, ladder, floor, wall, coin, donkey, fireballs): self.collectCoin(matrix, coin) #direction of fall if direction == Direction.EAST: offset = self.velx elif direction == Direction.WEST: offset = -1*self.velx else: offset = 0 if ((direction == Direction.EAST and matrix.SE_of(self) == matrix.symbol) or (direction == Direction.WEST and matrix.SW_of(self) == matrix.symbol) or matrix.getPosition(self) == matrix.symbol): while matrix.grid[self.y+self.vely][self.x+offset] in [matrix.symbol, 'o', coin.symbol]: self.collectCoin(matrix, coin) matrix.update_character_in_matrix(self.y, self.x, self.trace) matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap) for fireball in fireballs: matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.trace) fireball.move(limx, matrix, self, ladder, wall, floor, 0) matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.symbol) matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.trace) donkey.move(matrix.grid, self, 0) matrix.update_coins_in_matrix(coin.coordinates, coin.symbol) matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.symbol) self.y += self.vely if matrix.grid[self.y][self.x+offset] != wall: self.x += offset matrix.update_character_in_matrix(self.y, self.x, self.symbol) # time.sleep(0.05) matrix.print_matrix(self.score, self.lives)
def climb_down(self, matrix, player, ladder, wall, floor, autocall = 1): while matrix.S_of(self) not in [floor.symbol, wall]: self.checkCollision(player) matrix.update_character_in_matrix(self.y, self.x, self.trace) matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap) self.y += self.vely matrix.update_character_in_matrix(self.y, self.x, self.symbol) if autocall == 1: time.sleep(0.02) matrix.print_matrix(player.score, player.lives)
def fall(self, matrix, player, ladder, wall, floor, autocall = 1): offset = self.velx while matrix.SE_of(self) == matrix.symbol or matrix.SW_of(self) == matrix.symbol: matrix.update_character_in_matrix(self.y, self.x, self.trace) matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap) self.y += self.vely if matrix.grid[self.y][self.x+offset] != wall: self.x += offset matrix.update_character_in_matrix(self.y, self.x, self.symbol) if autocall == 1: time.sleep(0.02) matrix.print_matrix(player.score, player.lives)
def main(): m = [[1, 4, 6], [5, 4, 4], [0, 0, 1]] b = [[6, 3, 3], [12, 4, 6], [6, 5, 5]] m = matrix.scale_row(b, 2, "mul", 2) f = matrix.scale_row(m, 0, "div", 3) matrix.print_matrix(m) matrix.print_matrix(f) w = matrix.get_vector(m, 1) matrix.print_matrix(w) k = [[2, 2], [1, 0], [9, 7], [6, 6]] c = [[2, 6, 3], [7, 7, 7]] res = matrix.multiply_matrix(k, c) matrix.print_matrix(res)
def test(): V = [1,2,3,4] WE = [(1,2,5), (2,3,1), (3,1,8), (3,4,3), (4,1,2)] print """ Initial Data """ print "V =", V print "WE =", WE print """ Determine safe infinity. Safe infinity equals sum of all weights + 1. """ infinity = 1 for (u,v,w) in WE: infinity = infinity + w print "infinity =", infinity n = len(V) print """ Original weights. """ W = matrix.make(n, n, infinity) for (u,v,w) in WE: W[u-1][v-1] = w for i in xrange(n): W[i][i] = 0 matrix.print_matrix(W, infinity) print """ Repeated squaring """ D = all_pairs_shortest_paths(W, infinity) matrix.print_matrix(D, infinity) print """ Floyd-Warshall """ D = floyd_warshall(W, infinity) matrix.print_matrix(D, infinity)
def test(): V = [1, 2, 3, 4] WE = [(1, 2, 5), (2, 3, 1), (3, 1, 8), (3, 4, 3), (4, 1, 2)] print """ Initial Data """ print "V =", V print "WE =", WE print """ Determine safe infinity. Safe infinity equals sum of all weights + 1. """ infinity = 1 for (u, v, w) in WE: infinity = infinity + w print "infinity =", infinity n = len(V) print """ Original weights. """ W = matrix.make(n, n, infinity) for (u, v, w) in WE: W[u - 1][v - 1] = w for i in xrange(n): W[i][i] = 0 matrix.print_matrix(W, infinity) print """ Repeated squaring """ D = all_pairs_shortest_paths(W, infinity) matrix.print_matrix(D, infinity) print """ Floyd-Warshall """ D = floyd_warshall(W, infinity) matrix.print_matrix(D, infinity)
import matrix mat = matrix.generate_matrix(10,10) mat[0][0] = 7 matrix.print_matrix(mat)
points = [] for y in range(len(maze)): for x in range(len(maze[0])): if maze[y][x] == 0: points.append(Point(x, y)) return points points = validPoints(maze) startPos = r.choice(points) endPos = r.choice(points) start = Node(startPos, None) end = Node(endPos, None) path = aStar(start, end, maze) for y in range(len(maze)): for x in range(len(maze[0])): if maze[y][x] == 0: maze[y][x] = '.' else: maze[y][x] = '#' for i in path: maze[i.y][i.x] = 'X' matrix.print_matrix(maze) # https://www.growingwiththeweb.com/2012/06/a-pathfinding-algorithm.html
def test_q4(): print("-------------------------------------------") print("Testing Q4: Matrix Library") filename = 'q4_solution.txt' outFile = open(filename, 'w') print() outFile.write('1- Testing is_vector:\n') outFile.write('is_vector({}) = {}\n'.format([], matrix.is_vector([]))) outFile.write('is_vector({}) = {}\n'.format([10], matrix.is_vector([10]))) outFile.write('is_vector({}) = {}\n'.format([10, 20], matrix.is_vector([10, 20]))) outFile.write('is_vector({}) = {}\n'.format(10, matrix.is_vector(10))) outFile.write('is_vector({}) = {}\n'.format([3, 4.5], matrix.is_vector([3, 4.5]))) outFile.write('is_vector({}) = {}\n'.format([[]], matrix.is_vector([[]]))) outFile.write('is_vector({}) = {}\n'.format([[1, 2], [3, 4]], matrix.is_vector([[1, 2], [3, 4]]))) outFile.write('\n') outFile.write('2- Testing is_matrix') A = [] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = [5] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = [[1, 2], [3, 4]] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = [[1], [2], [3]] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = [[1, 2, 3], [4, 5, 6]] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = 5 outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = [5.5] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) A = [[1, 2, 3], [4, 5]] outFile.write('is_matrix({}) = {}\n'.format(A, matrix.is_matrix(A))) outFile.write('\n') print('3- Testing print_matrix') A = [] print('print_matrix({})='.format(A)) matrix.print_matrix(A) A = [10, 20, 30] print('print_matrix({})='.format(A)) matrix.print_matrix(A) A = [[10], [20], [30]] print('print_matrix({})='.format(A)) matrix.print_matrix(A) A = [[10, 20, 30], [40, 50, 60], [70, 80, 10]] print('print_matrix({})='.format(A)) matrix.print_matrix(A) A = [[10, 20, 30], [40, 50, 60], [70, 80]] print('print_matrix({})='.format(A)) print(matrix.print_matrix(A)) print() outFile.write('4/5/6- Testing size functions\n') A = [] outFile.write('get_rowCount({}) = {}\n'.format(A, matrix.get_rowCount(A))) outFile.write('get_ColumnCount({}) = {}\n'.format( A, matrix.get_columnCount(A))) outFile.write('get_size({}) = {}\n'.format(A, matrix.get_size(A))) outFile.write('\n') A = [1, 2, 3] outFile.write('get_rowCount({}) = {}\n'.format(A, matrix.get_rowCount(A))) outFile.write('get_ColumnCount({}) = {}\n'.format( A, matrix.get_columnCount(A))) outFile.write('get_size({}) = {}\n'.format(A, matrix.get_size(A))) outFile.write('\n') A = [[1, 2], [3, 4], [5, 6]] outFile.write('get_rowCount({}) = {}\n'.format(A, matrix.get_rowCount(A))) outFile.write('get_ColumnCount({}) = {}\n'.format( A, matrix.get_columnCount(A))) outFile.write('get_size({}) = {}\n'.format(A, matrix.get_size(A))) outFile.write('\n') A = [[1, 2], [3]] outFile.write('get_rowCount({}) = {}\n'.format(A, matrix.get_rowCount(A))) outFile.write('get_ColumnCount({}) = {}\n'.format( A, matrix.get_columnCount(A))) outFile.write('get_size({}) = {}\n'.format(A, matrix.get_size(A))) outFile.write('\n') outFile.write('7- Testing is_square\n') A = [] outFile.write('is_square({}) = {}\n'.format(A, matrix.is_square(A))) A = [5] outFile.write('is_square({}) = {}\n'.format(A, matrix.is_square(A))) A = [5, 6] outFile.write('is_square({}) = {}\n'.format(A, matrix.is_square(A))) A = [[1, 2], [3, 4]] outFile.write('is_square({}) = {}\n'.format(A, matrix.is_square(A))) A = [5.5] outFile.write('is_square({}) = {}\n'.format(A, matrix.is_square(A))) outFile.write('\n') outFile.write('8/9/10- Testing getter functions\n') A = [[1, 2, 3], [4, 5, 6]] i = 0 j = 1 outFile.write('get_row({},{}) = {}\n'.format(A, i, matrix.get_row(A, i))) outFile.write('get_Column({},{}) = {}\n'.format(A, j, matrix.get_column(A, j))) outFile.write('get_element({},{},{}) = {}\n'.format( A, i, j, matrix.get_element(A, i, j))) outFile.write('\n') i = 2 j = 2 outFile.write('get_row({},{}) = {}\n'.format(A, i, matrix.get_row(A, i))) outFile.write('get_Column({},{}) = {}\n'.format(A, j, matrix.get_column(A, j))) outFile.write('get_element({},{},{}) = {}\n'.format( A, i, j, matrix.get_element(A, i, j))) outFile.write('\n') i = 1 j = 3 outFile.write('get_row({},{}) = {}\n'.format(A, i, matrix.get_row(A, i))) outFile.write('get_Column({},{}) = {}\n'.format(A, j, matrix.get_column(A, j))) outFile.write('get_element({},{},{}) = {}\n'.format( A, i, j, matrix.get_element(A, i, j))) outFile.write('\n') A = [[1, 2, 3], []] outFile.write('get_row({},{}) = {}\n'.format(A, i, matrix.get_row(A, i))) outFile.write('get_Column({},{}) = {}\n'.format(A, j, matrix.get_column(A, j))) outFile.write('get_element({},{},{}) = {}\n'.format( A, i, j, matrix.get_element(A, i, j))) outFile.write('\n') outFile.write('11- Testing new_matrix\n') r = 0 c = 0 pad = 0 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) c = 1 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) r = 1 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) r = 2 c = 1 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) c = 2 r = 1 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) c = 3 r = 3 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) r = -1 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) r = 3 c = -5 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) c = 5 pad = 3.5 outFile.write('new_matrix({},{},{})=\n{}\n'.format( r, c, pad, matrix.new_matrix(r, c, pad))) outFile.write('\n') outFile.write('12- Testing get_I\n') size = -1 outFile.write('get_I({}) = {}\n'.format(size, matrix.get_I(size))) size = 0 outFile.write('get_I({}) = {}\n'.format(size, matrix.get_I(size))) size = 1 outFile.write('get_I({}) = {}\n'.format(size, matrix.get_I(size))) size = 2 outFile.write('get_I({}) = {}\n'.format(size, matrix.get_I(size))) size = 3 outFile.write('get_I({}) = {}\n'.format(size, matrix.get_I(size))) outFile.write('\n') outFile.write('13- Testing is_identity\n') A = [1] outFile.write('is_identity({}) = {}\n'.format(A, matrix.is_identity(A))) A = matrix.get_I(3) outFile.write('is_identity({}) = {}\n'.format(A, matrix.is_identity(A))) A = [[1, 0], [1, 1]] outFile.write('is_identity({}) = {}\n'.format(A, matrix.is_identity(A))) A = [[1, 0], [0, 1, 0]] outFile.write('is_identity({}) = {}\n'.format(A, matrix.is_identity(A))) outFile.write('\n') outFile.write('14- Testing scalar_mul\n') A = [[1, 2], [3, 4]] c = 10 outFile.write('scalar_mul({},{}) = {}\n'.format(A, c, matrix.scalar_mul(c, A))) A = [1, 2, 3, 4] outFile.write('scalar_mul({},{}) = {}\n'.format(A, c, matrix.scalar_mul(c, A))) A = [] outFile.write('scalar_mul({},{}) = {}\n'.format(A, c, matrix.scalar_mul(c, A))) A = [1, 2, 3, [4]] outFile.write('scalar_mul({},{}) = {}\n'.format(A, c, matrix.scalar_mul(c, A))) A = [[1, 2], [3, 4]] c = [10] outFile.write('scalar_mul({},{}) = {}\n'.format(A, c, matrix.scalar_mul(c, A))) outFile.write('\n') outFile.write('15- Testing mul\n') A = [[1, 2], [3, 4]] B = [[10, 20], [30, 40]] outFile.write('mul({},{})=\n{}\n'.format(A, c, matrix.mul(A, B))) A = [[1, 2, 3], [5, 6, 7]] B = [[10, 20], [30, 40], [50, 60]] outFile.write('mul({},{})= {}\n'.format(A, c, matrix.mul(A, B))) A = [5] B = [10] outFile.write('mul({},{})= {}\n'.format(A, B, matrix.mul(A, B))) A = [0, 1, 2] B = [[0], [1], [2]] outFile.write('mul({},{})= {}\n'.format(A, B, matrix.mul(A, B))) A = [[0], 1] B = [1, 0] outFile.write('mul({},{})= {}\n'.format(A, B, matrix.mul(A, B))) A = [1, 0] B = [[0], 1] outFile.write('mul({},{})= {}\n'.format(A, B, matrix.mul(A, B))) A = [[1, 2, 3], [5, 6, 7]] B = [[10, 20], [30, 40], [50, 60]] outFile.write('mul({},{})= {}\n'.format(B, A, matrix.mul(B, A))) A = [[1, 2, 3], [5, 6, 7]] B = [[10, 20], [30, 40]] outFile.write('mul({},{})= {}\n'.format(A, B, matrix.mul(A, B))) outFile.write('\n') outFile.write('16- Testing matrix_mod\n') A = [[1, 2], [3, 4]] m = 2 outFile.write('matrix_mod({},{})= {}\n'.format(A, m, matrix.matrix_mod(A, m))) A = [1, 2, 3, 4] m = 2 outFile.write('matrix_mod({},{})= {}\n'.format(A, m, matrix.matrix_mod(A, m))) A = [[3], [5]] m = 3 outFile.write('matrix_mod({},{})= {}\n'.format(A, m, matrix.matrix_mod(A, m))) A = [[3], [5]] m = 0 outFile.write('matrix_mod({},{})= {}\n'.format(A, m, matrix.matrix_mod(A, m))) A = [3, [5]] m = 6 outFile.write('matrix_mod({},{})= {}\n'.format(A, m, matrix.matrix_mod(A, m))) outFile.write('\n') outFile.write('17- Testing det\n') A = [[1, 2], [3, 4]] outFile.write('det({})= {}\n'.format(A, matrix.det(A))) A = [10] outFile.write('det({})= {}\n'.format(A, matrix.det(A))) A = [[1, 1, 1], [2, 2, 2], [3, 3, 3]] outFile.write('det({})= {}\n'.format(A, matrix.det(A))) A = [[1, 1, 1], [2, 2]] outFile.write('det({})= {}\n'.format(A, matrix.det(A))) outFile.write('\n') outFile.write('18- Testing inverse\n') A = [[1, 4], [8, 11]] m = 26 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) A = [[4, 3], [1, 1]] m = 5 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) A = [[1, 4], [8, 10]] m = 26 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) A = [1, 4, 8, 10] m = 15 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) A = [[4, 3], [1, 1]] m = -5 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] m = 7 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) A = [[1, 2, 3], [4, 5]] m = 7 outFile.write('inverse({},{})= {}\n'.format(A, m, matrix.inverse(A, m))) outFile.close() print('Comparing q4_solution with q4_sample:') print(utilities_A4.compare_files('q4_solution.txt', 'q4_sample.txt')) print() print("-------------------------------------------")
width = 100 height = 40 grid = matrix.generate_matrix(width, height, 0) # set starting points to random values fill1Queue = [ {'x': r.randint(0,width-1), 'y':r.randint(0,height-1)} ] fill2Queue = [ {'x': r.randint(0,width-1), 'y':r.randint(0,height-1)} ] fill3Queue = [ {'x': r.randint(0,width-1), 'y':r.randint(0,height-1)} ] while TilesLeft(): while len(fill1Queue) > 0 or len(fill2Queue) > 0 or len(fill3Queue) > 0: # if a queue has tiles left, sets the queue to the result # of the floodfill method # specifies different values for each queue if (len(fill1Queue) > 0): fill1Queue = FillFrom(fill1Queue, "*") if (len(fill2Queue) > 0): fill2Queue = FillFrom(fill2Queue, "#") if (len(fill3Queue) > 0): fill3Queue = FillFrom(fill3Queue, ".") # draw the fill each loop # os.system('cls') # matrix.print_matrix(grid) matrix.print_matrix(grid)
import matrix x = matrix.generate_matrix(20, 20) x[12][7] = 4 matrix.print_matrix(x)
def jump(self, direction, limx, limy, matrix, ladder, floor, wall, coin, donkey, fireballs, max_height = 2, multiplier = 3): self.collectCoin(matrix, coin) #direction of jump if self.motion == Motion.RIGHT: offset = multiplier*self.velx elif self.motion == Motion.LEFT: offset = -1*multiplier*self.velx elif self.motion == Motion.REST: offset = 0 matrix.update_character_in_matrix(self.y, self.x, self.trace) #init jump if direction == Direction.JUMP and matrix.S_of(self) in [wall, floor.symbol, ladder.symbol]: maxjump = self.y-max_height initial_height = self.y #up while self.y > maxjump: matrix.update_character_in_matrix(self.y, self.x, self.trace) matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap) for fireball in fireballs: matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.trace) fireball.move(limx, matrix, self, ladder, wall, floor, 0) matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.symbol) matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.trace) donkey.move(matrix.grid, self, 0) matrix.update_coins_in_matrix(coin.coordinates, coin.symbol) matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.symbol) if matrix.N_of(self) != floor.symbol or getPosition(self) != floor.symbol: if matrix.getPosition(self) == ladder.symbol and self.motion != Motion.REST: break self.y -= self.vely else: break if self.x + offset not in range(1,limx-2): if self.motion == Motion.RIGHT: self.x = limx-2 offset = 0 elif self.motion == Motion.LEFT: self.x = 1 offset = 0 else: self.x += offset matrix.update_character_in_matrix(self.y, self.x, self.symbol) time.sleep(0.05) matrix.print_matrix(self.score, self.lives) #down while matrix.S_of(self) in [matrix.symbol, 'o', coin.symbol]: self.collectCoin(matrix, coin) matrix.update_character_in_matrix(self.y, self.x, self.trace) matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap) for fireball in fireballs: matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.trace) fireball.move(limx, matrix, self, ladder, wall, floor, 0) matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.symbol) matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.trace) donkey.move(matrix.grid, self, 0) matrix.update_coins_in_matrix(coin.coordinates, coin.symbol) matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.symbol) if matrix.getPosition(self) == ladder.symbol and self.motion != Motion.REST: break self.y += self.vely if self.x + offset not in range(1,limx-1): if self.motion == Motion.RIGHT: self.x = limx-2 offest = 0 elif self.motion == Motion.LEFT: self.x = 1 offset = 0 else: self.x += offset matrix.update_character_in_matrix(self.y, self.x, self.symbol) time.sleep(0.05) matrix.print_matrix(self.score, self.lives)
asciiMaze = CreateASCIIMaze(grid) startConnecting = time.time() carveTime = startConnecting - fullStart tilesInRooms = [] regions = [] notInRoom = TilesNotInRooms() while len(notInRoom) > 0: region = FillFrom(notInRoom[0]) for i in region: tilesInRooms.append(i) regions.append(region) notInRoom = TilesNotInRooms() ''' checks region counting for i in range(len(regions)): for cell in regions[i]: asciiMaze[cell['y']][cell['x']] = i matrix.print_matrix(asciiMaze) ''' while len(regions) > 1: walls = GetWalls() possibleConnectors = [] for wall in walls: directions = [N, S, E, W] adjacentTiles = [] positionX = wall['x']
return child @property def wih(self) -> list: """Weights between input layer and hidden layer""" return self._wih @wih.setter def wih(self, weights: list): self._wih = weights @property def who(self) -> list: """Weights between hidden layer and output layer""" return self._who @who.setter def who(self, weights: list): self._who = weights if __name__ == "__main__": n = NeuralNetwork(2, 2, 2) matrix.print_matrix(n.wih) print('') matrix.print_matrix(n.who) print('') n_input = [1, -1] out = n.output(n_input) print(out)
while TilesRemain(): while len(centerQueue) > 0 or len(TLQueue) > 0 or len(TRQueue) > 0 or len( BLQueue) > 0 or len(BRQueue) > 0: if loops > 20: if len(centerQueue) > 0: centerQueue = Flood(centerQueue, '.', 'newest') if len(TLQueue) > 0: TLQueue = Flood(TLQueue, '#', 'random') if len(TRQueue) > 0: TRQueue = Flood(TRQueue, '#', 'random') if len(BLQueue) > 0: BLQueue = Flood(BLQueue, '#', 'random') if len(BRQueue) > 0: BRQueue = Flood(BRQueue, '#', 'random') loops += 1 borderedMap = matrix.generate_matrix(width + 1, height + 1) for y in range(height + 1): if y > 0 and y < height: for x in range(width + 1): if x > 0 and x < width: borderedMap[y][x] = grid[y - 1][x - 1] for y in range(height + 1): for x in range(width + 1): if borderedMap[y][x] != '#' and borderedMap[y][x] != '.': borderedMap[y][x] = '#' matrix.print_matrix(borderedMap)