47
Procedural Generation of Game content

Lecture 5 - Procedural Content Generation

Embed Size (px)

DESCRIPTION

This is the 5th of an 8 lecture series that I presented at University of Strathclyde in 2011/2012 as part of the final year AI course. In this lecture I outline some approaches that use AI techniques to automate the creation of content within game world. I make specific reference to assets such as rocks and plants, to interaction mechanisms such as weapons and to quest generating systems, in particular Skyrim's Radiant engine.

Citation preview

Page 1: Lecture 5 - Procedural Content Generation

Procedural Generationof Game content

Page 2: Lecture 5 - Procedural Content Generation

Procedural Content Generation

• Procedural Content Generation is the process of

using techniques based on AI, maths and other

disciplines to automatically create game content.

• Consider a game set in a city

‣ How many unique buildings are there in a city?

‣ How frequently could you duplicate a building before

players noticed?

‣What about trees?

2

Page 3: Lecture 5 - Procedural Content Generation

Trees

• Trees are complicated.

‣ Easy to get wrong

‣ The same tree over and over breaks immersion

‣ Lots of trees in a forest

• You could pay an artist to sit and come up with the

look of a whole bunch of trees, then model them,

put them into levels etc.

‣ Costly, time consuming, bloats game’s size

3

Page 4: Lecture 5 - Procedural Content Generation

Lindenmayer Systems

• L-Systems are recursive grammar rewriting

frameworks.

• Defined as a tuple (A, S, R)

‣ Alphabet of symbols

‣ Starting state

‣ Rules that are used to rewrite the initial state

• Great for creating fractal patterns

• Iterate n times to get interesting shapes appearing4

Page 5: Lecture 5 - Procedural Content Generation

Koch Snowflakes

• A : variables - { f } constants - {+, -}

• S : f - - f - - f

• R : f > f + f - - f + f

5

Page 6: Lecture 5 - Procedural Content Generation

Koch Snowflakes

• Board work

6

Page 7: Lecture 5 - Procedural Content Generation

Koch Snowflakes

• n=0 : f -- f -- f

• n=1 : f + f -- f + f -- f + f -- f + f -- f + f -- f + f

• n=2 : f + f -- f + f + f + f + f -- f + f -- f + f -- f + f + f

+ f -- f + f -- f + f -- f + f + f + f + f -- f + f -- f + f -- f

+ f + f + f -- f + f -- f + f -- f + f + f + f + f -- f + f -- f

+ f -- f + f + f + f -- f + f

7

Page 8: Lecture 5 - Procedural Content Generation

Koch Snowflakes

• Assign meaning to each component of the alphabet

• f draw forwards

• + turn 60 degrees right

• - turn 60 degrees left

8

Page 9: Lecture 5 - Procedural Content Generation

Koch Snowflakes

9

N=0

Page 10: Lecture 5 - Procedural Content Generation

Koch Snowflakes

10

N=1

Page 11: Lecture 5 - Procedural Content Generation

Koch Snowflakes

11

N=2

Page 12: Lecture 5 - Procedural Content Generation

Koch Snowflakes

12

N=3

Page 13: Lecture 5 - Procedural Content Generation

Koch Snowflakes

13

N=3

Page 14: Lecture 5 - Procedural Content Generation

L-System Example

• A : Variables : {X, F} Constants : {+, -}

• S : X

• R : {X > F - [ [X] + X ] + F [ + F X ] - X, F > F F}

• Meanings :

‣ F draws forward, X is a dummy variable (no real action)

‣ - + left and right 25 degrees

‣ [ begins subtree, ] returns to start of sub tree

14

Page 15: Lecture 5 - Procedural Content Generation

L-System Example

15

Page 16: Lecture 5 - Procedural Content Generation

L-System Example

16

Page 17: Lecture 5 - Procedural Content Generation

Rocks

• Rocks have the same problem as trees.

• Seeing the same rock over and over has the same

issues as trees.

• Rocks can also be generated using L-Systems

‣ “SpeedRock: Procedural rocks through grammar and

evolution” Dart, Di Rossi and Togelius, Proceedings of the

FDG Workshop on Procedural Content Generation, 2011

17

Page 18: Lecture 5 - Procedural Content Generation

Evolving L-Systems

• It’s possible to take an L-System definition and

represent it chromosomally.

• From there we can apply all the kinds of tricks.

‣ Clustering

‣ Evolution

•We can evolve “art” based on our L-System

representation

18

Page 19: Lecture 5 - Procedural Content Generation

The Morph Lab

• Part of the ALife suite at http://alife.fusebox.com

• Starts from a single dot, player select the “fittest”

candidate from a selection of drawn L-Systems.

• Chromosome defines size, colour, rewrite rules and

number of iterations to rewrite for.

• Rapidly create interesting distinct patterns.

19

Page 20: Lecture 5 - Procedural Content Generation

The Morph Lab

• Demo

20

Page 21: Lecture 5 - Procedural Content Generation

Weaponry

• Procedural generation can be used for a lot more

than art.

•We can use it to generate the weapons that the

player might find in a game.

‣Not just the models of the weapons

‣ Also the stats and effects

21

Page 22: Lecture 5 - Procedural Content Generation

Borderlands

22

Page 23: Lecture 5 - Procedural Content Generation

Borderlands

• Borderlands has over 650,000 weapons in it.

‣Different stats

‣Different models

‣Different names

• In many ways, just a simple combinatorics problem

‣ Given a set of different options for these various

parameters, how many ways can we combine them?

• Beats sitting down and designing each one by hand!

23

Page 24: Lecture 5 - Procedural Content Generation

Galactic Arms Race

24

Page 25: Lecture 5 - Procedural Content Generation

Galactic Arms Race

• GAR uses the cgNEAT algorithm to evolve different

types of weaponry in the game.

• Fitness is based on the amount a weapon is used

• Parameters evolved include

‣ Colour

‣ Effects

‣ Trajectory

‣ Bullet lifetime

25

Page 26: Lecture 5 - Procedural Content Generation

Galactic Arms Race

26

Page 27: Lecture 5 - Procedural Content Generation

Galactic Arms Race

• Important - none of the behaviour the GAR

weapons exhibit is defined by the developer

• Completely emergent

• Randomised weapons guided by player preference

• Interesting effects appear quickly

• Balance could be difficult

27

Page 28: Lecture 5 - Procedural Content Generation

Quests

• Typically Role Playing Games (RPG) involve “quests”

• A mechanic for giving the player tasks and goals.

• Two different types

‣ Storyline - part of the narrative of the game

‣ Side-quest - time-wasting stuff that has no impact other

than giving the player things to do.

28

Page 29: Lecture 5 - Procedural Content Generation

Skyrim

29

Page 30: Lecture 5 - Procedural Content Generation

Skyrim - Radiant

• Skyrim is the debut for Bethesda’s Radiant quest

generator.

• Various quest-givers across the world are

generating quests procedurally.

• Not part of the core story arcs.

• Can have an effect on the world.

30

Page 31: Lecture 5 - Procedural Content Generation

Example - Thieves Guild

• The Thieves Guild is a group that the player can join

• Major quest arc related to the group

• Range of side quests

‣ Burglary, pickpocket, “shill” jobs

• Each type of quest has standard objectives

• The location of the objective changes each time, as

do the details e.g. what to steal.

31

Page 32: Lecture 5 - Procedural Content Generation

Mechanics

• In order to adequately execute this kind of system

‣Need a rich selection of potential locations

‣More immersive when we can talk about specific people

rather than generic villagers

•What does the player get from this diversion?

‣ Reward

‣ Experience and reputation

‣ Perhaps affects the world more broadly

32

Page 33: Lecture 5 - Procedural Content Generation

Levels

• It’s possible not only to generate components of the

game such as scenery and objective procedurally.

• Also entire environments for the player to

experience.

• Keeps the game fresh

• Enhances replayability

33

Page 34: Lecture 5 - Procedural Content Generation

Tiny Wings

• iPhone game based around a bird

• Touch the screen to fold wings, untouch to flap

wings

• Landscape features valleys

‣ Slide down the valley to gain speed

‣ Flip up the other side to fly through the air

• Aim is to get as far as possible in a given time

34

Page 35: Lecture 5 - Procedural Content Generation

Tiny Wings

35

Page 36: Lecture 5 - Procedural Content Generation

Tiny Wings

• Landscape is broken into discrete islands

• Each island has a general character

‣ 1st island has gentle rolling hills

‣ 4th island has sharp, deep valleys

• The level changes every day, but the overall tone of

it doesn’t.

• How can this be achieved?

36

Page 37: Lecture 5 - Procedural Content Generation

Parametric Definitions

• Landscape in Tiny Wings is effectively defined by a

single function for each island.

‣ Sinosoidal function.

‣ (More likely a unification of several sinosoidals)

•We can define the function with parameters

‣ The non-parameterised components define the character

‣ The parameters define the specific shape for today’s level

37

Page 38: Lecture 5 - Procedural Content Generation

Parametric Definitions

38

Sin(x) - note the characteristic roll

Page 39: Lecture 5 - Procedural Content Generation

Parametric Definitions

39

Contrast with 2sin(2x) - totally different “character”

Page 40: Lecture 5 - Procedural Content Generation

Parametric Definitions

40

2sin(2x) with 2.3sin(1.8x+15)

Page 41: Lecture 5 - Procedural Content Generation

Levels

•We can specify the level design in Tiny Wings as a

parameterised function.

•We can update the parameters on a regular basis to

alter the experience the player gets.

•We can control the way the experience changes by

how the parameters are applied.

41

Page 42: Lecture 5 - Procedural Content Generation

Difficulty

• Lots of games give players options of what difficulty

they want.

• There are obvious (naive) ways we can alter

difficulty.

‣ Give bad guys more health / make player weapons deal

less damage.

‣More bad guys.

‣ Fewer items, less ammo

42

Page 43: Lecture 5 - Procedural Content Generation

Difficulty

•We can also do stuff that’s way more subtle.

‣ Alter timings

‣Decrease visibility of “signposts” (markers within the

level that cue the player - often subconsciously - where

to go)

‣Mess around with the design of the level in more detail

43

Page 44: Lecture 5 - Procedural Content Generation

Difficulty of Levels

•We can make the same kind of manipulations to the

functions generating a Tiny Wings level dependent

on what difficulty the player has selected

‣ Easy level gives the functions a more gentle curve

‣ Hard level gives the functions a harsher minima

• Even within the different islands characters, we can

generate “easy” versions and “hard” versions.

44

Page 45: Lecture 5 - Procedural Content Generation

Difficulty in aMario-style game

• Consider a game like Mario

• Side scrolling

‣ Lots of jumping over obstacles

‣ Gaps to jump between

• How can we modify the difficulty of the level?

45

Page 46: Lecture 5 - Procedural Content Generation

Summary

• Procedurally Generated Content

‣ In-game assets

‣ Levels

‣Quests

• Introduced concept of difficulty in games

• Talked about the difference between obvious and

subtle changes in difficulty

46

Page 47: Lecture 5 - Procedural Content Generation

Next Lecture

• Talking about how we can use the player models we

created last week to understand video games better

• Using these models to build better content

47