Algorithms course · 2024
Clash Royale in Python
A Pygame recreation of Clash Royale using custom pathfinding, sorting, and data structures.
Gameplay from the course project: deploy troops and defend your towers against a bot.
Pathfinding for different troop sizes
Breadth-first search works over the arena grid. Before adding a neighboring position, the pathfinder checks every cell covered by the troop’s width and height.
That check matters when units have different sizes: an open cell can still be an invalid position for a larger troop.
One cellThe position is clear.
Two by twoThe footprint hits an obstacle.
Inside the game
Search, rendering, and opponent logic
- Queue & linked list
- The queue holds the search frontier. Linked nodes retain the route so the path can be reconstructed when the search reaches its target.
- Merge sort
- Merge sort orders troops by vertical position for front-to-back drawing.
- Greedy opponent
- The bot scores threats and chooses responses from a counter table.