Decision Making Overview: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
From a high-level perspective, [[NPC]]s follow a fairly simple (and real-world logical) process for making decisions. The easiest way to understand it is to examine the basic outline first, and then dig further into the necessary exceptions afterwards.
从上层应用的角度来看,[[NPC]]遵循相当简单(并符合现实逻辑)的决策过程。 想要理解它,最简单的方式就是查看其大纲,之后再进一步挖掘必要的特例情况。


Each time an NPC [[Think()|thinks]], it follows this routine:
每一次NPC [[Think()|思考]], 都会遵照以下的过程:


;Perform Sensing
;感知
:[[NPC Sensing]] generates a list of entities that it can see, and another list of NPC sounds that it can hear. The NPC ignores entities and sounds that it doesn't care about.
:[[NPC_Sensing|NPC感知]] 会产生一个NPC所能看到的实体列表, 以及一个它能够听到的声响列表。并且,NPC会忽略它不关心的实体与声响。
;Generate a list of Conditions
;生成条件列表
:[[Conditions]] are key pieces of information that the NPC will be using to make a decision. They are extracted from the sensed lists of entities & sounds, and from the state of the world and the NPC. Conditions might include:
:[[Condition|条件]] 是一串NPC用于做决策的关键信息。 它们提取于所感知到的实体、声响以及world与NPC的状态。列举一些可能的条件:
:*I can see an enemy
:*我看见了敌人
:*I have taken some damage
:*我正承受伤害
:*My weapon's clip is empty
:*弹夹已空
;Choose an appropriate State
;切换合适状态
:The [[State]] is the overall assessment of the NPC based upon the<!-- global?--> list of Conditions. For example:
:[[State|状态]] 是基于<!-- global?-->条件列表总体评估的。例如:
:*NPCs with a visible enemy enter ''Combat''
:*NPC视野存在可见敌人时将进入''Combat''状态
:*NPCs who have no enemies left will drop back to ''Alert''
:*NPC认为不存在敌人时将进入''Alert''状态
:*NPCs with a health of 0 would move to ''Dead''
:*NPC血量为0时将进入''Dead''状态
;Select a new Schedule if appropriate
;适时选择行程
:The [[Schedule]] is the overall action being taken by the NPC, which is then broken down into Tasks (see below) for the NPC to actually perform. Schedules are chosen based upon the NPC's current State and Conditions. Examples might include:
:[[Schedule|行程]]是NPC将采取的行动总和, 它被拆为多个任务(见下方)被NPC实际执行。 行程的选择基本取决于NPC的状态与条件. 例子如下:
:*I'm taking cover to reload my gun
:*我将寻找掩护并换弹
:*I'm chasing after my enemy
:*我将追逐我的敌人
:*I'm moving to a position where I have line-of-sight to my enemy
:*我将转移到能够看到敌人的位置
:NPCs will choose a new schedule for one of two reasons:
:NPC切换到新行程的原因有两个:
:#They finish performing their last schedule
:#完成了前一个行程
:#They generate a condition that their current schedule has specified as an [[Interrupt]]
:#产生了一个条件,而这个条件被这个行程指定为 [[Interrupt]]
;Perform the current Task
;执行当前任务
:The [[Task]] is a component of a Schedule that describes a discrete action. Tasks must be performed one by one for the schedule to be completed. For example, the "I'm taking cover to reload my gun" schedule would be broken down into the following tasks:
:[[Task|任务]]是行程的组件,可称为离散动作。要想完成一个行程,任务必须一个接一个地执行。 例如, 行程 "我将寻找掩护并换弹" 将被拆为以下任务:
:#Find a position to take cover at
:#找到掩护点
:#Generate a path to that position
:#产生到掩护点的路径
:#Run the path
:#沿着路径行走
:#Reload my gun
:#换弹
:Many tasks, like the one above, take time to perform, so the NPC will keep performing that task each time it thinks until the task is completed. Then, it'll move onto then next task in the current schedule, or pick a new schedule if there are no tasks left. If a task fails, the schedule fails. <!-- is this always true? -->
:像上面的任务一样,许多任务都会花时间执行, 所以NPC每次思考都会不停地执行任务,直到该任务完成。 接着,它会执行当前行程的下一个任务, 或者,当没有任务剩余时会跳到下一个行程. 如果任务失败了,那么行程也会立即失败。(存疑) <!-- is this always true? -->


[[Category: AI]]
[[Category: AI]]

Revision as of 23:59, 25 June 2024

从上层应用的角度来看,NPC遵循相当简单(并符合现实逻辑)的决策过程。 想要理解它,最简单的方式就是查看其大纲,之后再进一步挖掘必要的特例情况。

每一次NPC 思考, 都会遵照以下的过程:

感知
NPC感知 会产生一个NPC所能看到的实体列表, 以及一个它能够听到的声响列表。并且,NPC会忽略它不关心的实体与声响。
生成条件列表
条件 是一串NPC用于做决策的关键信息。 它们提取于所感知到的实体、声响以及world与NPC的状态。列举一些可能的条件:
  • 我看见了敌人
  • 我正承受伤害
  • 弹夹已空
切换合适状态
状态 是基于条件列表总体评估的。例如:
  • NPC视野存在可见敌人时将进入Combat状态
  • NPC认为不存在敌人时将进入Alert状态
  • NPC血量为0时将进入Dead状态
适时选择行程
行程是NPC将采取的行动总和, 它被拆为多个任务(见下方)被NPC实际执行。 行程的选择基本取决于NPC的状态与条件. 例子如下:
  • 我将寻找掩护并换弹
  • 我将追逐我的敌人
  • 我将转移到能够看到敌人的位置
NPC切换到新行程的原因有两个:
  1. 完成了前一个行程
  2. 产生了一个条件,而这个条件被这个行程指定为 Interrupt
执行当前任务
任务是行程的组件,可称为离散动作。要想完成一个行程,任务必须一个接一个地执行。 例如, 行程 "我将寻找掩护并换弹" 将被拆为以下任务:
  1. 找到掩护点
  2. 产生到掩护点的路径
  3. 沿着路径行走
  4. 换弹
像上面的任务一样,许多任务都会花时间执行, 所以NPC每次思考都会不停地执行任务,直到该任务完成。 接着,它会执行当前行程的下一个任务, 或者,当没有任务剩余时会跳到下一个行程. 如果任务失败了,那么行程也会立即失败。(存疑)