游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

开发者谈《盗贼之海》的AI设计解析之三

发布时间:2019-09-30 09:34:30 Tags:,

开发者谈《盗贼之海》的AI设计解析之三

原作者:Tommy Thompson 译者:Willow Wu

欢迎来到AI与游戏,《盗贼之海》系列的第三篇。在前两篇,我分析了Rare公司是如何平衡这款海盗题材游戏的AI系统在不同服务器的游戏体验,另外骷髅和鲨鱼AI是如何促使玩家无论在陆地还是水中都保持警惕。在系列的倒数第二篇,我们来看看《盗贼之海》中玩家面临的三个最大威胁:巨齿鲨、海怪和骷髅船。

我们至今看到的AI都是围绕特定的设计元素而构建的。猪、蛇和鸡给藏宝的岛屿增加了生气,骷髅成为了你寻宝路上的障碍,而鲨鱼是为了不让你在水中闲得太久。虽然其他玩家小队也是你航海途中的威胁之一,但是Rare想要增加一些更具有震慑力的威胁,不管多牢固的大帆船也能被摧毁。

Sea of Thieves(from gamesindustry.biz)

Sea of Thieves(from gamesindustry.biz)

在游戏刚发行之时,海怪会在开放世界中捕猎船只,玩家可能会不幸成为它的猎物。饥饿深渊DLC引入了巨齿鲨,而诅咒之帆DLC加入了幽灵船——由一群骷髅掌舵的大型帆船。它们都有的特定激活条件,是游戏世界中大型海战事件的主角。海怪总是出没在公海上,随时准备攻击船只,而巨齿鲨最初需要完成梅里克的任务线才能激活,并且只在Devil’s Ridge岛的南部活动。同样,在诅咒之帆加入的骷髅船最初也只在3个地区活动——分别是Smuggler’s Bay、Sharkbait Cove和Marauder’s Arch的附近海域。然而,在这些DLC发行之后,巨齿鲨和骷髅船的活动范围逐渐扩大,以更灵活的方式遨游在公海中,伺机攻击玩家,跟海怪AI的运行方式更像了。

2018年的最后一个DLC雾锁宝藏,巨齿鲨有了多种个性、骷髅船分为了两种大小规模以及海怪攻击模式的调整。开发人员添加新特色、重新平衡现有内容为的就是让玩家时刻保持警惕。但这些变化也带来了一些新的问题,这些系统可以彼此交互吗?你可以通过攻击骷髅船来中断巨齿鲨的攻势吗?海怪或者巨齿鲨也会攻击骷髅船吗?

开发团队曾经担心过一个小队可能会同时遇上多种危险。然而,在经历了内部测试之后,团队的想法很快就发生了改变。你可以在最近的更新中看到开发者做了更多努力,从多方面确保这些交互的实际效果好玩有趣,同时还要将性能开销保持在最低限度,也就是我们在第一篇所说的那样。

在拜访Rare工作室期间,我找了个机会跟三位开发者坐下来聊了聊,他们的工作对新特色的发行起着至关重要的作用。巨齿鲨主要是由Andy Blastable负责,Chantelle Porritt和Tristan Bell分别负责海怪以及骷髅船的持续的开发、调整。我在上一篇与Rob和Sarah的视频访谈中就已经发现了这些系统的内部命名:海怪Kraken是Karen,巨齿鲨Megalodon是Megan,而骷髅船skeleton ships是Skevin(?)。

嘿,我知道你是来看敌对角色的AI分析,所以开始吧。让我们逐个分析,这些AI运作的基础是什么、自发行以来做过哪些调整和更新、它们是如何与第一篇中讲过的的AI管理系统相适应的、以及让骷髅到处跑并控制幽灵船所需的有趣技巧。

巨齿鲨

让我们先从最容易解释的开始:巨齿鲨Megan,在开发期间人们也称她为“小鲨鱼”。这是一个代号,目的是为了不让数据挖掘者发现开发人员的意图,因为他们总是在窥探下一次的更新内容。可以说,她是最容易解释的AI角色了,因为大部分内容我在第二篇就讲过了。巨齿鲨就是鲨鱼的加大号版本,只是她现在会攻击船而不仅是玩家。

然而,开发团队并不只是单纯地把鲨鱼变大,他们重新平衡了巨齿鲨的行为,以便更好地适应海战的节奏。为了让她的行为频率达到一个平衡的状态,他们用了计时器。这些行为包括跳出水面游到目标船只旁边、游到船下面、当然还有攻击和从船体上撕咬下一大块。虽然对绝大部分人来说她是一个挑战性十足的击杀目标,但开发人员仍然需要确保玩家能够拿下她,不会觉得游戏体验失衡。于是,他们不仅在视觉效果上做了调整——鱼鳍,也就巨齿鲨的顶部在海平面看得更加清楚了——还沿用了之前我们在第二篇中讨论过鲨鱼导航系统,确保Megan的位置在大炮射程之内。

在冷却时间结束后Megan会立即出现,可能会攻击船员,任何在还在水中的船员都能亲身领教她的愤怒。然而,尽管如此,其实有不小概率她只是跳出来捣乱罢了。自饥饿深渊发行以来,游戏后续的更新让巨齿鲨有了更多样化的外形和行为,还有不同的皮肤。她可能是以被动形态出现的,只会在被激怒时发动攻击。

海怪

接下来,我们来谈下游戏发行之初时就有的boss,海怪Karen!海怪会定期选择一艘船攻击,此时周围的海会变成黑色,几只触手从海底升上来。每次海怪出现时,触手会包围船只——是的只有触手,因此有很多玩家怀疑海怪Karen实际上就没有主体。有些触手是真的会攻击玩家和船,有些只是花瓶触手,为的是把画面弄得更加壮观。

海怪这个角色是非常独特的,她是唯一一个没有用虚幻引擎行为树构建的AI角色。每只触手都有属于自己的AI组件,或者是攻击玩家,或者是攻击船,又或者是屹立于海上什么都不做。它们从Overlord系统接受指令,系统命令哪些触手需要主动出击,并选择有效的目标。Overlord在一定程度上是作为一个有限状态机(finite state machine,是表示有限个状态以及在这些状态之间的转移和动作等行为的数学模型,游戏邦注)构建的,它的任务是关注攻击之间的时间间隔(无论攻击对象是船还是玩家)以及攻击方式。
跟Megan类似,Karen的触手包围船只是刻意设计的,为的是确保它在炮弹的射程范围之内,玩家可以打败它。此外,被攻击团队的每个玩家都会有对应的冷却计时器。当玩家被某个触手攻击后,冷却计时器就会重置。你会得到喘息的机会,要么赶紧回血,要么再次开始攻击。另外更关键的是,攻击会被分摊到其他船员和你的船只上。因此,一点合作+运气你就能把海怪送回老家。

每次Karen攻击服务器上的一艘船时,她都会等待一段时间再发动又一次攻击。所以在这期间全体船员都有机会处理自己的事。虽然具体的间隔时长还是个秘密,但与巨齿鲨一样,海怪攻击的冷却时间在游戏开发的第一年中经过了多次调整。另外,我了解到了一件有趣的事:Karen不会歧视任何人,她乐于攻击任何在海上的船员,甚至是刚才她已经攻击过的。虽然你可能暂时是安全的,但最好尽快把所有的战利品都扔到最近的据点。

骷髅船

最后一个但同样重要的——骷髅船。随着新DLC雾锁宝藏的发行,骷髅船现在能在开放海域航行了,如果有玩家靠近他们,他们就会立即发起攻击。每艘船上都有独立的AI骷髅船员,实时AI行为再加上一些烟雾弹式设计,既能简化开发人员的工作,又能达到预期的效果。事实上,骷髅船是游戏中最复杂的一组AI系统,从最初的概念到最后成品耗费了好几个月的时间。

这些船只依赖于它们自己独特的航行和转向机制,而虚幻4引擎没有内置的水上导航系统,这就跟鲨鱼AI的问题一样。因此,每艘骷髅船都有自己的传感器合集,不仅是用于探测附近的障碍物,还能计算出它和附近的船(无论是人类还是AI控制的)几秒钟后的移动位置。这有助于预测它与附近岛屿、礁石甚至其它船只的碰撞,并让掌舵AI相应地改变方向。当然,如果它是刻意想撞你的话那就另当别论了。这个设计方式也适用于从海洋里升起的船只,这样它们就不会落在另一艘船上。实际的运动速度要考虑风向等因素计算得出并做相应的调整。

现在,思考一下幽灵船的构造,它的甲板上有许多骷髅,每个骷髅都依赖于的他们独特的AI框架,正如我们在第二篇中详述的那样,骷髅与玩家共享输入接口,玩家能做的事他们也能做。然而,还是有一些限制存在的。他们可以部署大炮、用装备栏中的木板修理船体,但他们不能舀水——这就让玩家们想出了各种有意思的对策。开发人员确实用了一些蒙蔽人眼的技巧制造出骷髅船员控制帆船的效果。但船锚和船帆都不是骷髅控制的,是船本身调整的。我们已经解释了所有的导航系统,你们也可以推测出游戏不需要经由骷髅来控制航行路线。尽管如此,在船长没有到位的情况下船是无法行驶的。所以,虽然有船长掌舵才能扬帆起航,但实际上船本身就可以指挥一切。

所以,如果你想展示一下海盗的职业能力,可以去尝试分散船长的注意力,或者直接杀死船长,这都会迫使骷髅船停下来,而且其他骷髅都无法接手掌舵。记住这一点,下次你在海上看到他们的时候就有胜算了!

然而,不管这一切有多酷,骷髅船AI真正的成功之处是大多数玩家都不会留心注意的:骷髅是真的在甲板上、船体内都在活动。他们能够找到船体破洞里修理,也能够移动到到大炮后边发射它们。我知道对于大多数家来说,这听起来似乎并不是什么具有突破性的东西,但从AI的角度来看,这确实是个大事,是我在玩《盗贼之海》时的一个真正意外惊喜。让我来解释一下。

就如我们在第二篇中所分析的那样:一般我们会用一个叫作导航网格的系统让角色在三维空间内行走,游戏岛上所有的骷髅都是用这个系统。然而,导航网格或者是提前构建好的,或者是集成到关卡之中,又或者是像我最近研究的《地平线:零之曙光》那样,在运行时根据岩石或在导航网格表面移动的其他小物体的变化来计算。是的,导航网格可以适应在表面上移动的物体和角色的变化,但是导航网格本身并没有移动。如果这个二维表面也在移动,那就不仅要重新计算导航网格,还要重新规划所有站在这上面的角色的路径,哪怕只是移动一点点。这无疑会消耗很多CPU和内存资源,你很难想到适合的解决方案。但是在《盗贼之海》中,船体和甲板的表面并不只是随着海浪的移动而移动,船本身也是移动的!一开始时我以为这是假的:骷髅只是简单地从船上的一个点移动到另一个点,但是如果你仔细观察帆船上骷髅的移动方式,你会发现它们是按照自己的需求地四处奔走,从海洋物理学的角度来说,它们一直都是站在一艘移动的船上。
最大的秘密在于船只的导航网格其实是静止的,它是覆盖在海底的,船上的骷髅其实还是跟岛上的一样,在导航网格上移动。也就是说导航网格是固定的,不会跟随船只移动。同时,海底导航网格上的坐标分别被传送到甲板以及船体上,这个过程必须考虑船目前的方向。也就是说,导航路径需要跟随船只的实时转向而变化。面对这个非常复杂的问题,开发团队给出了一个颇具创造性的解决方案,虽然不算完美,但它确实很好地实现了团队的目标!

总结

虽然其他其他玩家是你航海途中的真正威胁,但是这些AI角色也是不可忽视的狠角色。这三篇文章中我们探讨了《盗贼之海》游戏体验背后的所有AI系统,它们为你提供任务、在岛屿和海上生成不同个性的AI角色(友善和非友善)、平衡不同服务器上的玩家体验。但我还不打算在此画上句号。《盗贼之海》这个游戏需要Rare全体开发成员的大量投入,无论是原画师、动画师、声效设计还是程序员都是如此,事实证明要驾驭类似规模的项目是非常具有挑战性的。

在系列的最后一篇,我们会谈到贯穿《盗贼之海》整个开发过程的测试、部署系统,以及它是如何简化开发团队的工作。我将采访项目的两位领导主力Andy Bastable和Rob Masella——他们从代码库入手,将《盗贼之海》引向新的未来。为了预防玩家在游戏过程中AI或者其它游戏系统出现bugs,测试系统起到了什么样的作用?以及游戏是如何做到快速部署的?

本文由游戏邦编译,转载请注明来源,或咨询微信zhengjintiao

Welcome to part 3 of the AI of Sea of Thieves here on AI and Games. In parts 1 & 2 I looked at how Rare’s online pirate game balances the AI systems at play across each server plus how skeleton and shark AI are built to keep players on their toes both on land and in the water. In this penultimate video we look at the three biggest threats players face across the Sea of Thieves: Megan, Karen and…. Skevin??

All of the AI we’ve seen to-date in this series on Sea of Thieves is built to facilitate a specific design element. The pigs, snakes and chickens bring life to the tropical islands, the skeletons present a threat that seeks to thwart your quest for hidden treasure whilst the sharks seek to keep you from sitting too long in the water. While other crews of players present a threat as you sail the Sea of Thieves, Rare sought to add great threats that could sink even the strongest of galleons.

At launch players could fall prey to the Kraken as it hunted ships on the open seas. Meanwhile the Hungering Deep expansion introduced the mighty Megaladon plus the Cursed Sails event brought haunted galleons commanded by skeletons to open waters. Each of these act as larger event battles on the sea that have varying conditions that enable their activation. The Kraken has always been haunting the open seas ready to attack ships, while the Megalodon originally could only be summoned having completed Merrick’s quest line and traveling just south of the Devil’s Ridge. Similarly, the haunted galleons which first appeared during the Cursed Sails event were constrained to three specific sites near Smuggler’s Bay, Sharkbait Cove and Marauder’s Arch. However, since those expansions, both the Megaladon and the skeleton ships have expanded their remit; spawning the open world attacking players in a more dynamic fashion more akin to how the kraken operates.

The last content drop of 2018 – the Shrouded Spoils – addressed each of these experiences by adding new features and re-balancing existing ones all in an effort to keep players on their toes. This led to the likes of varying megalodon personalities, two sizes of skeleton ships and tweaks to kraken attack patterns. But as these changes were being made, it led to new constraints to be managed within the core gameplay systems. Do you allow these systems to interact with each other? Can you be attacking a skeleton ship only for a megalodon to interrupt. Does a kraken or megalodon attack skeleton ships as well as players?

At one point there was a concern about having more than one of these systems in play at once for a given crew. However, upon experiencing themselves when testing internally, the opinion with the team shifted pretty quickly. As a result, there has been a more concerted effort in recent updates to ensure that these interactions continue to prove interesting and fun, whilst also enabling them to interact with one another all while keeping those AI overheads discussed in part 1 to a minimum.

During my visit to Rare I had the chance to sit down and chat with three developers whose work had proven critical to the release of each of these features. Andy Blastable, who discussed his work on the Shark AI in part 2, was largely responsible for the development of the Megaladon, while Chantelle Porritt and Tristan Bell who had a big hand in the ongoing development of the Kraken and Skeleton ships respectively. But during my interview on skeleton AI with Rob and Sarah from back in part 2, I quickly discovered that each of these systems go by slightly different names internally. So while the Kraken and Megalodon become Karen and Megan respectively, the skeleton ships became known as Skevin (?)

But hey, I know you’re here to listen about the AI of these enemies, so let’s do just that. Let’s take a look at each of these threats in turn, the basics of how they work, the tweaks and updates made since launch, how each of them fit within the existing AI management systems discussed in part 1, and the fun tricks required to have the skeletons run around and take command of the haunted ships.

The Megaladon

Let’s begin with the easiest one to explain: Megan, the Megalodon, or as she was called during development: ‘Tiny Shark’. It was a codename that sought to keep the developers intentions hidden from data miners always spying for the next update. She’s arguably the easiest AI to explain because, well… I already did much of the leg work in part 2. Given that the Megalodon is – for all intents and purposes – a larger version of the original shark AI, only she now attacks ships instead of players.

However it’s not as straightforward as just ‘big shark’, Megan’s behaviour is re-balanced to better fit the pacing of naval combat. A set of gameplay timers are used to balance the frequency of her behaviour set. This includes popping out of the water to swim alongside your ship, swim under the boat and of course attacking and taking a big chunk out of the hull. While she presents a big enough target to shoot at for the most part, there’s still a need to ensure players can take her down and not feel like the experience is unbalanced. This not only resulted in custom visual effects being employed such that the fin and top of the Megaladon are better visible when on the surface, but the existing shark navigation systems discussed back in part 2 are employed to ensure that Megan is often positioned such that she is within cannon range.

Megan can spawn in to attack a crew once her cooldown timer has ended, after which point any crew that’s out in open waters can potentially suffer her wrath. However, despite this, there’s actually a good chance Megan will only pop up just to mess with you. The updates since the Hungering Deep have added a lot of variety to the Megalodon’s look and behaviour, with different skins, as well as the chance she can spawn in a passive mode whereby she’ll only attack when provoked.

The Kraken

Next up, let’s deal with the boss monster released at launch, Karen the Kraken! The Kraken periodically opts to attack a particular ship somewhere in the open world. Upon triggering the attack, the seas nearby turn black and several tentacles rise from the depths. Each time the Kraken spawns in, the tentacles surround the ship – and yeah it’s just tentacles, as many players have suspected since the beginning, Karen doesn’t actually a main body. Her tentacles are a mixture of those that are actually going to attack players and the ship, as well as those that are merely set dressing and designed to add some scope to the proceedings.

Karen is unique, in that she’s the only AI character in the entire game that isn’t reliant on the behaviour tree architecture in Unreal Engine 4. Each tentacle is it’s own unique AI component, which can either attack a player, attack their ship or simply sit in the water and not engage. However, the tentacles are built such that they all receive instructions from a system known as Overlord, which dictates which tentacles should be active and selects valid targets. The Overlord is built more or less as a Finite State Machine, and its job is to keep an eye on the time between attacks, whether a tentacle is attacking the ship or players and the types of attacks being employed.

Much like Megan, Karen’s tentacles are deliberately spawned in such a way to ensure you can defeat them, with them deliberately positioned around the ship such that they are within cannon and pistol firing range. Plus each player on a given crew that is going to be attacked by Kraken has their own corresponding cooldown timer. When that player is attacked by one of Karen’s tentacles, the cooldown timer is reset so that – for a period at least – you’ll get a breather and either recover or start attacking once more. Plus more critically, this distributes the damage being delivered across all the crew and the ship. Hence with a little bit of coordination and luck, you can send Karen back to the depths of the ocean.

Every time Karen attacks a ship on the server, she’ll wait a certain amount of time before doing so again. Hence there’s a chance for all crews to go about their business for a short while before they’re attacked again. While the time between attacks is still a secret, the Kraken’s attack cooldowns like the Megaladons has changed and received tweaks throughout the first year of the games development. However, one interesting thing I did learn that she doesn’t discriminate and will happily attack any crew that is out in open waters – even if it’s a crew she’s already attacked in the same play session. So while you might be safe for a time whilst attacking a Skeleton Fort on land, you better be quick about dropping all that loot off at the nearest outpost .

Skeletons Ships

Last but not least, let’s look at the skeleton ships. As recently as the Shrouded Spoils, skeleton galleons can now appear on the open waters and proceed to attack players if they get a little too close. Each ship has its own crew of individual AI skeletons and there is an interesting combination of real-time AI behaviours being deployed, with some smoke and mirrors to streamline the overall process for the developers while attaining the desired effect. It’s actually the most complicated set of AI systems in the entire game and took months to come together from original concept all the way to finished product.

The ships themselves are reliant on their own unique sailing and steering mechanisms, given much like the issues had with the shark AI, there’s no navigation systems built in UE4 to handle ships atop water. So each skeleton ship has it’s own collection of sensors not only for detecting nearby obstacles, but calculating where both it and nearby ships – be they human or AI controlled – are going to be a couple of seconds from now. This helps anticipate collisions with nearby islands, rock outcrops and even other ships – unless of course it wants to ram you – and allows the steering AI to move the ship accordingly. This projection is also applied to the ships rising out of the ocean, so that they don’t land atop another ship. The actual movement speed is calculated based on the potential it can achieve based on wind direction and adjusted accordingly.

Now if you consider the make-up of a haunted ship, it has numerous skeletons running around the deck. Each of these are reliant on the skeleton AI framework as detailed in part 2, where they interface with a virtual representation of the players input to do the same things as we can. However there are some limitations. They can man the cannons and repair damage using the planks in their inventory, but they can’t bail water – which has led to some creative solutions for defeating them by players. But it does employ some smoke and mirrors to sell the effect of a skeleton crew manning a ship. The anchor and sails aren’t controlled by the skeletons, the ship itself corrects their position. Plus having explained all of the navigation systems a minute ago, this removes the need for a skeleton to try and calculate the navigation itself. But despite that, the ship can’t steer lest this fella right here is at the helm, the Captain! So while the Captain must be at the helm in order for the boat to sail, the ship effectively controls itself.

So there you go, if you’re looking to engage in a spot of piracy, distracting the captain from the wheel or outright killing it will force a skeleton ship to stop and no other skeleton can take control. Keep that in mind next time you spot one in the open seas!

However, despite how cool all this is. The real success that has been achieved in the skeleton ship AI is one that most players would never thing twice about: the skeletons on the ships are actually moving around both on the deck and in the hull. They’re capable of moving to holes in the hull to repair them as well as head for the cannons to fire them. Now this is something that for most players isn’t all that ground breaking, but from an AI perspective this is actually a really big deal and the one thing upon playing Sea of Thieves that really took me by surprise! Let me explain.

As I discussed back in part 2: we typically use a system called a navigation mesh for characters to walk across 3D environments and in fact all the skeletons on the islands are using a nav mesh system to move around. However, navigation meshes are typically built or baked into the level in advance or – like in my recent case study in Horizon Zero Dawn – calculated at runtime based on changes by rocks, or other small items being moved around on the surface of the nav mesh. So yes they can adapt to changes in objects and characters being moved around on the nav mesh itself, but the navigation mesh itself isn’t moving. If the surface itself was moving, it would have recalculate not just the nav mesh but also the paths of all characters standing on it every time it moves by even the smallest amount. That’s simply far too much CPU and memory resource to consume. It’s a massive bottleneck. But here in Sea of Thieves, the surfaces of the hull and deck aren’t just moving in line with the waves of the ocean always moving, but they’re on a moving ship! At first I thought it’s faked: that the skeletons simply move from one point on the ship to another, but if you look at how they move on galleons, they’re running around as they wish, all the while adhering to the topography of standing on a moving ship with respect to the physics of the ocean.

The big secret is that the navigation mesh for the ships isn’t actually moving. It’s baked deep into the ocean. The navigation mesh for the entire ship is baked onto the deep down on the ocean floor and each skeleton is plotting their movement on that nav mesh. This nav mesh doesn’t move with the ship and stays at a fixed point. Meanwhile each coordinate on the navigation mesh is transposed from the ocean floor onto the ships deck and hull respectively. This has to factor the current orientation of the ship with regards to the oceans surface. Meaning the navigation paths need to follow the actual rotation of the ship as it crashes though a wave. It’s a creative solution to an otherwise horrendously complicated problem and while not perfect, it achieves what the team wanted really well!

Closing

While players present a real threat to one another as you sail the seas, the AI characters are still pulling their weight. Throughout the past three videos we’ve covered all of the AI systems that are running under the hood during your Sea of Thieves of experience: crafting missions for you, spawning a variety of friendly and aggressive AI characters on both land and at sea and balancing the overall experience for players across the server. But despite all that, I’m not done yet. A game like Sea of Thieves takes a lot of dedication from the entire development team at Rare, from artists and animators to sound designers and programmers, and it can prove challenging to steer a project of this size.

In my closing entry on the AI of Sea of Thieves, we’re going to look at testing and deployment systems used throughout Sea of Thieves development and how it streamlined working practices. I’ll be chatting with Andy Bastable and Rob Masella, two of the leads on a project that were responsible for steering this new direction on the Sea of Thieves codebase; how a testing system helps prevent bugs with AI and other gameplay systems from reaching players and how automated builds enabled for continued rapid deployment of the game long before it ever appeared on the Xbox marketplace.

(source:gamasutra.com


上一篇:

下一篇: