Python Programming: Shortest Path Pathfinding Algorithm In 5 Minutes

preview_player
Показать описание
I explain an easy shortest pathfinding algorithm (breadth-first search) in code, step by step. I show the results and full code first. This algorithm can be used for game development. I also share a link to the code in the description.

I'm a commercial developer who's worked for various companies on various products. Now I'm dedicating my time to game development.

On this channel, I want to share my game dev journey with you. Including coding, creating music and art assets. I hope some of these videos will be useful to you.

My common learning sources are Wikipedia, Google and YouTube.

#gamedev #pathfinding #learnpython
Рекомендации по теме
Комментарии
Автор

Thank you your way of explaining it is top notch

thejealousones
Автор

Please say that I'm wrong, but to me your code sounds like a: Depth first, maybe the shortest possible path algorithm, but a path anyway.

My argument is:
It seems to me that you got lucky with the left, right, up, down order.
As far as I understand your algorithm chooses the next coordinate based on the order of the list (in getNextMoove ), 'takes that path at a junction'. Than it tries to traverse that path (here not important how), until it is the end coordinates or until it can't append another valid coordinate. If it can't, than it backtracks to the last 'junction' (pop-ing the last coordinates in the searchPath till that point), then it takes the next valid move from the list that is in getNextMoove. So on and so forth till it meets the condition to return.

If the list in getNextMoove would go: down, right, left, up, than it would still find a path, but a completely different one.

expressivecreativity