How is a finite state machine used in artificial intelligence?
Finite state machines (FSMs), are computational models defined by a list of unique set states that can be only picked one by one. In a nutshell, FSMs are simple but elegant solutions to build AI where the machine can only be in one state at any time, and can only switch from one state to another through a transition when an input is received. The most traditional example is a traffic light, that transitions from green to yellow, and from yellow to red after a defined amount of time. In this case, the input is represented by time, but no real AI is involved since the device is completely passive. Only if the traffic light could react to passersby, then AI could be involved.
FSMs are broadly used in the video gaming industry for their inherent simplicity and predictability to support basic but functional AI. For example, they’re largely used in action and RPG games by non-playable characters (NPCs). A relatively simple AI model is built so that a given NPC (usually a foe) can only select a particular behavior — say, attack, flee, defend, detect, etc. They can also be used for main characters, for example when the player gets a power-up or bonus, or to model UI and control schemes in platforming games (to set the crouched state or rapid-fire mode).
FSMs can be used to create realistic simulations of software architecture and communication protocols for cybersecurity purposes. FSM models of vulnerable operations are generated to understand all possible exploits, and let the AI find the best solutions to mitigate them. These simulations are used to test and evaluate security protocols, their robustness, and the security posture of a system. They can be later used to establish cybersecurity policies and best practices.
FSMs have also been used in the field of computational linguistics to build natural language processing (NLP) tools and chatbots with mixed results. Natural human language is, however, full of ambiguities in context that are easily inferred by other humans during real-life conversations (or even while reading a text). FSMs try to parse language with a deterministic approach which is often too rigid to properly handle natural conversations, so statistical inference and decision theories are usually the preferred methods. FSMs still represent a good foundation upon which a simple but efficient NLP AI has been built in the past. In software and applications where dialogs are hard-coded inside source code of a particular programming language, however, FSMs can be used efficiently enough.
Tags
Written by Claudio Buttice | Data Researcher, Contributor

Dr. Claudio Butticè, Pharm.D., is a former clinical and hospital pharmacist who worked for several public hospitals in Italy, as well as for the humanitarian NGO Emergency. He is now an accomplished book author who has written on topics such as medicine, technology, world poverty, human rights, and science for publishers such as SAGE Publishing, Bloomsbury Publishing/ABC-Clio, and Mission Bell Media. His latest books are "Universal Health Care" (2019) and "What You Need to Know about Headaches" (2022).
A data analyst and freelance journalist as well, many of his articles have been published in magazines such as Cracked, The Elephant, Digital Journal, The Ring of Fire, and Business Insider. Dr. Butticè also published pharmacology and psychology papers on several clinical journals, and works as a medical consultant and advisor for many companies across the globe.
More Q&As from our experts
- How is artificial intelligence used in video games?
- Is artificial intelligence a tool or a threat to cybersecurity?
- Which medical professions can ethically be replaced with AI?
Related Terms
- State Machine
- Artificial Intelligence
- Role-Playing Game
- Non-Player Character
- Software Architecture
- Cybersecurity
- Computational Linguistics
- Natural Language Processing
- Chatbot
- Decision Theory
Related Articles

Computer Programming: From Machine Language to Artificial Intelligence

Deep Learning: How Enterprises Can Avoid Deployment Failure

Machine Learning: 4 Business Adoption Roadblocks

Artificial Neural Networks: 5 Use Cases to Better Understand
Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
- The CIO Guide to Information Security
- Robotic Process Automation: What You Need to Know
- Data Governance Is Everyone's Business
- Key Applications for AI in the Supply Chain
- Service Mesh for Mere Mortals - Free 100+ page eBook
- Do You Need a Head of Remote?
- Web Data Collection in 2022 - Everything you need to know