- Unity Artificial Intelligence Programming
- Dr. Davide Aversa Aung Sithu Kyaw Clifford Peters
- 287字
- 2021-06-10 18:57:46
Finite State Machines (FSMs)
Finite State Machines (FSMs) are one of the simplest AI model forms and are commonly used in the majority of games. A state machine consists of a finite number of states that are connected in a graph by the transitions between them. A game entity starts with an initial state and then looks out for the events and rules that will trigger a transition to another state. A game entity can only be in exactly one state at any given time.
For example, let's take a look at an AI guard character in a typical shooting game. Its states could be as simple as patrolling, chasing, and shooting:
There are four components in a simple FSM:
- States: This component defines a set of states that a game entity or an NPC can choose from (Patrol, Chase, and Shoot)
- Transitions: This component defines relations between different states
- Rules: This component is used to trigger a state transition (player on sight, close enough to attack, and lost/killed player)
- Events: This is the component that will trigger to check the rules (guard's visible area, distance with the player, and so on)
So, a monster in Quake 2 might have the following states: standing, walking, running, dodging, attacking, idle, and searching.
FSMs are widely used in game AI because they are simple to implement and more than enough for both simple and somewhat complex games. Using simple if/else statements or switch statements, we can quickly implement an FSM. On the other hand, they can get messy when we start to have a lot of states and transitions. We'll look at how to manage a simple FSM in the next chapter.
- 物聯(lián)網(wǎng)之魂:物聯(lián)網(wǎng)協(xié)議與物聯(lián)網(wǎng)操作系統(tǒng)
- PLC、現(xiàn)場(chǎng)總線(xiàn)及工業(yè)網(wǎng)絡(luò)實(shí)用技術(shù)速成
- 中小型局域網(wǎng)組建、管理與維護(hù)實(shí)戰(zhàn)
- 物聯(lián)網(wǎng)技術(shù)與應(yīng)用
- 網(wǎng)管工具使用與技巧大全
- SAE原理與網(wǎng)絡(luò)規(guī)劃
- Learning Node.js Development
- Hands-On Docker for Microservices with Python
- 智慧城市中的物聯(lián)網(wǎng)技術(shù)
- 巧學(xué)活用CISCO網(wǎng)絡(luò)典型配置
- 學(xué)術(shù)虛擬社區(qū)用戶(hù)社會(huì)化交互行為研究
- 網(wǎng)絡(luò)設(shè)備配置與調(diào)試項(xiàng)目實(shí)訓(xùn)
- Learning IoT with Particle Photon and Electron
- 互聯(lián)網(wǎng)下一站:5G與AR/VR的融合
- 一板成功:高速電路研發(fā)與設(shè)計(jì)典型故障案例解析