astarrts

For this project, I developed a grid-based real-time strategy game in Unity with a heavy focus on AI systems and gameplay decision making. The game features two opposing teams that gather resources, spawn units, defend their bases, and attack enemy forces autonomously or through player control. The core goal of the project was to explore practical AI implementation within games, particularly around pathfinding, finite state machines, and behaviour-driven unit logic. Alongside the gameplay systems, I also built supporting systems for level generation, resource management, unit selection, team management, and performance optimisation.

The main AI system was built around a custom implementation of the A* pathfinding algorithm running on a 2D grid-based world. Units calculate routes around obstacles while dynamically reacting to occupied cells and moving targets. To improve performance, I also implemented a line-of-sight movement optimisation that allows units to move directly toward targets whenever a clear path exists, avoiding unnecessary pathfinding calculations. On top of this, unit behaviour was controlled using finite state machines, allowing Gatherer and Soldier units to make context-sensitive decisions such as harvesting, depositing resources, fleeing danger, chasing enemies, or attacking targets. Each unit type extends shared base behaviours while introducing role-specific decision logic and transitions.

A large part of development focused on scalability and optimisation. Instead of relying heavily on expensive GameObject searches, I used lightweight grid occupancy systems built around Vector2Int and boolean arrays to reduce runtime overhead. Coroutines were used in place of constant frame-by-frame updates for many systems such as harvesting, cooldown handling, and AI decision making, helping reduce performance costs as unit counts increased. I also implemented singleton-based managers to centralise systems like level generation, resources, and game state handling, which helped keep the overall architecture cleaner and easier to debug.

What I found most valuable during this project was balancing technical AI systems with practical gameplay behaviour. Throughout development I ran into issues involving state conflicts, performance drops, and AI decision handling, particularly when player commands interrupted autonomous behaviour. Solving those problems gave me a much stronger understanding of optimisation, AI architecture, and gameplay system design within larger simulations. While there are still areas I would improve in a future iteration — particularly around scalability and more advanced squad behaviours — the project gave me solid hands-on experience building AI-driven gameplay systems from scratch and reinforced my understanding of game architecture and real-time decision making.