Artificial intelligence AI,状态机-如何扩展状态机来处理多个怪物?

Artificial intelligence AI,状态机-如何扩展状态机来处理多个怪物?,artificial-intelligence,state-machine,Artificial Intelligence,State Machine,我在看书。不幸的是,我很难理解如何扩展下面列出的状态机。此示例的伪代码似乎要求状态机对当前状态执行操作: do_stateless_ai(statemachine[action][currentstate]); 如果我需要实现多个怪物AI,这意味着什么 我是否创建了一个状态机实现,然后用不同的状态表加载它,如下所示 或 我是否为每个怪物编写了唯一的状态机代码 或 如果我有多个怪物,我会创建一个巨大的状态表吗?抱歉,如果这个问题看起来非常业余,这是我第一次尝试实现人工智能 以下是文章中描述的人工

我在看书。不幸的是,我很难理解如何扩展下面列出的状态机。此示例的伪代码似乎要求状态机对当前状态执行操作:

do_stateless_ai(statemachine[action][currentstate]);
如果我需要实现多个怪物AI,这意味着什么

我是否创建了一个状态机实现,然后用不同的状态表加载它,如下所示

我是否为每个怪物编写了唯一的状态机代码

如果我有多个怪物,我会创建一个巨大的状态表吗?抱歉,如果这个问题看起来非常业余,这是我第一次尝试实现人工智能

以下是文章中描述的人工智能状态表:

龙艾(部分)

这是实现这台机器的伪代码:

acted = 0;
while (!acted)
{
    observe(statemachine[obs][currentstate]);
    shifted = 0;
    for (inputs=FIRSTINPUT; inputs < LASTINPUT && !shifted; inputs++)
    {
       if (input_is_true(input))
       {  /* note that what's stored in the statemachine is an expression, 
             not necessarily just a number. getshiftprob substitute in 
             values from the monster's extrinsic info and solves the expr.*/
          probshift = getshiftprob 
                 (statemachine[input][currentstate].probshift);
          if random() < probshift
          {
             currentstate = statemachine[input][currentstate].state;
             shifted = 1;
          }
       }
    }
    if statemachine[action][currentstate] != NULL
    {
       do_stateless_ai(statemachine[action][currentstate]);
       acted = 1;
    }      
}
act=0;
当(!行动)
{
观察(状态机[obs][currentstate]);
移位=0;
对于(输入=第一输入;输入<最后输入&&!移位;输入++)
{
如果(输入为真(输入))
{/*注意状态机中存储的是一个表达式,
不一定只是一个数字。getshiftprob替换为
从怪物的外部信息中提取值并求解表达式*/
probshift=getshiftprob
(statemachine[input][currentstate].probshift);
if random()
如果你使用一个巨大的表,那么你最终会得到一个巨大的AI直接控制一切。但是想一想这个表和实现会是什么样子,即使对于两个代理——想一想状态和观察值的组合,以及即使对于两个或三个代理,这个表会增长多大。我想你会得出结论,那是不可行的。这甚至可能不可取

如果您有多个表,那么您就有多个代理,它们都是独立控制的,并且具有更合理的大小。我不明白为什么你们希望每个代理都有独特的机器。即使您想要不同的行为,这意味着不同的表,您仍然应该能够提出一些通用的基础架构,您可以轻松地进行个性化设置

acted = 0;
while (!acted)
{
    observe(statemachine[obs][currentstate]);
    shifted = 0;
    for (inputs=FIRSTINPUT; inputs < LASTINPUT && !shifted; inputs++)
    {
       if (input_is_true(input))
       {  /* note that what's stored in the statemachine is an expression, 
             not necessarily just a number. getshiftprob substitute in 
             values from the monster's extrinsic info and solves the expr.*/
          probshift = getshiftprob 
                 (statemachine[input][currentstate].probshift);
          if random() < probshift
          {
             currentstate = statemachine[input][currentstate].state;
             shifted = 1;
          }
       }
    }
    if statemachine[action][currentstate] != NULL
    {
       do_stateless_ai(statemachine[action][currentstate]);
       acted = 1;
    }      
}