我正在做一个扫雷游戏,我想用一个递归函数,当我点击一个空白的方块时,我会显示出许多方块。在
到目前为止我的视图.py公司名称:
def reveal(board_id, x, y):
tile = Tile.objects.filter(board=board_id, x=x, y=y)
if tile[0].revealed == False:
tile.update(revealed=True)
if tile[0].mine == False and tile[0].value == 0:
if x != 0:
tempx = x-1
reveal(board_id, tempx, y)
if x != 9:
tempx = x+1
reveal(board_id, tempx, y)
if y != 0:
tempy = y-1
reveal(board_id, x, tempy)
if y != 9:
tempy = y+1
reveal(board_id, x, tempy)
它给我一个服务器错误。在
x和y值是作为unicode字符传递的,所以当我试图添加或减去这些值时,它引发了一个异常。在
基本上
帮我解决了。在
我猜
reveal()
会一直走在已经显示的瓷砖上。在相关问题 更多 >
编程相关推荐