Labyrinthe-Astar
Implementation of A* pathfinding algorithm (own interpretation)
It's in fact resolution of a small exercise (described below) It permit actually to display what algorithm do in real time
What script do?
#######################################
#.....................................#
#.....................................#
#....................#................#
#............#.......#................#
#............#.......#......#.........#
#....C.......#..............#...T.....# 'T' want to reach 'C'
#............#.......#......#.........# and then come back to his initial position
#............#.......#................#
#....................#................#
#.....................................#
#.....................................#
#######################################
???????????????????????????????????????
???????????????????????????????????????
???????????????????????????????????????
???????????????????????????????????????
??????????????????????????????.....????
??????????????????????????????.....???? but T can't see further than 5 space
??????????????????????????????.....????
??????????????????????????????........?
??????????????????????????????........?
??????????????????????????????.....T..?
??????????????????????????????........?
??????????????????????????????........?
??????????????????????????????########?
???????????????????????????????????????
???????????????????????????????????????
???????????????????????????????????????
??????????????????????????????????????? So first T search for C,
??????????????????????????????..o..???? he goes to closest unknown square ('?') until he find 'C',
??????????????????????????????.ooo.????
??????????????????????????????ooooo???? A* pathfinding :
??????????????????????????????ooooo???? O = current position
??????????????????????????????oooo*o..? o = open list
??????????????????????????????ooo*o*o.? * = close list
??????????????????????????????oooo***o?
??????????????????????????????ooo*0**o?
??????????????????????????????########?
#######################################
#.....................................#
#.....................................#
#.......ooooo........#................#
#....ooo*****#.......#................# then he come back to intitial position
#...o********#.......#......#.........#
#...o********#..............#.........# O = current position
#.....*******#....ooo#......#.........# o = open list
#.....oo*****#oooo***#................# * = close list
#.......oooo*********#oo..............#
#...........oooooooo****0.............#
#...................oooo..............#
#######################################
#######################################
#.....................................#
#.....................................#
#.......ooooo........#................# This is the path found
#....ooo*****#.......#................#
#...o********#.......#......#.........#
#...o #......o.......#oo ......#
#.....****** #..oooo*#...ooo#* o.....#
#.....oo**** #oo*****#ooo**** *o.....#
#.......oooo #****** **o.....#
#...........oooooo** ***o.....#
#.................oooooooooooooo......#
#######################################
run
python3 labyrinthe.py
for more details on internals functions
>>> import labyrinthe
>>> help(labyrinthe)