欢迎光临散文网 会员登陆 & 注册

智能AI:NPC如何以有效、有趣、多样的方式运作?

2023-09-01 23:38 作者:机枪豌豆射手159  | 我要投稿

智能AI:NPC如何以有效、有趣、多样的方式运作?

Intelligent Artificial Intelligence: How Do NPCs Operate In An Effective, Flavorful, And Varied Way?

为什么回合制战略游戏是复杂人生模拟的合适媒介?

And Why Turn Based Strategy Games Are The Proper Medium For Sophisticated Sims

AXIOMS

2023年4月19日

简介

Introduction

我在这里和其他地方写过很多关于回合制游戏如何实现卓越AI的文章,尤其是在有大量代理的游戏中,我们希望代理能做一些实际复杂的事情。在这里,我将尝试对这一话题进行更详细的阐述,并对我如何计划制作有趣的AI进行高水平的解释。

I’ve written a lot here and elsewhere on how turn based games allow for superior AI, especially in games with lots of agents who we want to do actually complex things. I’m going to try to go into more detail here about that topic as well as provide a high level explanation of how I plan to make an interesting AI.

除了关于玩家和他们对AI的需求的严肃讨论之外,关于使用计算机控制代理的电子游戏以及如何让它们运行的讨论也持续了很长时间。它们应该有趣吗?有趣味性/历史性(如果游戏是关于历史的)?它们是否应该棘手?作弊是否公平?复制人类的强度玩法?或者,如果没有这两条捷径,AI是否应该很困难?

There are several long running debates about video games with computer controlled agents and how to make them work in addition to serious debates about players and what they want from an AI. Should they be fun? Flavorful/historical(if the game is about history)? Should they be tough? Is cheating fair? What about copying human meta-gaming? Or should they be difficult without those two shortcuts?

此外,我还将讨论一些潜在的游戏规则,这些规则适用于那些不想要最优玩法天才敌人(即使是非常有味道的敌人)的人。最后,我将谈谈如何使用半同步计算机代理。它们拥有与你相同的工具和许多相同的目标,但有时它们也有 "个人 "目标和个人 "实现目标的偏好"。

Additionally I’ll be discussing some potential game rules for people who don’t want the most min-maxed genius enemy, even a very flavorful one. Finally I’ll be talking about how to use semi-asynchronous computer agents. They have all the same tools as you and many of the same goals but sometimes they have “personal” goals and personal “preferences for achieving their goals”.

回合制 VS 实时

Turn Based Vs Real Time

我是回合制复杂战略游戏的忠实拥护者。我认为这有很多重大优势。首先,通过两阶段的规划/行动系统,你可以在第一阶段大量使用多线程,甚至可以在玩家的回合中执行。实际上,我曾试图构建游戏结构,让玩家每回合至少花费几分钟时间,以减少高质量AI的回合时间成本。

I’m a big advocate of turn based games for complex strategy. I think it provides a lot of major advantages. Firstly with a two phase plan/act system you can heavily utilize multithreading for the first phase and even execute it during the player’s turn. I actually tried to structure the game so the player would spend at least a couple minutes per turn so as to ameliorate the turn time cost of an high quality AI.

我试图让用户界面尽可能高效、低点击率,但每时每刻的游戏和每回合的潜在行动次数应该会让 2-5 分钟的回合既有趣又常见。此外,虽然理论上可以进行多线程实时游戏或 "基于时间点"的游戏,但当目标随着时间点的流逝而不断变化时,就很难做到这一点了。

I tried to make the UI as effective and low-click as possible but the moment to moment gameplay and per turn potential action count should make 2-5 minute turns both interesting and common. Additionally while you could theoretically multi-thread real time or “tick-based” games it is hard to do so when the target is constantly changing as ticks pass.

回合制游戏还允许有更多时间进行复杂的战斗模拟。虽然在《Axioms Of Dominion》中无法观看或控制战斗,但你可以在一定程度上计划战斗,而且正如我在最近的文章中所讨论的那样,战斗仍然有详细的模拟。所有战斗都会在玩家回合结束后立即使用多线程运行。战斗无论如何都不会发生交互,因此这就允许使用相对简单的多线程,而我作为一个非专业人士也能成功做到这一点。希望如此,我还没有像研究AI多线程那样深入研究战斗多线程。

Turn based games also allow for more time for complex battle simulations. Although you can’t watch or control battles in Axioms you can plan them to some degree and they still have a detailed simulation, as I’ve discussed in recent posts. All battles are run immediately after the player’s turn using multithreading. Battles don’t interact in anyway so this allows for relatively simple multithreading which I as a non-PhD/professional can implement effectively. Well I hope so, I haven’t gone deep into the battle multi-threading like I have for AI multi-threading.

此外,回合制允许 "社交场合"(如本博客同名文章所述)比其他游戏更具互动性、趣味性和影响力。在我看来,这其中就包括《CK3》新公布的 "盛大活动"。实际上,它们与我在去年的博文中对 "社交场合 "的高水平描述非常相似,就像《CK3》的秘密与我在2014年的博客中对《Axioms Of Dominion》秘密系统的描述一样,但这可能只是巧合。只是因为《Axioms Of Dominion》是回合制游戏,所以有时间为 "社交场合 "进行更复杂的决策、更好的规划和更详细的互动。

Additionally being turn based allows the “Social Occasions”, as described in the eponymous post on this blog, to be much more interactive and interesting and impactful than they are in other games. That includes, in my admittedly biased opinion, the new “Grand Events” announced for CK3. They actually have a pretty strong resemblance to my high level description in last year’s post of “Social Occasions”, as CK3 Secrets did to my 2014 blog post on the Secrets system for Axioms, but this is probably a coincidence. There is just time for much more complex decision making and better planning and more detailed interactions for Social Occasions because Axioms is turn based.

《Axioms Of Dominion》中的角色所做的事情远比其他策略或社交模拟游戏中的代理所做的事情更详细、更综合、更有味道。正如我将在本篇文章中详述的那样,他们与任何非线性叙事视频游戏中平淡无奇、容易被遗忘、可随意替换的角色都截然不同。正如之前讨论 "角色 "的文章所指出的,他们拥有完整的意识模拟,包括意识形态、性格、兴趣、欲望、技能和目标。 它们还具有语言、宗教和其他更多面向策略的方面,而且这些系统在《Axioms Of Dominion》中的深度也是独一无二的。

What the Characters in Axioms do is far more detailed, integrated, and flavorful than anything agents do in other strategy or social simulation games. As I’ll detail in this post they are very dissimilar from the bland, forgettable, and interchangeable agents in any non linear narrative video game. They have a full consciousness simulation including, as noted in previous posts discussing Characters: Ideology, Personality, Interests, Desires, Skills, and Goals. They also have Language, Religion, and other more strategy oriented aspects and also these systems are uniquely deep in Axioms.

难度、多样性还是真实性?

Difficulty Or Variety Or Verisimilitude?

策略游戏中的计算机代理应该有趣、有能力还是有味道? 为什么选择我说。 虽然在高度抽象或非常不切实际的控制方案下运行的游戏实际上只能选择难度作为AI目标,尽管开发人员声称不然。但在具有详细和集成模拟的游戏中,我们可以使我们的角色变得有趣、令人难忘、独特,并且有能力。 大多数策略游戏都将你作为不朽的蜂巢指挥来运作。 无论是RTS、战术策略、策略角色扮演等。 他们无法以任何其他方式运作。

Should computer agents in strategy games be interesting, competent, or flavorful? Why choose I say. While games that operate at very high abstraction levels or with very unrealistic control schemes can really only choose difficulty as an AI goal, despite devs claiming otherwise, in a game with a detailed and integrated simulation we can make our characters interesting, memorable, distinct, and competent. Most strategy games operate with you as an immortal hivemind command node. RTS, tactical strategy, strategt rpg, etc. Doesn’t matter. They can’t operate any other way.

在《Axioms Of Dominion》中,每个代理(主要是角色,但有时也包括下面提到的其他类型)都应该是有能力的(除非他们特别没有意识),与其他代理不同/有区别,并且至少可以根据他们的意识以半理解的方式运作。

In Axioms each agent, mostly Characters but sometimes other kinds as noted below, should be competent(unless they specifically aren’t Consciousness wise), varied/distinct from other agents, and operate in at least a semi-understandable way based on their Consciousness.

角色想要什么

What Characters Want

《Axioms Of Dominion》中的代理对玩家的角色可能是敌对、中立或友好。代理种类繁多,包括角色、人口、神灵和精灵/恶魔/生物/怪物。在这些代理类型中,还有各种子类型等等。

Agents in Axioms can be hostile, neutral, or friendly to the player’s Character. There are a wide variety of agents including Characters, Populations, Deities, and Spirits/Demons/Creatures/Monsters. Within these agent types there are a variety of subtypes and such.

角色可以是统治者、将军、政治家、操纵者等各种类型的领导者。他们也可以是商人、雇佣兵、冒险者、工匠、研究员等等。在这里,我将主要关注那些玩 "伟大游戏 "的人。政治领袖可能会涉足一个或多个其他领导角色,他们在《Axioms Of Dominion》中的性质和行为都是多种多样的。

Characters can be leaders of various types like rulers, generals, statesment, manipulators, and so forth. They can also be merchants, mercenaries, adventurers, crafters, researchers, and more. I’m going to focus primarily on those playing the “great game” here. Political leaders, who may dabble in one or more other leadership roles, are quite varied in Axioms both in their nature and actions.

两个领导人面对同样的问题,会根据他们的 "意识 "采取不同的解决方式。意识是一种类别类型,在代码中是一个子类,包含了角色的意识形态、性格、兴趣、欲望、技能和目标。人口也有意识形态,但没有别的。

Two leaders with the same problem will solve it in distinct ways based on their Consciousness. Consciousness is the class type, a subclass compositionally in the code, that contains the Ideology, Personality, Interests, Desires, Skills, and Goals that Characters will have. Populations also have Ideology but not the others.

其他类型的游戏,包括基于角色的策略游戏、社会模拟游戏和RPG,可能会像叙事 RPG 游戏那样给角色提供一个简单的伦理系统,或者像社会模拟游戏或基于角色的策略游戏那样给角色提供一套简单的性格特征,仅此而已。他们没有完整的个性,很少有多极化的意识形态,他们的文化/背景更像是一组次要的修正,任何用于技能检查之类的 "技能 "系统都非常简单。

Other genres including character based strategy, social simulation, and RPGs might give a character a simplistic ethical system like in a narrative RPG, or a simple set of personality traits like a social sim or a character based strategy game and that is really it. They don’t have a full Personality, they’ll rarely have a multi-polar ideology, their Culture/Background will be more like a minor set of modifiers, and any “Skill” system used for skill-checks and such will be quite simple.

在叙事性角色扮演游戏中,角色可能会有预定义的任务,但在这些类型的游戏中,他们都不会有有意义的兴趣/爱好、个人愿望或你可以帮助他们实现的目标。如果他们想成为大法师或成功的商人,你最多只能完成一次线性叙事冒险。你不会和他们一起训练,也不会用资源资助他们,你和他们也不会与其他感兴趣的角色建立实际的联系。

Characters might have predefined quests in a narrative rpg but in none of these genres will they have meaningful interests/hobbies, personal desires, or goals you can help them with. If they want to be an archmage or a successful merchant you’ll at most complete a linear narrative adventure. You won’t train with them or stake them with resources, you and they won’t build up actual contacts with other interesing characters.

角色会有兴趣和欲望。他们会希望与自己的兴趣互动,并按照自己的愿望行事。欲望可以由他们的性格、站位、兴趣、意识形态、宗教、关系等产生。愿望可以是任何事情,从为爱女找一个好丈夫到征服一个大陆,从收集史前魔法知识到向仇敌复仇等等。博客上专门关于 "欲望 "的帖子详细介绍了这些潜在的选项。

Characters will have Interests and Desires. They’ll want to engage with their Interests and act upon their Desires. Desires can be generated by their Personality, Station, Interests, Ideology, Religion, Relationships, and so forth. A Desire can be anything from finding a good husband for their beloved daughters to conquering a continent to gathering estoric magical knowledge to getting revenge on a hated enemy and more. The post on the blog specifically about Desires expands on the potential options.

欲望会被动或主动地影响你的人际关系。在一个政体中,角色可以自主满足自己的欲望,他们会更快乐,也更有支持者。你也可以主动帮助其他角色,这样他们的幸福感和与你的关系都会得到提升。

Desires will impact your relationships both passively and actively. In a polity where Characters can fulfill their own desires autonomously they’ll be happier and more supporter. You can also actively assist other Characters in which case the boost to their happiness and their relationship with you will be more intense.

兴趣是角色和关系与众不同的另一个方面。当你出于某种原因想让一个角色喜欢你时,无论是恋爱、政治支持还是纯粹的友谊,实现目标的最佳方式都取决于他们的意识,尤其是他们的兴趣。一般来说,一个人可以满足一个愿望,而且是一次性的。任何数量的角色都可以让一个其他角色参与他们的兴趣。

Interests create another aspect of the distinctness of Characters and Relationships. When you want to make a Character like you for some reason whether romance or political support or pure friendship the optimal way to achieve your goal depends on their Consciousness and especially their Interests. A Desire can be fulfilled by one person generally and is a one off boost. Any number of Characters can engage a single other Character in their Interests.

马术和自然主义者通常会非常乐意在山间林间小道上骑马。不同的角色对其他角色的看法只会得到基本的互动提升。相反,他们可能更喜欢讨论当时的学术问题或去酒馆。如果你想追求某个贵族女孩,也许她想在舞会上跳舞。或者她讨厌舞会,想偷偷溜去看魔术师或训练长矛或长剑。

A Character who is an equestrian and naturalist will generally be very happy to ride horses on wooded trails in the hills. A different Character would get only the base interaction boost to their Opinion of the other Character. They might instead prefer to debate scholarly issues of the day or go to the taverns. If you want to court some noble girl maybe she wants to dance at balls. Or maybe she hates balls and wants to sneak away to watch a magician or train with a spear or sword.

此外,你的角色会对这些不同的活动做出不同的反应。你可能讨厌在公共场合跳舞,但为了儿时的暗恋对象而忍着,需要通过其他活动来解压。这同样适用于NPC与NPC之间的互动。有些性格类型会减少或消除这种摩擦。具有这种特质的角色可能会成为一名出色的间谍或外交官。

Additionally *your* Character will react differently to these different activities. You might hate dancing in public but suffer it for your childhood crush and then need to decompress with some other activity. The same applies to NPC to NPC interactions. Some Personality types will reduce or remove such friction. A Character with such a trait might make a fantastic spy or diplomat.

角色如何实现目标

How Characters Achieve Goals

假设一个角色需要实现某个目标。也许是削弱一个敌对国家。不同的角色会根据他们的意识以不同的方式实现相同的目标。一个拥有强健体魄的角色,如果是军国主义者,对战斗和战略感兴趣,就会倾向于尝试以战争为基础的战略。野心勃勃的角色可能渴望征服。贪婪的角色可能会单纯掠夺征服的领土,而不愿费心统治。

Suppose that a Character needs to achieve some Goal. Perhaps bringing low a rival nation. Different Characters will consistently achieve the same goal in different ways based on their Consciousness. One Character with strong physical traits who is militaristic and has an interest in combat and strategy would be predisposed to attempt a war based strategy. An Ambitious Character might crave conquest. A Greedy Character might engage in a campaign of raiding and pillaging and not want to bother ruling conquered territory.

然而,一个拥有强大外交或阴谋技能的角色可能会试图在社会上孤立敌人,导致联盟终止或取消婚约。具有宣传技能的角色可能会制造恶毒的谣言来降低敌对国家的声望。拥有政治和间谍技能的角色可能会在封臣中制造叛乱。根据怨恨的程度,简单地让敌人颜面扫地或让封臣要求降低税收,都可能奏效。

However a Character with strong diplomatic or intrigue skills might attempt to socially isolate their enemy causing allies to break alliances or betrothals to be cancelled. Perhaps a Character skill at Propaganda might create nasty rumors to lower the prestige of the opposing nation. One with Political and Espionage skills might create a revolt among vassals. Depending on the degree of the grudge simply causing them to lose face or have vassals demand lower taxes or something migt work.

当角色选定一个主要目标,然后评估潜在的解决方案时,他们就更有可能选择符合自己意识的策略。如果以前的国王是军国主义者,建立了一支庞大的军队,那么注重经济的新国王仍然会考虑他们的军事实力,但他们会比以前的国王更倾向于制裁、关税或经济破坏。因此,他们不会盲目忽视自己的实际情况。此外,除非角色是个笨蛋或愚蠢的人,否则他们一般都会想出一个看起来有可能成功的有价值的方法。一个专注于管理或贸易的国王,即使他不喜欢冲突或认为自己是个拙劣的战略家,但如果有必要,他很可能会发动一场大规模战争,作为首要目标的一部分,同时随着时间的推移,他还会建立自己的信使网络或贸易舰队。

When a Character picks a primary goal and then evaluates potential solutions they will be more likely to pick strategies in line with their Consciousness. If the old king was militaristic and built up a large army, the new economics focused king will still consider their military power but they’ll be much more likely to prefer sanctions or tariffs or economic sabotage than the previous king. So they don’t blindly ignore their actual situation. Additionally unless a Character is dull or foolhardy or some such thing they’ll generally try to come up with a worthwhile method that seems likely to succeed. A king focused on administration or trade might very well launch a big war if he has to as part of a primary goal, even if he dislikes conflict or considers himself a poor strategist, while also building up their messenger network or trade fleet over time.

《Axioms Of Dominion》中的角色需要管理自己的精神状态、家庭状况,并考虑他们的支持度,而AI知道这一点。等我进一步完善AI并进行游戏测试后,我们就会知道它们在平衡方面有多有效,但它们每回合都会评估这些因素。即使是玩家也不可能在任何时候都无视自己的意识,为了一个特定的目标而盲目地横冲直撞。

Characters in Axioms need to manage their mental state, family situation, and consider their popular support and the AI knows this. We’ll see how effective they are at balancing things once I get farther into fleshing out the AI and doing playtesting but they will evaluate these factors every turn. Even the player won’t be able to blithly rampage along ignoring their Consciousness minmaxing for a single specific goal at all times.

疲惫、抑郁、生病或其他影响会对统治者的行动产生各种惩罚。有些角色甚至会因为某些因素而更关注自己的内心状态,而不是外部环境。例如,残忍的角色需要对他人做坏事,否则就会面临幸福惩罚。他们也会高估战争或酷刑等对他们来说是标签化的解决方案。其他性格类型也是如此。

Tired, depressed, ill, or otherwise impacted rulers will have various penalties to their actions. Some Characters even have factors causing them to focus more on their internal state than their external situation. Cruel Characters for instance will need to do bad stuff to others or face happiness penalties. They’ll also upweight solutions like war or torture that are tagged for them. The same with other personality types.

角色也会尝试考虑他们目标的交叉点。 我想获得荣耀并增加收入,征服、掠夺或强迫进贡都行。 我也想打倒我讨厌的对手。 我恨他的程度达到X,击败他的国家难度为Y,是攻击他还是选一个更容易的国家? 出于文化原因,我需要进口肉桂。 我讨厌的对手有肉桂,我应该尝试打破他与供应方的关系还是应该采取更简单的选择?

Characters will attempt to consider the intersections of their goals as well. I want to gain glory and increase revenues. Conquest or raiding or enforcing tribute is good. I also want to bring down a hated rival. I hate him X amount and his nation will be Y harder to defeat, is it worth it to go for him over an easier country? I need to import Cinnamon for cultural reasons. My hated rival has Cinnamon. Should I try to break his relationship with his supplier or should I take an easier option?

合格、有趣、逼真的AI需要时间

Competent, Interesting, And Realistic AI Takes Time

现在我们回到一开始的话题。与其他策略或社交模拟游戏相比,《Axioms Of Dominion》中由电脑控制的代理的操作要复杂得多。它们要考虑更多相互关联的变量和更多总体变量。即使采用了巧妙的多线程和高效的处理策略,这也需要大量的处理时间。

Now we get back to where we were at the start. The computer controlled agents in Axioms are operating at a much more complex level than those in other strategy or social simulation games. They are considering more interrelated variables and more variables overall. This requires a significant amount of processing time even with clever multi-threading and efficient processing strategies.

例如,《Axioms Of Dominion》试图永远不处理字符串比较。如果你愿意承受字符串比较所带来的性能损失,你就能编写出更简单、更容易的代码,但《Axioms Of Dominion》无法以这种方式运行。即使使用最高效的算法,你也无法在消费级硬件上实时完成《Axioms Of Dominion》所做的工作。

Axioms tries to never deal with string comparison for instance. You could get simpler and easier to write code if you were willing to take the string comparison performance hit but Axioms couldn’t function that way. Even with the most efficient algorithms you simply can’t do what Axioms does in real time on consumer hardware.

同样,《Axioms Of Dominion》对内存的要求也很高。为什么?我们从模拟代理之间非常复杂的关系中获得了很多价值,但我们也必须存储这些数据。我在代码复杂度上付出了很大代价,才将 "好感修正 "的 RAM占用率从57字节降至4字节。当你有成百上千个代理,每个代理都与成千上万个其他代理有关系时,你所拥有的 "好感"数量就会迅速激增。中小型地图可能至少需要32GB内存。在进行更深入的游戏测试和性能测试之前,我不会有最终的数据。

Similarly Axioms has significant RAM requirements. Why? Well we gain a lot of value from simulating very complex relationships between agents but we also have to store that data. At a significant cost in code complexity for me I got the RAM usage from “opinion modifiers” down from 57 to 4 bytes. When you have 100s of 1000s of agents who each have relationships with 1000s of other agents the number of Opinions you have spikes very fast. You’ll probably need a minimum of 32GB of RAM for small to medium maps. I won’t have final numbers until I get much farther into playtesting and performance testing.

我预计中型地图在游戏后期可能一回合需要一分钟处理,不过我们还不能确定,这只是因为 "规划阶段 "是在玩家回合时完成的。因此,只有 "执行阶段 "是在按下 "结束回合 "和新回合之间完成的。在游戏后期,"规划阶段 "可能需要 5 分钟,即使有大量的多线程处理。单核处理一回合可能需要 40 多分钟。

I’d expect medium maps to require maybe a minute of turn time processing in the late game, though we can’t know for sure yet, and this is only because the “planning phase” is done while it is the player’s turn. Thus only the “implementation phase” is done between when you press end turn and the new turn. The “planning phase” would probably take 5 minutes in the late game, even though there is significantly multithreading. Single core processing would arguably take 40+ minutes a turn.

当然,对我来说,《Axioms Of Dominion》提供了重要的价值,以换取基于回合的要求、高内存使用率和占用大量 CPU 时间。智能代理拥有不同的目标,他们的反应是可以理解和预测的,并且需要独特的互动来处理。

Of course Axioms provides, for me anyways, significant value in exchange for the requirement to be turn based, for the high RAM usage, and for using a ton of CPU time. Smart agents, with varied goals, who respond in an understandable and somewhat predictable way and who require unique interaction to deal with.

智能AI:NPC如何以有效、有趣、多样的方式运作?的评论 (共 条)

分享到微博请遵守国家法律