Implementation of a Finite State Machine for Controlling NPC Customer Behavior in the 2D Game "Cooking Chaos"
DOI:
https://doi.org/10.62411/jimat.v3i2.17570Keywords:
2D game, Finite state machine, NPC customer, Software testing, UnityAbstract
Non-Player Characters (NPC) are components in games that can be used to create interactions and gameplay dynamics. NPC behavior control is required to enable characters to respond appropriately to conditions occurring during gameplay. This study aims to implement a Finite State Machine (FSM) to control customer NPC behavior in the Unity-based 2D game Cooking Chaos. The implemented FSM consists of four states: Waiting, Angry, Chasing, and Attack. State transitions are influenced by the customer’s patience system and interaction conditions with the player. When the patience time expires, the customer changes behavior from waiting to becoming angry, chasing, and potentially attacking the player. The implementation was evaluated using Black Box Testing, FSM Transition Testing, and Multi-Customer Testing. The Black Box Testing results showed that all 12 functional scenarios were valid. FSM Transition Testing on seven scenarios, each tested 10 times, resulted in 70 successful trials out of 70. Multi-Customer Testing demonstrated that the order, patience, and FSM mechanisms operated independently with up to three active customers simultaneously. The results indicate that the implemented FSM consistently controls customer NPC behavior transitions under the defined test scenarios and integrates the service mechanism with direct gameplay consequences for the player.References
F. Mandita and B. K. Jati, “Application of Finite State Machine in the 3D Game ‘Virus Hunter’,” Jurnal Ilmu Komputer dan Desain Komunikasi Visual, vol. 7, no. 2, pp. 90–101, 2022, doi: 10.55732/jikdiskomvis.v7i2.613.
M. H. Syu’aibi, A. Mahmudi, and K. Auliasari, “Perancangan dan Implementasi Metode FSM (Finite State Machine) pada Game Military Defence 2D Berbasis Android,” JATI (Jurnal Mahasiswa Teknik Informatika), vol. 7, no. 4, pp. 2349–2357, 2023, doi: 10.36040/jati.v7i4.7508.
M. B. R. Alvian, S. Bukhori, and M. A. Furqon, “Implementation of Finite State Machine to Determine The Behaviour of Non-Playable Character in Leadership Simulation Game,” Journal of Games, Game Art, and Gamification, vol. 9, no. 1, pp. 11–21, 2024, doi: 10.21512/jggag.v9i1.10894.
M. B. Firdaus, A. Z. Waksito, A. Tejawati, M. Taruk, M. K. Anam, and A. Irsyad, “Finite state machine for retro arcade fighting game development,” International Journal of Informatics and Communication Technology (IJ-ICT), vol. 14, no. 1, pp. 102–110, 2025, doi: 10.11591/ijict.v14i1.pp102-110.
F. P. Utami, H. Z. Alifa, and M. A. Yaqin, “Implementasi Black Box Testing Pada Game Ular Untuk Mendeteksi Bug,” Journal Automation Computer Information System, vol. 4, no. 2, pp. 76–87, 2024, doi: 10.47134/jacis.v4i2.85.
J. Gregory, Game Engine Architecture, 3rd ed. Boca Raton: CRC Press, 2019.
J. Nystrom, Game Programming Patterns. USA: Genever Benning, 2014.
I. Millington dan J. Funge, Artificial Intelligence for Games, 3rd ed. Boca Raton: CRC Press, 2019.
D. Brackeen, Developing Games in Unity. New York: Apress, 2019.
Unity Technologies, “Unity Manual,” 2024. [Online]. Available: https://docs.unity3d.com/Manual/. [Accessed: Jul. 20, 2026].
A. Dennis, B. H. Wixom, dan D. Tegarden, Systems Analysis and Design: An Object-Oriented Approach with UML, 6th ed. Hoboken: Wiley, 2021.
R. S. Pressman dan B. Maxim, Software Engineering, 9th ed. New York: McGraw-Hill Education, 2020.
B. Beizer, Software Testing Techniques, 2nd ed. New York: Van Nostrand Reinhold, 1990.
R. Black, Managing the Testing Process, 3rd ed. Indianapolis: Wiley Publishing, 2009.
M. Mustaqbal, R. F. Firdaus, dan H. Rahmadi, “Pengujian Aplikasi Menggunakan Metode Black Box Testing,” Jurnal Ilmiah Teknologi Informasi Terapan, vol. 1, no. 3, pp. 31–36, 2015
M. B. Nendya, S. G. Gunanto, and R. G. Santosa, “Pemetaan Perilaku Non-Playable Character Pada Permainan Berbasis Role Playing Game Menggunakan Metode Finite State Machine,” Journal of Animation and Games Studies. Sumber ini secara langsung membahas pemodelan perilaku NPC menggunakan FSM.
S. Amalia, M. D. F. Abidullah, F. Marcellino, D. D. Rabani, F. F. Azzahra, and A. Abdiansah, “AI-Driven Traffic Simulation using Unity: Implementing Finite State Machines for Adaptive NPC Behaviour,” Journal of Intelligent Computing & Health Informatics, vol. 5, no. 2, 2024. Penelitian ini relevan untuk FSM, NPC, Unity, dan integrasi pathfinding.
P. Alam and H. Haryanto, “Implementasi Behavior Tree dalam Menentukan Perilaku Musuh pada Game Metroidvania ‘Cursed World’,” TECHNO CREATIVE, vol. 2, no. 2, 2024. Penelitian ini dapat digunakan untuk mendukung pembahasan mengenai Behavior Tree sebagai alternatif ketika perilaku NPC semakin kompleks.
J. Lee and J. Kim, “지능형 NPC의 행동 메커니즘에 따른 계층적 유한 상태 기계와 행동 트리의 효율성 평가,” 지능정보논문지, vol. 24, no. 2, pp. 113–118, 2024, doi: 10.7236/JIIBC.2024.24.2.113. Penelitian ini secara langsung membandingkan HFSM dan Behavior Tree pada NPC.
Atthariq and D. A. Putra, “Penentuan Pergerakan Non-Player Character Menggunakan Algoritma A* pada Game Action-Role-Playing Game,” Jurnal Infomedia: Teknik Informatika, Multimedia, dan Jaringan, doi: 10.30811/.v2i2.516. Penelitian ini relevan untuk pembahasan pathfinding NPC menggunakan A*.
Downloads
Published
Issue
Section
License
Authors who publish their articles in this journal agree to the following conditions:
- Copyright remains with the author and gives the JIMAT journal the right as first priority to publish the article under a Creative Commons Attribution License which allows articles to be shared with acknowledgment of the author of the article and this journal as the place of publication.
- Authors can distribute their published articles non-exclusively (for example: in university repositories or in books) with notification or acknowledgment of publication in JIMAT.
- Authors are permitted to list their work online (for example: on a personal website or in a university repository) before and after the submission process (see The Effect of Open Access).






