Skip to content
A Python, PyGame simulation of Dijkstra and A*, running at the same time.
Branch: master
Clone or download


A Python, PyGame simulation of Dijkstra and A*, running at the same time.

Python 3 Patreon Slack

Dijkstra and A* at the same time

I decided to refresh my memory on how Dijkstra and A* operate, ready for my final exam on them, I would write a Python script that runs both of them at the same time for a visual comparison.

Demonstration of the script, running on a 50x50 grid with a 0.25 chance of walls. Magenta is the A* path, cyan is the Dijkstra path.


This started as just a PyGame simulation of A*, but then I decided to allow the heuristic to be forced to zero, which simulates Dijkstra's algorithm. With that change made I could then abstract the main grid to its own class and allow multiple searches to be run and rendered at the same time, resulting in the current code.


Contributions are always welcome to this project!
Take a look at any existing issues on this repository for starting places to help contribute towards, or simply create your own new contribution to the project.

Please make sure to follow the existing standards within the project such as code styles, naming conventions and commenting/documentation.

When you are ready, simply create a pull request for your contribution and I will review it whenever I can!


You can also help me and the project out by contributing through a donation on PayPal or by supporting me monthly on my Patreon page.

Patreon PayPal

Discussion, Support and Issues

Need support with this project, have found an issue or want to chat with others about contributing to the project?

Please check the project's issues page first for support & bugs!

Not found what you need here?

  • If you have an issue, please create a GitHub issue here to report the situation, include as much detail as you can!
  • or, You can join our Slack workspace to discuss any issue, to get support for the project or to chat with contributors and myself:
You can’t perform that action at this time.