Comparing AI enemy behaviour methods in Godot for smarter and more engaging NPCs
Nguyen, Hung (2026)
Kandidaatintyö
Nguyen, Hung
2026
School of Engineering Science, Tietotekniikka
Kaikki oikeudet pidätetään.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi-fe20260814117122
https://urn.fi/URN:NBN:fi-fe20260814117122
Tiivistelmä
This thesis compares two enemy AI architectures — a Finite State Machine and a Behaviour Tree — implemented in the Godot 4 game engine. Both systems control the same set of enemy behaviours: idle, wander, chase, and stun response. A shared navigation infrastructure based on Godot's NavigationAgent2D and A* pathfinding is used by both implementations, ensuring that the only variable between them is the AI decision-making architecture.
The theoretical background covers the evolution of NPC AI in games, the principles of FSMs and Behaviour Trees, and pathfinding with navigation meshes. The practical implementation is evaluated through five test scenarios covering passive behaviour, hit response, chase behaviour, hit interruption during chase, and a direct side-by-side comparison of both enemies.
The results show that both implementations produce functionally equivalent and visually identical enemy behaviour across all test scenarios. The FSM was simpler to implement and easier to debug for a small, well-defined behaviour set, while the BT produced more modular and extensible code that would scale better as complexity grows. No significant performance difference was observed between the two approaches, and state transition timing logged across all test scenarios confirmed that both architectures operate well within real-time performance constraints. Godot proved to be a capable environment for prototyping and comparing AI techniques, providing sufficient built-in tools without requiring any external plugins.
The theoretical background covers the evolution of NPC AI in games, the principles of FSMs and Behaviour Trees, and pathfinding with navigation meshes. The practical implementation is evaluated through five test scenarios covering passive behaviour, hit response, chase behaviour, hit interruption during chase, and a direct side-by-side comparison of both enemies.
The results show that both implementations produce functionally equivalent and visually identical enemy behaviour across all test scenarios. The FSM was simpler to implement and easier to debug for a small, well-defined behaviour set, while the BT produced more modular and extensible code that would scale better as complexity grows. No significant performance difference was observed between the two approaches, and state transition timing logged across all test scenarios confirmed that both architectures operate well within real-time performance constraints. Godot proved to be a capable environment for prototyping and comparing AI techniques, providing sufficient built-in tools without requiring any external plugins.
