Project — 05
Fastest route
A Python pathfinding playground: paint forests, water, fire and walls onto a grid, press Start, and watch Dijkstra's algorithm work out the cheapest way from A to B — terrain by terrain, cost by cost.
Python / Dijkstra's algorithm
View code01 — The map
Paint the terrain
The app opens with an empty grid — A pinned in one corner, B in the other. Every cell starts free, and each terrain you can paint carries a price for stepping on it. Left click lays down the selected terrain, right click clears a cell back to open ground. Like the Angular project, the interface speaks Slovak.
0
Volne
Open
5
Les
Forest
10
Voda
Water
20
Ohen
Fire
∞
Stena
Wall
Cost per cell — walls are effectively impassable

02 — The route
The cheapest way out
Hit Start and Dijkstra's algorithm explores outward from A, always expanding the cheapest reachable cell first, until it arrives at B. The winning route is then drawn back across the map with the running cost written into every cell. On this map it weaves around water, fire and walls, pays for a single stretch of forest, and reaches the goal at a total cost of 5 — announced at the top as “Hotovo. Najrychlejsia trasa ma cenu 5.”
