Maze solving with python

后端 未结 2 523
清歌不尽
清歌不尽 2020-12-18 00:21

I am trying to make a maze solver, and it is working except that instead of the path being marked by \"o\" I want it to be marked with \">\", \"<\", \"v\", \"^\" dependin

2条回答
  •  攒了一身酷
    2020-12-18 00:51

    #marking
    maze[y][x] = "o"        
    
    #recursive case
    if self.solve(x+1,y) == True :  #right
        maze[y][x] = ">"
        return True
    if self.solve(x,y+1) == True :  #down
        maze[y][x] = "v"
        return True
    ...
    

    From Lix example. You need to uncomment maze[y][x] = "o", you need that row to prevent the node from being revisited

提交回复
热议问题