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

在游戏中使用程序生成内容的5大诀窍

发布时间:2012-11-22 09:30:52 Tags:,,,,

作者:Mike Rose

程序生成内容是不是很厉害?尽管反复玩的是同一款游戏,但是每一次都能够感受到完全不同的体验;从开发角度来看,开发者只需要创造出少量的内容便能够呈现给玩家非常有趣的体验。

但是程序生成内容并非总是有效,许多中核游戏便总是未能够整合随机放置的内容。而“少即是多”原理(Eufloria开发者Rudolf Kremers最近所提出的)则能够帮助独立工作室节约时间去专注于其它开发领域(如果使用得当的话)。

独立工作室Serious Brew旗下的《Cargo Commander》便添加了程序生成内容,即让玩家能够在随机的太空集装箱中穿行着,并尽快抓取更多珍宝。这有点像太空中的《洞穴探险》。

该工作室的联合创始人Maarten Brouwer说道:“我一直对程序内容创造充满兴趣,从年轻的时候刚开始编写基本的程序,经过接触分形学以及人工智能,再到投入好几个小时于那些拥有各种程序生成形式的游戏中。”

通过创造《Cargo Commander》,Brouwer已经明确了在生成关卡时应该瞄准哪些内容并避免哪些内容了。他承认:“生成内容并不是像我们所预期的那样随时有效。但是如果合理使用的话便能够带来非常棒的结果。”

Brouwer明确了在游戏中添加程序生成内容需要掌握的五大诀窍。

1.有选择地进行设置

“不要想着只是挑选一部分游戏设计并将其创造成程序生成内容便可。你需要将游戏机制,主题和程序生成内容有效地整合在一起,并努力实现低成本创造出高效率的结果。

在《Cargo Commander》,基于孤独的太空探索主题我们创造了独特的生成关卡:这一次玩家将来到一个未曾有人探及的地方!同时游戏主题也不会过于严肃,生成关卡虽然有点奇怪,但却不会太过突兀。除此之外生成内容不仅会影响背景设置,同时还会影响到游戏玩法。每个集装箱中的对象(包括敌人,爆炸物,燃烧器和道具)和功能(如重力和布局)也都各不相同,从而创造出各种材料让玩家可以以各种不同的方式进行结合。

另一方面,我也尝试着去避开一些无效的程序生成功能。例如一些关卡生成内容是用于确保某些关卡能够得到解决——‘能否使用道具到达带有钥匙的壁架?’游戏中存在一些检查能够避免那些不可能的情境,而关卡破坏性和空间导航则能够确保玩家总是能够创造出各种路线,并且因为玩家可以跳过某些集装箱,所以即使未能得到货物道具也不会构成什么大问题。而关于如何通过集装箱,这更像是一个需要玩家解决的益智问题,对此我设置了随机功能(确保不会影响到玩家解决问题),而其它内容则是基于手动制作关卡。”

2.随机性设置

“《Cargo Commander》便拥有随机生成关卡。区域名称(玩家可以从列表或类型中自由挑选)便决定着随机种子,而区域中的所有关卡都是基于种子的随机生成值。当我们在决定如何使用随机生成值时还应该考虑随机属性。

统计数据是用于观察随机性的最常用的方法。例如‘集装箱的规格值在3至9之间,所以集装箱的平均规格变为6,’又或者‘每个集装箱生成医疗包的机率为25%,所以当玩家遇到一个集装箱4次便能够获得1个医疗包。’如果涉及的总数过大,这种方法便很难发挥功效了,而在现实中这些数值也不如想象中那般有效。就像连续旋转将会导致愤怒的霍比特人能够轻易击败野蛮人——尽管野蛮人已经到达了第10个关卡,而玩家在某些区域中可能只会遇到小于规格6的集装箱。

大多数情况下这并不是问题所在,并且还能促成各种有趣的变化,但是如果涉及到游戏平衡,问题就出现了。尽管每个集装箱生成医疗包的机率为25%,但是之前生成的20个集装箱却未包含任何医疗包,也就是游戏比预期变得更加复杂且不公平。所以我们最好能够使用一些不会过多影响游戏平衡的随机元素,例如在20个集装箱中随机分发5个医疗包,或在两个医疗包出现的间隔变化集装箱的数量。”

3.赋予个性

“在我看来程序生成内容最复杂之处便在于避免随机拼凑一些死气沉沉的对象。当关卡设计师创造出关卡后,他便会添加一些额外功能或含义去赋予这些关卡个性。我也采取了一些方法去完善这一点:

如果你在纸上快速绘制出一张地图,为何你不选择你所选择的功能呢?这时候简单的方法总是最有效;就像我总是会使用对称性或在一般模式中使用基础设计,然后将其整合进生成代码中,并取得非常棒的功效。

some_containers_from_sector_GALLIFREY(from gamasutra)

来自GALLIFREY区域的程序生成集装箱(from gamasutra)

秘密地混合于手动关卡设计中。我已经创造了一些较小的关卡,并将其与生成过程的其余内容混合在一起。如果只使用功能元素并随机分配其它元素和外观的话,玩家便不会轻易认出这些重复使用的内容。

创造特殊体验。如果日常关卡中只包含一半的资产,而剩余的资产则很少出现,那么每次这些资产的出现都会让关卡变得更加特殊。这同样也适用于参数中;如果一般集装箱的规格在3至9之间,那么遇到规格为15的集装箱便是一种特殊的体验(游戏邦注:特别是当结果参数处于最佳游戏玩法的范围之外时)。

赋予资产存在的意义。Daniel Ernst所带领的另外一半的开发团队成员制作了详尽的模型,添加了更多角色,从而让原本非常简单的关卡具有了氛围。如果它们能够暗示更多内容,故事背后还存在故事,那么资产的随机结合也将具有额外的含义。”

4.为艰难的测试做准备

“在完成了一些原型创作后我创造了一个生成系统,之后我又基于区域随机界限创造了更复杂的分层系统;在区域随机界限中剩下的生成内容将能够发挥功效,并将受到被选中的集装箱主题,规格以及波数的影响。

我不知道这种方法是否有效或者这些生成内容是否能够保持平衡,并且之后我又遇到了一个问题:我不能对此进行测试。当我进入一个区域并遇到五个载满敌人的集装箱时,是否意味着游戏生成了过多敌人?或者说这一区域结合特定集装箱规格而生成敌人的随机数太高了?对于大多数参数我都测试了平均值以及理论上的最小和最大值,但是因为许多参数都会相互影响,所以测试结果并不明确。

在玩了许多游戏后,你便会对平衡问题更加敏感,并且能够很容易基于一个游戏攻略而总结出其中的问题(尽管其它攻略可能并未体现出这些问题)。我们总是很难清楚属性调整具有何种影响,所以到最后只能根据直觉去设置/调整属性。而邀请许多人帮忙测试也非常重要。

a sector pass container plan(from gamasutra)

在区域中通过集装箱的计划(from gamasutra)

当然了,面对程序生成内容是件很棒的事:如果生成内容能够越复杂就越好了,最好连设计师也不知道接下来会生成何种内容!”

5.利用起来!

“使用程序生成内容能够促成各种可能性——不只是添加无数的关卡(如此很快便会让玩家感到厌烦了),这也是静态的关卡设计所不能做到的。在《Cargo Commander》中,进入种子所生成的区域名(每个名字都有自己的在线排名)的机制便非常有效。

更有趣的可能性还包括基于玩家的状态或他们在之前关卡中的行动创造关卡;整个游戏世界将根据玩家的决定发生改变!或者给予玩家一些明确的权利,让他们能够选择特定的参数或制定一份基本的关卡大纲(并在之后进行自动填充)。

混合其它游戏元素,甚至可以添加一些奇特的选择。对于我来说,程序生成内容,人工智能以及用户生成内容是将游戏从一种静态体验带向动态且生动体验的重要机制。”

本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转载,如需转载请联系:游戏邦

5 tips for using procedurally-generated content in your game

By Mike Rose

Isn’t procedurally-generated content brilliant? Playing the same game over and over again, yet receiving what can be a satisfyingly different experience each time — and from a development perspective, the prospect of building only a small amount of content, and then being afforded the opportunity to focus more on making your title as enjoyable as possible.

OK, so procedural generation doesn’t always work so swimmingly, and there are plenty of mediocre games that have tried and failed to incorporate randomly-placed content. But taking the “less is more” approach, as Eufloria dev Rudolf Kremers recently called it, is a great way for indie studios to free up time to focus on other areas of development — if done successfully.

Cargo Commander from indie studio Serious Brew manages to ride procedurally-generated content into the sunset, with players zipping through random space containers to grab treasures as quickly as possible. A sort of Spelunky in space, if you will.

“I’ve always been interested in procedural content creation, from the BASIC programs I wrote when I was little, through fractals and my training in artificial intelligence, to the many hours I spent in games that had any form of procedural generation,” says Maarten Brouwer, co-founder of the studio.

Through the creation of Cargo Commander, Brouwer has learnt a great deal about what to aim for — and what to avoid — when it comes to level generation. “It didn’t always work out as well as I would have liked,” he admits, “but had several cool and surprising results that really improved the game.”

Here, Brouwer offers his top five tips for other studios considering procedurally-generated content in their games.

1. Pick your battles

“Don’t expect to simply pick a section of the game design and make it procedurally-generated. Adapt the game mechanics, theme and the procedural generation to each other to make it work as effectively as possible, and try to focus on high bang for low buck.

In Cargo Commander, we made the uniquely generated levels fit well with the lonely space exploration theme: this time you really go where no man has gone before! At the same time, the theme is not too serious, so that generated levels that are a bit odd don’t seem out of place. Also, the generation really impacts the gameplay and is not just a backdrop. The selection of objects (enemies, explosives, burners, items) and features (gravity, layout) differs for each container, creating ingredients that the player can combine in various cool improvised ways.

In other areas, I tried to steer away from features of procedural generation that wouldn’t be effective. For instance, a notoriously hard thing with level generation is to ensure that levels can be solved – ‘can that ledge with the key be reached, using the items that are available?’. Though there are a few checks to minimize impossible situations, the level destructibility and space navigation make sure that the player almost always can create a route somewhere, and because containers can be skipped, it’s not a big problem if one cargo item is unreachable. For the sector pass containers, that are more like a puzzle and do need to be solvable, I kept the randomization to features that wouldn’t influence this, and relied on handmade levels for the rest.”

2. Remember that randomness is random

“The levels of Cargo Commander are randomly generated. The sector name (that players can pick from a list or type freely) determines the random seed, and all levels in that sector are generated from random values based on that seed. However, it’s important to take the attributes of randomness into account when deciding how to use the random values for generation.

The usual way to look at randomness is by using statistics. For instance ‘the container size picks a value between 3 and 9, so on average containers have a size of 6′, or ‘each container has a 25 percent chance to spawn a medkit, so on average they’re encountered once each 4 container’. However, unless the population that they say something about is large enough, in reality such numbers are less useful than they seem. Just like rolling 1s in a row may cause a barbarian to be defeated by an angry hobbit cook despite the barbarian’s level 10 and Loincloth of Awesomeness, the player may encounter only really tiny containers in a sector, with an average far below 6.

In many cases this is not a problem and may cause nice variation, but when game balance is involved, this can become a problem. If despite the 25 percent, the first 20 generated containers don’t have medkits at all, the game gets harder or more unfair than intended. In that case it may be better to use the randomness in a way that can’t affect game balance too much, like randomly dividing 5 medkits over the 20 containers, or randomly vary the number of containers between the first medkit and the next.”

3. Try anything to add ‘life’

“In my opinion, the hardest part of procedural generation is to avoid getting randomly thrown together objects that feel lifeless. When a level designer crafts levels, (s)he adds personality to it with unique features or things with an extra meaning above the mere components. I’ve tried several things to improve this:

Use introspection. If you quickly draw a map on paper, why do you choose the features that you choose? Even simple things help here; I noticed that I often use symmetry, or base designs on general patterns, and incorporating that in the generation code helped a lot.

Procedurally-generated containers from the GALLIFREY sector

Cheat by secretly mixing in handmade level design. I’ve created a number of tiny pieces of level that get mixed in the rest of the generation process. By only using their functional parts and have the other parts and the appearance be randomized, players won’t recognize these reused parts too quickly. It’s almost depressing to see how well these tiny hand-designed pieces work.

Create specialness. If half of the assets are used in everyday levels, but the other half are encountered rarely, each encounter of a rare asset automatically makes the level more special. This also works for parameters; if container size is normally between 3 and 9, a rare encounter of a container of size 15 becomes a memorable event (even/especially when the resulting parameter is outside the bounds for optimal gameplay).

Let assets radiate life. Daniel Ernst, the other half of the dev team, made detailed models that add a lot of character, so that even a simple level has atmosphere. If they hint to something more, a story behind the story, then a random combination of assets can suddenly get an extra meaning.”

4. Prepare for tough testing

“When I built the generation system after some first prototypes, I created a rather complex layered system, with the sector randomizing boundaries in which the rest of the generation worked, further influenced by such properties as the selected container theme, the container size and the wave number.

I had no idea if it would work and be balanced, and then I encountered a problem: I couldn’t test that either. When I’d try out a sector and encountered five containers that are full with enemies, did that mean that too many enemies get spawned? Or was this sector one of which the enemy count was randomly set very high, combined with the specific container sizes? Or did a few random rolls just came up with a lot of sixes?
For most parameters I tested the average value and a theoretical min and max, but because many parameters influence each other, this was not definitive.

After playing many games, some balance problems can become apparent, but it’s easy to conclude some issue based on one playthrough, while a next playthrough shows nothing of the sort at all. Knowing what effect a property adjustment has is even harder. In the end setting/tweaking the properties was mostly done on gut feeling. Having a beta with a lot of people was essential as well.

A sector pass container plan

This is also the cool thing with procedural generation, of course: if it’s complex enough, even the designer has no idea what might be produced!”

5. Do something with it!

“The use of procedural generation opens up all kinds of possibilities that aren’t possible with static level design, much more than merely adding an infinite amount of levels (which quickly gets boring anyway). In Cargo Commander, the simple mechanic of entering a sector name that seeds the generation, with each name having its own online leaderboard, worked surprisingly well.

More interesting possibilities include creating levels based on the status of the player, or what the player has done in previous levels; the whole world can change based on his decisions! Or the player can be given explicit influence, by choosing certain parameters, or perhaps have him make a basic level outline that’s further filled in automatically.

Mixed with other game elements, even more exotic options are possible. To me, procedural content generation, artificial intelligence and user generated content are mechanisms that can elevate a game from a static experience to a highly organic, living whole.” (source:gamasutra)


上一篇:

下一篇: