This study presents the implementation of a Finite State Machine (FSM) to control enemy behavior in a 2D game environment based on the player’s attack patterns. FSM is applied to manage dynamic transitions between states such as Idle, Attack, Teleport, and Summon. Each state is triggered by contextual gameplay variables including player proximity, number of consecutive hits, and enemy health level. The AI system was developed using the Godot Engine and GDScript, incorporating visual assets via sprite sheets linked to each behavioral state. The FSM framework allows the enemy character to react adaptively teleporting after repeated attacks and summoning reinforcements thus simulating intelligent behavior. System evaluation was conducted using black-box testing in simulated combat scenarios. Results demonstrate that the FSM-based AI provides enhanced gameplay variability, responsiveness, and strategic challenge, while maintaining system modularity and scalability. The findings support the effectiveness of FSM for real-time enemy behavior modeling in 2D games and offer a reference framework for future development of adaptive AI in interactive digital environments.
Copyrights © 2025