INFO
Solo developer (everything except pixel art) of a pixel-art, turn-based strategy RPG demo inspired by Fire Emblem in Unity (C#), where the player and enemy take turns moving and attacking with their units. I built this project in 5 weeks in my spare time alongside full-time studies. I implemented a custom grid system and A* pathfinding for unit movement, and designed an original AI decision-making algorithm that selects optimal movement and actions based on unit health, enemy weaknesses, and distance to potential targets.
Decision-Making Algorithm
My enemy AI uses a custom decision-making algorithm to choose the best action each turn.
It selects a target by evaluating:
- Current unit health
- Matchups / enemy weaknesses
- Distance to potential targets
- Reachability (can it move into a position to engage the target?)
To compare options consistently, I store each evaluation in a small custom Score class containing the target’s unit index, distance, final score value, and reachability.


Calculate Distance
Evaluates each player unit and finds all valid tiles the enemy can attack from (based on unit class: Archer/Warrior/Mage). Each option is scored using a distance map from the enemy’s current position to the target tile.

Calculate Weakness
Adjusts the score based on matchups: the AI prefers targets it has an advantage against, including a damage bonus when attacking units it is strong against.

Calculate Health
Prioritizes low-health targets by increasing the score for units with low HP — especially units that are near death, enabling consistent finishing blows.

Fallback Movement (No Valid Attack Tile)
When the AI can’t reach any valid attack position this turn, it doesn’t waste the turn. Instead, it selects a walkable tile near the closest player unit and moves toward that unit, improving positioning so it can engage as soon as an attack becomes possible.

Each enemy unit is controlled by a behavior tree. Units take turns based on a unique ID , so only the unit whose ID matches the current turn index is allowed to act.

1.ActivateTurnAction
Checks whether this unit’s ID matches the active unit ID for the turn. If not, it does nothing and waits
2.Disable camera – It snaps the camera to the current unit(So you can see what is going on).
3.MoveToNavPoint – moves the unit to the chosen tile
4.Attack – checks CanAttack; if true, attacks the player unit
5.DoneRound – hands control to the next unit ID (If last ID ends turn)
Grid System (A* Navigation)
My pathfinding uses a custom grid-based navigation system built for A*. Each tile stores whether it is walkable or blocked.
How it works
- When the grid is generated/updated, it checks a specific collision layer.
- If an object is detected on the “blocked” layer, that tile is marked as non-walkable.
- A* then uses this walkability data to avoid obstacles and find valid paths.
- At the end of each unit’s turn, the tile the unit is standing on is marked as blocked so other units won’t pathfind into occupied tiles (prevents units from overlapping).
Editor visualization
To make debugging easier, I added visual indicators in the editor so I can quickly see which tiles are walkable vs non-walkable while building levels.


Conclusion
I learned a lot from this project about what’s required to make a system like this work end-to-end, and the kinds of bugs you run into when combining grid movement, pathfinding, and AI decision-making. I’d love to rebuild it someday—now that I know which core systems and scripts need to be in place from the start, I’m confident I could make a much cleaner and more polished second version. I also built an early prototype of the project in Unreal.

