- 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)
- 網(wǎng)絡(luò)故障現(xiàn)場處理實踐(第4版)
- Learning Karaf Cellar
- 互聯(lián)網(wǎng)基礎(chǔ)資源技術(shù)與應(yīng)用發(fā)展態(tài)勢(2021—2023)
- 城域網(wǎng)與廣域網(wǎng)(第2版)
- 智慧光網(wǎng)絡(luò):關(guān)鍵技術(shù)、應(yīng)用實踐和未來演進(jìn)
- CCNP TSHOOT(642-832)認(rèn)證考試指南
- 面向5G-Advanced的關(guān)鍵技術(shù)
- Getting Started with Memcached
- 網(wǎng)絡(luò)工程實施技術(shù)與方案大全
- 物聯(lián)網(wǎng)基礎(chǔ)及應(yīng)用
- 通信系統(tǒng)實戰(zhàn)筆記:無處不在的信號處理
- ReasonML Quick Start Guide
- 走近2050:注意力、互聯(lián)網(wǎng)與人工智能
- 視聽變革:廣電的新媒體戰(zhàn)略