文件名称:Python深度优先算法生成迷宫
文件大小:29KB
文件格式:PDF
更新时间:2024-01-15 09:27:31
python python算法 算法
本文实例为大家分享了Python深度优先算法生成迷宫,供大家参考,具体内容如下 import random #warning: x and y confusing sx = 10 sy = 10 dfs = [[0 for col in range(sx)] for row in range(sy)] maze = [[' ' for col in range(2*sx+1)] for row in range(2*sy+1)] #1:up 2:down 3:left 4:right operation = {1:(0,-1),2:(0,1),3:(-1,0),4:(1,0)} dire