<!-- Generated by scripts/sync-agent-content.mjs. Edit the shared public sources, then regenerate. -->
# Clash Royale in Python

A strategy game with pathfinding and custom data structures.

- Dates: 2025
- Status: Course project
- Areas: Software engineering
- Stack: Python · Pygame · Algorithms
- Topics: Python; Pygame; Games; Game AI; Algorithms; Pathfinding
- Public case study: https://mgiorgetti.com/project_details/project-algorithms-project.html

## Problem

An arena game needs paths that respect troop footprints, consistent drawing order and an opponent that can respond to threats.

## Contribution

Team contribution to an algorithms course project implementing a Pygame recreation with custom pathfinding, sorting and data structures.

## Technical approach and public case study

A Pygame recreation of Clash Royale using custom pathfinding, sorting, and data structures.

- Team project

- Python · Pygame

- Completed

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.

Illustration of the neighbor check. The two troops start at the same grid position.

### 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.

## Results and limitations

The course project is completed and has public gameplay and source links. It demonstrates the implemented algorithms rather than reporting competitive AI strength or performance against the original game.

## Public supporting links

- [Portfolio case study](https://mgiorgetti.com/project_details/project-algorithms-project.html)
- [View source](https://github.com/Inventure72/AlgorithmsProject)
- [Watch gameplay on YouTube](https://youtu.be/35BMyos7Oa8)
- [Matteo Giorgetti profile](https://mgiorgetti.com/profile.md)
