SlideShare une entreprise Scribd logo
1  sur  92
Télécharger pour lire hors ligne
Game Programming
Procedural Content Generation
Nick Prühs, Denis Vaz Alves
Objectives
• To get an overview of the different fields of procedural content
generation
• To learn how to procedurally generate content of different types
• To understand game design implications of using generated content
in games
2 / 90
Procedural Content Generation
“Procedural content generation (PCG) refers to creating game content
automatically, through algorithmic means.”
- Togelius, Yannakakis, Stanley, Browne
“PCG should ensure that from a few parameters, a large number of
possible types of content can be generated.”
- Doull
3 / 90
Categories of PCG
• Online Level Generation
• Offline Level Generation
• Fixed Seed Level Generation
• Game Entity Instancing
• User-mediated Content
• Dynamic Systems
• Procedural Puzzles & Plot Generation
4 / 90
Categories of PCG
5 / 90
Online Level Generation in Diablo 2
Categories of PCG
6 / 90
Fixed Seed Level Generation in Elite
Categories of PCG
7 / 90
Game Entity Instancing in Spore
Categories of PCG
8 / 90
Dynamic Systems in Left 4 Dead
Opportunities of PCG
• high diversity of the resulting assets
• faster than any human designer could ever be
• significantly reduces production costs
• allows for a mixed-initiative approach to level design
• content automatically implemented in the engine
• can save vital system resources
• players can influence the parameters of the game world
• possibility of automatically analyzing player behavior
9 / 90
Opportunities of PCG
10 / 90
Procedurally Generated Item in Diablo 2
Opportunities of PCG
11 / 90
Map Editor of Age of Empires 2
Opportunities of PCG
12 / 90
Game Parameters of Master of Orion 2
Challenges of PCG
• Satisfying a high number of constraints (e.g. full connectivity)
▪ Finding these constraints and tweaking unintuitive parameters of
the system can degenerate into trial and error
• Produce aesthetically pleasing results
▪ Levels can become too similar to each other
• Maximize the expressive range (variety of results)
▪ Can decrease co-op multiplayer playability
• May require spending too much time on inventing a sophisticated
level generator
13 / 90
Challenges of PCG
14 / 90
Generation Mistakes in Infinite Mario
(Picture by Mawhoter, Mateas)
“Random” Numbers
• Computers are deterministic – thus, producing “random” numbers
seems to be conceptually impossible.
• Pseudo-random numbers in computers are generated by applying a
fixed rule to a given number, generating the next number in the
sequence.
• The first number of the sequence is often called the seed of the
random number generator.
• The length of the sequence before repeating numbers is called its
period.
15 / 90
“Good” “Random” Numbers
“What is random enough for one application may not be random
enough for another.”
For games:
• Don’t use generators with a period less than 264!
• Don’t use built-in language generators!
• Don’t use overengineered generators!
16 / 90
A Good Pseudo-Random Number Generator
• Should combine at least two unrelated generation methods, in order
to mitigate the flaws of each.
• Should be an object instead of a static class, as it maintains an
internal state (the current number in the sequence).
17 / 90
64-bit XOR Shift Method
Max. Period: 264 – 1
Operations: 3x XOR, 3x shift
Algorithm:
1. x = x ^ (x >> A1)
2. x = x ^ (x << A2)
3. x = x ^ (x >> A3)
with A1 = 21, A2 = 35, A3 = 4 as full-period triple.
18 / 90
MLCG Module 264
Max. Period: 262 (suffers from serial correlation)
Operations: 1x multiplication, 1x modulo
Algorithm:
x = (x * A) mod 264
with A = 2685821657736338717 as recommended multiplier.
19 / 90
Combined Generator
Period: 1.8 x 1019
Algorithm:
1. x = x ^ (x >> 21)
2. x = x ^ (x << 35)
3. x = x ^ (x >> 4)
4. x = (x * 2685821657736338717 ) mod 264
20 / 90
Level Generation Algorithms
• Context-free grammars
• Reinforcement learning
• Genetic algorithms
• Chunk-based approach
21 / 90
Context-Free Grammar
• Approach for generating levels for platform games
• Originally presented by Ince in 1999
▪ Later improved on by Compton and Mateas in 2006
• Generation model is represented as a context-free grammar
▪ Level as start symbol
▪ Most basic units out of which the levels are constructed as
terminal symbols
▪ Sequences of these units as nonterminal symbols
▪ Connections between these sequences as productions
22 / 90
Reinforcement Learning
• Context-free grammar approach requires programmers to find the
generational rules, which can be extremely difficult
• In 2009, Laskov interpreted level generation as a maintenance task
▪ Level building agent performs certain actions
▪ Goal is to generate a level that satisfies user-specified
parameters at all times
▪ Enforced by a reward function
o Punishes fail-states like unplayable levels
o Rewards branches and game elements like enemies or treasures
23 / 90
Genetic Algorithms
• Sorenson and Pasquier were among the first to propose an algorithm
that is able to generate platform game levels and 2D adventure game
levels alike
• Feasible-infeasible two-population algorithm
▪ Considers levels which do not yet satisfy all given constraints as
infeasible population
o Evolved towards minimising the number of violated constraints
▪ Considers all others as feasible population
o Subject to a fitness function that rewards levels based on the criteria
specified by the level designers
• Generating Roguelike levels on an average machine took “less than an
hour”...
24 / 90
Chunk-based Approach
• Used in Infinite Mario Bros and Torchlight
• Creates a game level by assembling pre-authored level chunks
• Requires applying some post-processing algorithms afterwards
25 / 90
Chunk-based Approach
• Very intuitive for designers
• Applicable for both 2D and 3D
• Easy to increase the variety of different levels just by extending the
chunk library
26 / 90
Definition (Game Element)
27 / 90
A game element is any domain-specific game object a player can
interact with (i.e. enemies, items, levers).
Definition (Chunk)
28 / 90
A chunk is the most basic building block of a level. It contains
information about its extents, its position and rotation as well as about
where to align it to the existing level and where to add game elements.
Definition (Chunk Library)
29 / 90
A chunk library holds a set of chunk templates and is needed by the
level generator to have a specific repertoire of chunks that may be used
during the generation process.
Definition (Context)
30 / 90
Every chunk contains at least one single context describing the relative
position at which it may be aligned to other chunks.
Definition (Anchor)
31 / 90
Every chunk may contain one or more tagged anchors describing the
relative position at which game elements can be added.
Definition (Level)
32 / 90
A level is a bounded space containing a limited number of level chunks.
33 / 90
Definition (Level)
Procedurally Generated Game Level
34 / 90
Level Generation Framework
UML Class Diagram of the ByChance Framework
35 / 90
Main Routine
Precondition: C is a non-empty chunk library. L is a bounded level
which contains chunks of C, only, and none of these chunks overlap or
exceed the level bounds.
36 / 90
Main Routine
1. While L contains at least one non-blocked context:
1. Select a non-blocked context for expanding L.
2. Find all compatible chunk candidates as follows: For each chunk in C, and
for each of its contexts:
1. If contexts are compatible and new chunk wouldn't overlap or exceed the level
bounds, add to list of candidates.
2. Else if the chunk is allowed to be rotated and hasn't already been rotated by 360
degrees in every direction, rotate it and try again.
3. Else, reject the chunk.
3. If candidate list is empty, block selected context and continue.
4. Else, select a compatible chunk from candidate list and add it to L, aligning
the selected contexts.
2. Perform post-processing.
37 / 90
Main Routine
Postcondition: All contexts of L are blocked. No chunk exceeds the
level bounds, and no two different level chunks overlap.
38 / 90
Chunk Selection
• Three attributes influence the probability of picking a particular
chunk:
▪ Weight
▪ Quantity
▪ Tags
• Tuning these three attributes is key to producing enjoyable levels.
39 / 90
Post-Processing
Cluster of floors.
Cluster of rooms.
40 / 90
Post-Processing
Dead ends.
41 / 90
Post-Processing
Connected contexts.
42 / 90
3D Chunks
43 / 90
3D Chunks
44 / 90
Level Layouts
Special level layouts.
(Picture by Compton, Mateas)
45 / 90
Editor Support
ByChance Chunk Template Editor in Unity
46 / 90
Editor Support
ByChance Scene View in Unity
47 / 90
Editor Support
ByChance Game View in Unity
Perlin Noise
• Originally created by Ken Perlin in 1983
• Mapping from ℝn to [-1; 1]
• Can be used to assign a greyscale value to each pixel of a bitmap
• Bitmap can be used as heightmap for 3D terrain
48 / 90
Perlin Noise
• Perlin Noise is coherent
▪ For any two points A, B, the value of the noise function changes
smoothly as you move from A to B.
49 / 90
Non-coherent noise (left) vs. coherent noise (right)
(Picture by Matt Zucker)
Creating Perlin Noise
• Well-known approach is creating non-coherent noise and smooth
(blur) it
• Original approach by Perlin is different, mathematically well-defined
and more efficient
50 / 90
Creating Perlin Noise
Wanted:
noise: ℝn [-1; 1]
51 / 90
Creating Perlin Noise
Wanted:
noise: ℝ2 [-1; 1]
52 / 90
Creating Perlin Noise
On a bounded space of size Size x Size,
Size > 0
impose a grid of size GridSize x GridSize,
Size >= GridSize > 0
53 / 90
Creating Perlin Noise
• Grid points are defined for each whole number.
• Any number with a fractional part (i.e. 3.14) lies between grid points.
54 / 90
Picture by Matt Zucker.
Creating Perlin Noise
Step 0: Assign a pseudorandom gradient of length 1 to each grid point.
55 / 90
Picture by Matt Zucker.
Creating Perlin Noise
Note: The gradient of each grid point must not change after it has been
computed once (e.g. don’t compute random gradients every time
computing noise(x,y)).
56 / 90
Picture by Matt Zucker.
Creating Perlin Noise
Step 1: Find the grid points surrounding (x, y). In ℝ2, we have 4 of
them, which we will call (x0,y0), (x0, y1), (x1, y0), and (x1, y1).
57 / 90
Picture by Matt Zucker.
Creating Perlin Noise
Step 2: Find the vectors going from each grid point to (x, y).
58 / 90
Picture by Matt Zucker.
Creating Perlin Noise
Step 3: Compute the influence of each gradient by performing a dot
product of the gradient and the vector going from its associated grid
point to (x, y).
59 / 90
s = g(x0, y0) · ((x, y) -
(x0, y0))
t = g(x1, y0) · ((x, y) - (x1, y0))
u = g(x0, y1) · ((x, y) - (x0, y1))
v = g(x1, y1) · ((x, y) - (x1, y1))
Creating Perlin Noise
Step 4: Ease the position of the point, exaggerating its proximity to
zero or one.
For inputs that are sort of close to zero, output a number really close to
zero. For inputs close to one, output a number really close to one.
60 / 90
f(p) = 3p2 – 2p3
(Picture by Matt Zucker)
Creating Perlin Noise
Step 4: Ease the position of the point, exaggerating its proximity to
zero or one.
For inputs that are sort of close to zero, output a number really close to
zero. For inputs close to one, output a number really close to one.
61 / 90
Sx = 3(x - x0)² - 2(x - x0)³
Sy = 3(y - y0)² - 2(y - y0)³
Creating Perlin Noise
Step 5: Linearly interpolate between the influences of the gradients.
62 / 90
a = s + Sx(t - s)
b = u + Sx(v - u)
noise(x, y) = a + Sy(b - a)
Creating Perlin Noise
In order to use noise as greyscale value, you might want to transform it
to a more useful interval.
Full source code is available at https://github.com/npruehs/perlin-noise.
63 / 90
noise(x, y) = a + Sy(b - a)
[-1; 1]
transformedNoise(x, y) = (noise(x, y) + 1) / 2 [0; 1]
greyscale(x, y) = transformedNoise(x, y) * 255 [0; 255]
Markov Chains
• Named after Andrey Markov
• State space with random transitions
• Usually memory-less
▪ Next state only depends on current state
▪ Thus the name
• Usually doesn’t terminate
▪ There is always a next state
• Generally impossible to predict the state at a given point in the future
▪ Statistical properties can be predicted (and are more interesting in
most cases)
64 / 90
Markov Chains
• Example: Drunkard’s Walk
▪ One-dimensional state space
▪ Position may change by +1 or -1 with equal probability
▪ Two possible transitions from each state
▪ Transition probability only depends on the current state
65 / 90
Markov Chains
• Example: Drunkard’s Walk
▪ One-dimensional state space
▪ Position may change by +1 or -1 with equal probability
▪ Two possible transitions from each state
▪ Transition probability only depends on the current state
66 / 90
Markov Chains
• Example: Creature Diet
▪ Creature eats only grapes, cheese, or lettuce
▪ Eats exactly once a day
▪ If it ate cheese today, tomorrow it will eat lettuce or grapes with
equal probability.
▪ If it ate grapes today, tomorrow it will eat grapes with probability
1/10, cheese with probability 4/10 and lettuce with probability
5/10.
▪ If it ate lettuce today, tomorrow it will eat grapes with probability
4/10 or cheese with probability 6/10.
67 / 90
Markov Chains
• Example: Creature Diet
▪ Can be modeled with a Markov chain since its choice tomorrow
depends solely on what it ate today
o not what it ate yesterday
o not what it ate any other time in the past
▪ Statistical property that could be calculated is the expected
percentage, over a long period, of the days on which the
creature will eat grapes
68 / 90
Markov Chain – Definition
A Markov chain is a sequence of random variables X1, X2, X3, ... with
the Markov property, namely that, given the present state, the future
and past states are independent:
Pr 𝑋1 = 𝑥1, … , 𝑋 𝑛 = 𝑥 𝑛 > 0 ⇒
Pr 𝑋 𝑛+1 = 𝑥 𝑋1= 𝑥1, 𝑋2 = 𝑥2, … . , 𝑋 𝑛 = 𝑥 𝑛 = Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑥 𝑛)
69 / 90
Markov Chains – Description
• Directed graph
▪ Edges are labeled by the probabilities of going from one state at
time n to the other states at time n+1
• Transition matrix
70 / 90
Stationary Markov Chains
Stationary Markov chains are processes where the probability of a
transition is independent of n.
∀𝑛 ∈ 𝑁:
Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑦) = Pr(𝑋 𝑛 = 𝑥 | 𝑋 𝑛−1 = 𝑦)
71 / 90
Higher Order Markov Chains
A Markov chain of order 𝑚 ∈ 𝑁 is a process where the future state
depends on the past m states.
∀𝑛 ∈ 𝑁, 𝑛 > 𝑚:
Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑥 𝑛, 𝑋 𝑛−1 = 𝑥 𝑛−1, … , 𝑋1 = 𝑥1) =
Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑥 𝑛, 𝑋 𝑛−1 = 𝑥 𝑛−1, … , 𝑋 𝑛−𝑚 = 𝑥 𝑛−𝑚)
72 / 90
73 / 90
Random Name Generation
Given an input set of feasible existing names, a new random name can be
generated using an m-order Markov chain as follows:
1. Pick any existing name, with equal probability.
2. Take the first m letters of that name.
3. Find all existing names containing these m letters.
4. In all of these existing names, check the following letter. (Consider end-of-word
as letter here.) Count the occurrences of the same following letters.
5. Pick the next letter of the generated name with probability of the distribution in
existing names.
6. If the next letter is not end-of-word, start over from step 3, always considering
the last m letters of the current name.
74 / 90
Random Name Generation
Example (m = 2)
1. Pick any existing name, with equal probability.
LILY
75 / 90
Random Name Generation
Example (m = 2, name = “LI”, current = “LI”)
2. Take the first m letters of that name.
LI
76 / 90
Random Name Generation
Example (m = 2, name = “LI”, current = “LI”)
3. Find all existing names containing these m letters.
AMELIA, OLIVIA, LILY, ALICE, ELISABETH, LILAH, JULIET,
CAROLINE, EVANGELINE, MADELINE, NATELIE, ROSALIE, LILLIAN,
ELISE, ADELINE, DELILAH, ELIANA, FELICITY, JULIA
77 / 90
Random Name Generation
Example (m = 2, name = “LI”, current = “LI”)
4. In all of these existing names, check the following letter. (Consider
end-of-word as letter here.) Count the occurrences of the same
following letters.
78 / 90
Next Letter Occurrences Probability
A 3 16 %
V 1 5 %
L 4 21 %
C 2 11 %
S 2 11 %
E 3 16 %
N 4 21 %
Random Name Generation
Example (m = 2, name = “LIN”, current = “LI”)
5. Pick the next letter of the generated name with probability of the
distribution in existing names.
79 / 90
Next Letter Occurrences Probability
A 3 16 %
V 1 5 %
L 4 21 %
C 2 11 %
S 2 11 %
E 3 16 %
N 4 21 %
Random Name Generation
Example (m = 2, name = “LIN”, current = “IN”)
2. Take the last m letters of the generated name.
IN
80 / 90
Random Name Generation
Example (m = 2, name = “LIN”, current = “IN”)
3. Find all existing names containing these m letters.
CAROLINE, EVANGELINE, MADELINE, JOSEPHINE, ADELINE,
QUINN
81 / 90
Random Name Generation
Example (m = 2, name = “LIN”, current = “IN”)
4. In all of these existing names, check the following letter. (Consider
end-of-word as letter here.) Count the occurrences of the same
following letters.
82 / 90
Next Letter Occurrences Probability
E 5 83 %
N 1 17 %
Random Name Generation
Example (m = 2, name = “LINN”, current = “IN”)
5. Pick the next letter of the generated name with probability of the
distribution in existing names.
83 / 90
Next Letter Occurrences Probability
E 5 83 %
N 1 17 %
Random Name Generation
Example (m = 2, name = “LINN”, current = “NN”)
2. Take the last m letters of the generated name.
NN
84 / 90
Random Name Generation
Example (m = 2, name = “LINN”, current = “NN”)
3. Find all existing names containing these m letters.
ARIANNA, HANNAH, ANNA, SAVANNAH, ANNABELLE, QUINN,
SIENNA
85 / 90
Random Name Generation
Example (m = 2, name = “LINN”, current = “NN”)
4. In all of these existing names, check the following letter. (Consider
end-of-word as letter here.) Count the occurrences of the same
following letters.
86 / 90
Next Letter Occurrences Probability
A 6 86 %
End-of-word 1 14 %
Random Name Generation
Example (m = 2, name = “LINN”, current = “NN”)
5. Pick the next letter of the generated name with probability of the
distribution in existing names.
87 / 90
Next Letter Occurrences Probability
A 6 86 %
End-of-word 1 14 %
Random Name Generation
Example (m = 2)
Generated Name:
LINN
88 / 90
References
• Togelius, Yannakakis, Stanley, Browne. Search-based procedural content generation. In
EvoApplications Workshop, volume 2024 of LNCS, pages 141150, November 2010.
• Andrew Doull. The death of the level designer: Procedural content generation in games.
http://roguelikedeveloper.blogspot.de/2008/01/death-of-level-designer-procedural.html, January
2008.
• Peter Mawhorter and Michael Mateas. Procedural level generation using occupancy-regulated
extension. In CIG, pages 351358, 2010.
• Press, Teukolsky, Vetterling, Flannery. Numerical Recipes 3rd Edition: The Art of Scientic
Computing. Cambridge University Press, New York, NY, USA, 2007.
• Ince. Automatic Dynamic Content Generation for Computer Games. PhD thesis, University of
Sheeld, 1999.
• Compton, Mateas. Procedural level design for platform games. In Proceedings of the 2nd Articial
Intelligence and Interactive Digital Entertainment Conference (AIIDE), pages 109111, Marina del
Rey, California, June 2006.
References
• Laskov. Level generation system for platform games based on a reinforcement learning approach.
Master's thesis, The University of Edinburgh, School of Informatics, 2009.
• Sorenson, Pasquier. Towards a generic framework for automated video game level creation. In
EvoApplications (1), pages 131140, 2010.
• Prühs, Vaz Alves. Towards a Generic Framework for Procedural Generation of Game Levels.
Master’s Thesis, Hamburg University of Applied Sciences, 2011.
• Perlin. Noise and Turbulence. http://www.mrl.nyu.edu/~perlin/doc/oscar.html, 1997.
• Perlin. Making Noise. http://www.noisemachine.com/talk1/index.html, December 9, 1999.
• Zucker. The Perlin noise math FAQ. http://webstaff.itn.liu.se/~stegu/TNM022-
2005/perlinnoiselinks/perlin-noise-math-faq.html#toc-algorithm, February 2001.
• Wikipedia. Markow chain. http://en.wikipedia.org/wiki/Markov_chain, September 6, 2014.
• Silicon Commader Games. Markow Name Generator.
http://www.siliconcommandergames.com/MarkovNameGenerator.htm, May 2016.
Thank you!
http://www.npruehs.de
https://github.com/npruehs
@npruehs
nick.pruehs@daedalic.com
5 Minute Review Session
• Which categories of procedural content generation do you know?
• Name a few opportunities of PCG!
• Name a few challenges of using generated content!
• In a few words, explain the chunk-based level generation approach!
• What is coherent noise, and what can it be used for?
• What are Markov chains, and what can they be used for?

Contenu connexe

Tendances

Cerny method
Cerny methodCerny method
Cerny method
Tim Holt
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
pjcozzi
 

Tendances (20)

Procedural Content Generation
Procedural Content GenerationProcedural Content Generation
Procedural Content Generation
 
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnPutting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game Framework
 
멀티스레드 렌더링 (Multithreaded rendering)
멀티스레드 렌더링 (Multithreaded rendering)멀티스레드 렌더링 (Multithreaded rendering)
멀티스레드 렌더링 (Multithreaded rendering)
 
게임제작개론 : #5 플레이어에 대한 이해
게임제작개론 : #5 플레이어에 대한 이해게임제작개론 : #5 플레이어에 대한 이해
게임제작개론 : #5 플레이어에 대한 이해
 
Cerny method
Cerny methodCerny method
Cerny method
 
Modular Level Design for Skyrim
Modular Level Design for SkyrimModular Level Design for Skyrim
Modular Level Design for Skyrim
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Level Design
Level DesignLevel Design
Level Design
 
GTC 2014 - DirectX 11 Rendering and NVIDIA GameWorks in Batman: Arkham Origins
GTC 2014 - DirectX 11 Rendering and NVIDIA GameWorks in Batman: Arkham OriginsGTC 2014 - DirectX 11 Rendering and NVIDIA GameWorks in Batman: Arkham Origins
GTC 2014 - DirectX 11 Rendering and NVIDIA GameWorks in Batman: Arkham Origins
 
진화하는 컴퓨터 하드웨어와 게임 개발 기술의 발전
진화하는 컴퓨터 하드웨어와 게임 개발 기술의 발전진화하는 컴퓨터 하드웨어와 게임 개발 기술의 발전
진화하는 컴퓨터 하드웨어와 게임 개발 기술의 발전
 
GDC 2017: Evaluating Monetization Early
GDC 2017: Evaluating Monetization EarlyGDC 2017: Evaluating Monetization Early
GDC 2017: Evaluating Monetization Early
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
 
Frostbite on Mobile
Frostbite on MobileFrostbite on Mobile
Frostbite on Mobile
 
TA가 뭐예요? (What is a Technical Artist? 블루홀스튜디오)
TA가 뭐예요? (What is a Technical Artist? 블루홀스튜디오)TA가 뭐예요? (What is a Technical Artist? 블루홀스튜디오)
TA가 뭐예요? (What is a Technical Artist? 블루홀스튜디오)
 
Dissecting the Rendering of The Surge
Dissecting the Rendering of The SurgeDissecting the Rendering of The Surge
Dissecting the Rendering of The Surge
 
2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)
 

En vedette

En vedette (20)

Game Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesGame Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design Principles
 
Game Programming 03 - Git Flow
Game Programming 03 - Git FlowGame Programming 03 - Git Flow
Game Programming 03 - Git Flow
 
Game Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsGame Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity Systems
 
Game Programming 05 - Development Tools
Game Programming 05 - Development ToolsGame Programming 05 - Development Tools
Game Programming 05 - Development Tools
 
Game Programming 06 - Automated Testing
Game Programming 06 - Automated TestingGame Programming 06 - Automated Testing
Game Programming 06 - Automated Testing
 
Game Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentGame Programming 08 - Tool Development
Game Programming 08 - Tool Development
 
Game Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationGame Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance Optimization
 
Game Programming 10 - Localization
Game Programming 10 - LocalizationGame Programming 10 - Localization
Game Programming 10 - Localization
 
What Would Blizzard Do
What Would Blizzard DoWhat Would Blizzard Do
What Would Blizzard Do
 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine Basics
 
Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - Git
 
Game Programming 09 - AI
Game Programming 09 - AIGame Programming 09 - AI
Game Programming 09 - AI
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
 
Game Programming 11 - Game Physics
Game Programming 11 - Game PhysicsGame Programming 11 - Game Physics
Game Programming 11 - Game Physics
 
Game Development Challenges
Game Development ChallengesGame Development Challenges
Game Development Challenges
 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great Game
 
Scrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsScrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small Teams
 
Game Models - A Different Approach
Game Models - A Different ApproachGame Models - A Different Approach
Game Models - A Different Approach
 
Style & Design Principles 03 - Component-Based Entity Systems
Style & Design Principles 03 - Component-Based Entity SystemsStyle & Design Principles 03 - Component-Based Entity Systems
Style & Design Principles 03 - Component-Based Entity Systems
 
Designing an actor model game architecture with Pony
Designing an actor model game architecture with PonyDesigning an actor model game architecture with Pony
Designing an actor model game architecture with Pony
 

Similaire à Game Programming 07 - Procedural Content Generation

Separating Hype from Reality in Deep Learning with Sameer Farooqui
 Separating Hype from Reality in Deep Learning with Sameer Farooqui Separating Hype from Reality in Deep Learning with Sameer Farooqui
Separating Hype from Reality in Deep Learning with Sameer Farooqui
Databricks
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
slantsixgames
 

Similaire à Game Programming 07 - Procedural Content Generation (20)

「原神」におけるコンソールプラットフォーム開発
「原神」におけるコンソールプラットフォーム開発「原神」におけるコンソールプラットフォーム開発
「原神」におけるコンソールプラットフォーム開発
 
Adding more visuals without affecting performance
Adding more visuals without affecting performanceAdding more visuals without affecting performance
Adding more visuals without affecting performance
 
Software Engineer- A unity 3d Game
Software Engineer- A unity 3d GameSoftware Engineer- A unity 3d Game
Software Engineer- A unity 3d Game
 
World of Tanks* 1.0+: Enriching Gamers Experience with Multicore Optimized Ph...
World of Tanks* 1.0+: Enriching Gamers Experience with Multicore Optimized Ph...World of Tanks* 1.0+: Enriching Gamers Experience with Multicore Optimized Ph...
World of Tanks* 1.0+: Enriching Gamers Experience with Multicore Optimized Ph...
 
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
 
Ndss 2016 game_bot_final_no_video
Ndss 2016 game_bot_final_no_videoNdss 2016 game_bot_final_no_video
Ndss 2016 game_bot_final_no_video
 
Understanding and improving games through machine learning - Natasha Latysheva
Understanding and improving games through machine learning - Natasha LatyshevaUnderstanding and improving games through machine learning - Natasha Latysheva
Understanding and improving games through machine learning - Natasha Latysheva
 
De Re PlayStation Vita
De Re PlayStation VitaDe Re PlayStation Vita
De Re PlayStation Vita
 
Pong
PongPong
Pong
 
Soc research
Soc researchSoc research
Soc research
 
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
 
Proj1
Proj1Proj1
Proj1
 
Proj1
Proj1Proj1
Proj1
 
Separating Hype from Reality in Deep Learning with Sameer Farooqui
 Separating Hype from Reality in Deep Learning with Sameer Farooqui Separating Hype from Reality in Deep Learning with Sameer Farooqui
Separating Hype from Reality in Deep Learning with Sameer Farooqui
 
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech UpdateAdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
 
Game Development Step by Step
Game Development Step by StepGame Development Step by Step
Game Development Step by Step
 
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON China
 

Plus de Nick Pruehs

Plus de Nick Pruehs (10)

Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
 
Unreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesUnreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior Trees
 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - Gameplay
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
 
Game Programming - Cloud Development
Game Programming - Cloud DevelopmentGame Programming - Cloud Development
Game Programming - Cloud Development
 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - Git
 
Game Programming 01 - Introduction
Game Programming 01 - IntroductionGame Programming 01 - Introduction
Game Programming 01 - Introduction
 
Game Programming 00 - Exams
Game Programming 00 - ExamsGame Programming 00 - Exams
Game Programming 00 - Exams
 
Tool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsTool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool Chains
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Game Programming 07 - Procedural Content Generation

  • 1. Game Programming Procedural Content Generation Nick Prühs, Denis Vaz Alves
  • 2. Objectives • To get an overview of the different fields of procedural content generation • To learn how to procedurally generate content of different types • To understand game design implications of using generated content in games 2 / 90
  • 3. Procedural Content Generation “Procedural content generation (PCG) refers to creating game content automatically, through algorithmic means.” - Togelius, Yannakakis, Stanley, Browne “PCG should ensure that from a few parameters, a large number of possible types of content can be generated.” - Doull 3 / 90
  • 4. Categories of PCG • Online Level Generation • Offline Level Generation • Fixed Seed Level Generation • Game Entity Instancing • User-mediated Content • Dynamic Systems • Procedural Puzzles & Plot Generation 4 / 90
  • 5. Categories of PCG 5 / 90 Online Level Generation in Diablo 2
  • 6. Categories of PCG 6 / 90 Fixed Seed Level Generation in Elite
  • 7. Categories of PCG 7 / 90 Game Entity Instancing in Spore
  • 8. Categories of PCG 8 / 90 Dynamic Systems in Left 4 Dead
  • 9. Opportunities of PCG • high diversity of the resulting assets • faster than any human designer could ever be • significantly reduces production costs • allows for a mixed-initiative approach to level design • content automatically implemented in the engine • can save vital system resources • players can influence the parameters of the game world • possibility of automatically analyzing player behavior 9 / 90
  • 10. Opportunities of PCG 10 / 90 Procedurally Generated Item in Diablo 2
  • 11. Opportunities of PCG 11 / 90 Map Editor of Age of Empires 2
  • 12. Opportunities of PCG 12 / 90 Game Parameters of Master of Orion 2
  • 13. Challenges of PCG • Satisfying a high number of constraints (e.g. full connectivity) ▪ Finding these constraints and tweaking unintuitive parameters of the system can degenerate into trial and error • Produce aesthetically pleasing results ▪ Levels can become too similar to each other • Maximize the expressive range (variety of results) ▪ Can decrease co-op multiplayer playability • May require spending too much time on inventing a sophisticated level generator 13 / 90
  • 14. Challenges of PCG 14 / 90 Generation Mistakes in Infinite Mario (Picture by Mawhoter, Mateas)
  • 15. “Random” Numbers • Computers are deterministic – thus, producing “random” numbers seems to be conceptually impossible. • Pseudo-random numbers in computers are generated by applying a fixed rule to a given number, generating the next number in the sequence. • The first number of the sequence is often called the seed of the random number generator. • The length of the sequence before repeating numbers is called its period. 15 / 90
  • 16. “Good” “Random” Numbers “What is random enough for one application may not be random enough for another.” For games: • Don’t use generators with a period less than 264! • Don’t use built-in language generators! • Don’t use overengineered generators! 16 / 90
  • 17. A Good Pseudo-Random Number Generator • Should combine at least two unrelated generation methods, in order to mitigate the flaws of each. • Should be an object instead of a static class, as it maintains an internal state (the current number in the sequence). 17 / 90
  • 18. 64-bit XOR Shift Method Max. Period: 264 – 1 Operations: 3x XOR, 3x shift Algorithm: 1. x = x ^ (x >> A1) 2. x = x ^ (x << A2) 3. x = x ^ (x >> A3) with A1 = 21, A2 = 35, A3 = 4 as full-period triple. 18 / 90
  • 19. MLCG Module 264 Max. Period: 262 (suffers from serial correlation) Operations: 1x multiplication, 1x modulo Algorithm: x = (x * A) mod 264 with A = 2685821657736338717 as recommended multiplier. 19 / 90
  • 20. Combined Generator Period: 1.8 x 1019 Algorithm: 1. x = x ^ (x >> 21) 2. x = x ^ (x << 35) 3. x = x ^ (x >> 4) 4. x = (x * 2685821657736338717 ) mod 264 20 / 90
  • 21. Level Generation Algorithms • Context-free grammars • Reinforcement learning • Genetic algorithms • Chunk-based approach 21 / 90
  • 22. Context-Free Grammar • Approach for generating levels for platform games • Originally presented by Ince in 1999 ▪ Later improved on by Compton and Mateas in 2006 • Generation model is represented as a context-free grammar ▪ Level as start symbol ▪ Most basic units out of which the levels are constructed as terminal symbols ▪ Sequences of these units as nonterminal symbols ▪ Connections between these sequences as productions 22 / 90
  • 23. Reinforcement Learning • Context-free grammar approach requires programmers to find the generational rules, which can be extremely difficult • In 2009, Laskov interpreted level generation as a maintenance task ▪ Level building agent performs certain actions ▪ Goal is to generate a level that satisfies user-specified parameters at all times ▪ Enforced by a reward function o Punishes fail-states like unplayable levels o Rewards branches and game elements like enemies or treasures 23 / 90
  • 24. Genetic Algorithms • Sorenson and Pasquier were among the first to propose an algorithm that is able to generate platform game levels and 2D adventure game levels alike • Feasible-infeasible two-population algorithm ▪ Considers levels which do not yet satisfy all given constraints as infeasible population o Evolved towards minimising the number of violated constraints ▪ Considers all others as feasible population o Subject to a fitness function that rewards levels based on the criteria specified by the level designers • Generating Roguelike levels on an average machine took “less than an hour”... 24 / 90
  • 25. Chunk-based Approach • Used in Infinite Mario Bros and Torchlight • Creates a game level by assembling pre-authored level chunks • Requires applying some post-processing algorithms afterwards 25 / 90
  • 26. Chunk-based Approach • Very intuitive for designers • Applicable for both 2D and 3D • Easy to increase the variety of different levels just by extending the chunk library 26 / 90
  • 27. Definition (Game Element) 27 / 90 A game element is any domain-specific game object a player can interact with (i.e. enemies, items, levers).
  • 28. Definition (Chunk) 28 / 90 A chunk is the most basic building block of a level. It contains information about its extents, its position and rotation as well as about where to align it to the existing level and where to add game elements.
  • 29. Definition (Chunk Library) 29 / 90 A chunk library holds a set of chunk templates and is needed by the level generator to have a specific repertoire of chunks that may be used during the generation process.
  • 30. Definition (Context) 30 / 90 Every chunk contains at least one single context describing the relative position at which it may be aligned to other chunks.
  • 31. Definition (Anchor) 31 / 90 Every chunk may contain one or more tagged anchors describing the relative position at which game elements can be added.
  • 32. Definition (Level) 32 / 90 A level is a bounded space containing a limited number of level chunks.
  • 33. 33 / 90 Definition (Level) Procedurally Generated Game Level
  • 34. 34 / 90 Level Generation Framework UML Class Diagram of the ByChance Framework
  • 35. 35 / 90 Main Routine Precondition: C is a non-empty chunk library. L is a bounded level which contains chunks of C, only, and none of these chunks overlap or exceed the level bounds.
  • 36. 36 / 90 Main Routine 1. While L contains at least one non-blocked context: 1. Select a non-blocked context for expanding L. 2. Find all compatible chunk candidates as follows: For each chunk in C, and for each of its contexts: 1. If contexts are compatible and new chunk wouldn't overlap or exceed the level bounds, add to list of candidates. 2. Else if the chunk is allowed to be rotated and hasn't already been rotated by 360 degrees in every direction, rotate it and try again. 3. Else, reject the chunk. 3. If candidate list is empty, block selected context and continue. 4. Else, select a compatible chunk from candidate list and add it to L, aligning the selected contexts. 2. Perform post-processing.
  • 37. 37 / 90 Main Routine Postcondition: All contexts of L are blocked. No chunk exceeds the level bounds, and no two different level chunks overlap.
  • 38. 38 / 90 Chunk Selection • Three attributes influence the probability of picking a particular chunk: ▪ Weight ▪ Quantity ▪ Tags • Tuning these three attributes is key to producing enjoyable levels.
  • 39. 39 / 90 Post-Processing Cluster of floors. Cluster of rooms.
  • 42. 42 / 90 3D Chunks
  • 43. 43 / 90 3D Chunks
  • 44. 44 / 90 Level Layouts Special level layouts. (Picture by Compton, Mateas)
  • 45. 45 / 90 Editor Support ByChance Chunk Template Editor in Unity
  • 46. 46 / 90 Editor Support ByChance Scene View in Unity
  • 47. 47 / 90 Editor Support ByChance Game View in Unity
  • 48. Perlin Noise • Originally created by Ken Perlin in 1983 • Mapping from ℝn to [-1; 1] • Can be used to assign a greyscale value to each pixel of a bitmap • Bitmap can be used as heightmap for 3D terrain 48 / 90
  • 49. Perlin Noise • Perlin Noise is coherent ▪ For any two points A, B, the value of the noise function changes smoothly as you move from A to B. 49 / 90 Non-coherent noise (left) vs. coherent noise (right) (Picture by Matt Zucker)
  • 50. Creating Perlin Noise • Well-known approach is creating non-coherent noise and smooth (blur) it • Original approach by Perlin is different, mathematically well-defined and more efficient 50 / 90
  • 51. Creating Perlin Noise Wanted: noise: ℝn [-1; 1] 51 / 90
  • 52. Creating Perlin Noise Wanted: noise: ℝ2 [-1; 1] 52 / 90
  • 53. Creating Perlin Noise On a bounded space of size Size x Size, Size > 0 impose a grid of size GridSize x GridSize, Size >= GridSize > 0 53 / 90
  • 54. Creating Perlin Noise • Grid points are defined for each whole number. • Any number with a fractional part (i.e. 3.14) lies between grid points. 54 / 90 Picture by Matt Zucker.
  • 55. Creating Perlin Noise Step 0: Assign a pseudorandom gradient of length 1 to each grid point. 55 / 90 Picture by Matt Zucker.
  • 56. Creating Perlin Noise Note: The gradient of each grid point must not change after it has been computed once (e.g. don’t compute random gradients every time computing noise(x,y)). 56 / 90 Picture by Matt Zucker.
  • 57. Creating Perlin Noise Step 1: Find the grid points surrounding (x, y). In ℝ2, we have 4 of them, which we will call (x0,y0), (x0, y1), (x1, y0), and (x1, y1). 57 / 90 Picture by Matt Zucker.
  • 58. Creating Perlin Noise Step 2: Find the vectors going from each grid point to (x, y). 58 / 90 Picture by Matt Zucker.
  • 59. Creating Perlin Noise Step 3: Compute the influence of each gradient by performing a dot product of the gradient and the vector going from its associated grid point to (x, y). 59 / 90 s = g(x0, y0) · ((x, y) - (x0, y0)) t = g(x1, y0) · ((x, y) - (x1, y0)) u = g(x0, y1) · ((x, y) - (x0, y1)) v = g(x1, y1) · ((x, y) - (x1, y1))
  • 60. Creating Perlin Noise Step 4: Ease the position of the point, exaggerating its proximity to zero or one. For inputs that are sort of close to zero, output a number really close to zero. For inputs close to one, output a number really close to one. 60 / 90 f(p) = 3p2 – 2p3 (Picture by Matt Zucker)
  • 61. Creating Perlin Noise Step 4: Ease the position of the point, exaggerating its proximity to zero or one. For inputs that are sort of close to zero, output a number really close to zero. For inputs close to one, output a number really close to one. 61 / 90 Sx = 3(x - x0)² - 2(x - x0)³ Sy = 3(y - y0)² - 2(y - y0)³
  • 62. Creating Perlin Noise Step 5: Linearly interpolate between the influences of the gradients. 62 / 90 a = s + Sx(t - s) b = u + Sx(v - u) noise(x, y) = a + Sy(b - a)
  • 63. Creating Perlin Noise In order to use noise as greyscale value, you might want to transform it to a more useful interval. Full source code is available at https://github.com/npruehs/perlin-noise. 63 / 90 noise(x, y) = a + Sy(b - a) [-1; 1] transformedNoise(x, y) = (noise(x, y) + 1) / 2 [0; 1] greyscale(x, y) = transformedNoise(x, y) * 255 [0; 255]
  • 64. Markov Chains • Named after Andrey Markov • State space with random transitions • Usually memory-less ▪ Next state only depends on current state ▪ Thus the name • Usually doesn’t terminate ▪ There is always a next state • Generally impossible to predict the state at a given point in the future ▪ Statistical properties can be predicted (and are more interesting in most cases) 64 / 90
  • 65. Markov Chains • Example: Drunkard’s Walk ▪ One-dimensional state space ▪ Position may change by +1 or -1 with equal probability ▪ Two possible transitions from each state ▪ Transition probability only depends on the current state 65 / 90
  • 66. Markov Chains • Example: Drunkard’s Walk ▪ One-dimensional state space ▪ Position may change by +1 or -1 with equal probability ▪ Two possible transitions from each state ▪ Transition probability only depends on the current state 66 / 90
  • 67. Markov Chains • Example: Creature Diet ▪ Creature eats only grapes, cheese, or lettuce ▪ Eats exactly once a day ▪ If it ate cheese today, tomorrow it will eat lettuce or grapes with equal probability. ▪ If it ate grapes today, tomorrow it will eat grapes with probability 1/10, cheese with probability 4/10 and lettuce with probability 5/10. ▪ If it ate lettuce today, tomorrow it will eat grapes with probability 4/10 or cheese with probability 6/10. 67 / 90
  • 68. Markov Chains • Example: Creature Diet ▪ Can be modeled with a Markov chain since its choice tomorrow depends solely on what it ate today o not what it ate yesterday o not what it ate any other time in the past ▪ Statistical property that could be calculated is the expected percentage, over a long period, of the days on which the creature will eat grapes 68 / 90
  • 69. Markov Chain – Definition A Markov chain is a sequence of random variables X1, X2, X3, ... with the Markov property, namely that, given the present state, the future and past states are independent: Pr 𝑋1 = 𝑥1, … , 𝑋 𝑛 = 𝑥 𝑛 > 0 ⇒ Pr 𝑋 𝑛+1 = 𝑥 𝑋1= 𝑥1, 𝑋2 = 𝑥2, … . , 𝑋 𝑛 = 𝑥 𝑛 = Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑥 𝑛) 69 / 90
  • 70. Markov Chains – Description • Directed graph ▪ Edges are labeled by the probabilities of going from one state at time n to the other states at time n+1 • Transition matrix 70 / 90
  • 71. Stationary Markov Chains Stationary Markov chains are processes where the probability of a transition is independent of n. ∀𝑛 ∈ 𝑁: Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑦) = Pr(𝑋 𝑛 = 𝑥 | 𝑋 𝑛−1 = 𝑦) 71 / 90
  • 72. Higher Order Markov Chains A Markov chain of order 𝑚 ∈ 𝑁 is a process where the future state depends on the past m states. ∀𝑛 ∈ 𝑁, 𝑛 > 𝑚: Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑥 𝑛, 𝑋 𝑛−1 = 𝑥 𝑛−1, … , 𝑋1 = 𝑥1) = Pr 𝑋 𝑛+1 = 𝑥 𝑋 𝑛 = 𝑥 𝑛, 𝑋 𝑛−1 = 𝑥 𝑛−1, … , 𝑋 𝑛−𝑚 = 𝑥 𝑛−𝑚) 72 / 90
  • 74. Random Name Generation Given an input set of feasible existing names, a new random name can be generated using an m-order Markov chain as follows: 1. Pick any existing name, with equal probability. 2. Take the first m letters of that name. 3. Find all existing names containing these m letters. 4. In all of these existing names, check the following letter. (Consider end-of-word as letter here.) Count the occurrences of the same following letters. 5. Pick the next letter of the generated name with probability of the distribution in existing names. 6. If the next letter is not end-of-word, start over from step 3, always considering the last m letters of the current name. 74 / 90
  • 75. Random Name Generation Example (m = 2) 1. Pick any existing name, with equal probability. LILY 75 / 90
  • 76. Random Name Generation Example (m = 2, name = “LI”, current = “LI”) 2. Take the first m letters of that name. LI 76 / 90
  • 77. Random Name Generation Example (m = 2, name = “LI”, current = “LI”) 3. Find all existing names containing these m letters. AMELIA, OLIVIA, LILY, ALICE, ELISABETH, LILAH, JULIET, CAROLINE, EVANGELINE, MADELINE, NATELIE, ROSALIE, LILLIAN, ELISE, ADELINE, DELILAH, ELIANA, FELICITY, JULIA 77 / 90
  • 78. Random Name Generation Example (m = 2, name = “LI”, current = “LI”) 4. In all of these existing names, check the following letter. (Consider end-of-word as letter here.) Count the occurrences of the same following letters. 78 / 90 Next Letter Occurrences Probability A 3 16 % V 1 5 % L 4 21 % C 2 11 % S 2 11 % E 3 16 % N 4 21 %
  • 79. Random Name Generation Example (m = 2, name = “LIN”, current = “LI”) 5. Pick the next letter of the generated name with probability of the distribution in existing names. 79 / 90 Next Letter Occurrences Probability A 3 16 % V 1 5 % L 4 21 % C 2 11 % S 2 11 % E 3 16 % N 4 21 %
  • 80. Random Name Generation Example (m = 2, name = “LIN”, current = “IN”) 2. Take the last m letters of the generated name. IN 80 / 90
  • 81. Random Name Generation Example (m = 2, name = “LIN”, current = “IN”) 3. Find all existing names containing these m letters. CAROLINE, EVANGELINE, MADELINE, JOSEPHINE, ADELINE, QUINN 81 / 90
  • 82. Random Name Generation Example (m = 2, name = “LIN”, current = “IN”) 4. In all of these existing names, check the following letter. (Consider end-of-word as letter here.) Count the occurrences of the same following letters. 82 / 90 Next Letter Occurrences Probability E 5 83 % N 1 17 %
  • 83. Random Name Generation Example (m = 2, name = “LINN”, current = “IN”) 5. Pick the next letter of the generated name with probability of the distribution in existing names. 83 / 90 Next Letter Occurrences Probability E 5 83 % N 1 17 %
  • 84. Random Name Generation Example (m = 2, name = “LINN”, current = “NN”) 2. Take the last m letters of the generated name. NN 84 / 90
  • 85. Random Name Generation Example (m = 2, name = “LINN”, current = “NN”) 3. Find all existing names containing these m letters. ARIANNA, HANNAH, ANNA, SAVANNAH, ANNABELLE, QUINN, SIENNA 85 / 90
  • 86. Random Name Generation Example (m = 2, name = “LINN”, current = “NN”) 4. In all of these existing names, check the following letter. (Consider end-of-word as letter here.) Count the occurrences of the same following letters. 86 / 90 Next Letter Occurrences Probability A 6 86 % End-of-word 1 14 %
  • 87. Random Name Generation Example (m = 2, name = “LINN”, current = “NN”) 5. Pick the next letter of the generated name with probability of the distribution in existing names. 87 / 90 Next Letter Occurrences Probability A 6 86 % End-of-word 1 14 %
  • 88. Random Name Generation Example (m = 2) Generated Name: LINN 88 / 90
  • 89. References • Togelius, Yannakakis, Stanley, Browne. Search-based procedural content generation. In EvoApplications Workshop, volume 2024 of LNCS, pages 141150, November 2010. • Andrew Doull. The death of the level designer: Procedural content generation in games. http://roguelikedeveloper.blogspot.de/2008/01/death-of-level-designer-procedural.html, January 2008. • Peter Mawhorter and Michael Mateas. Procedural level generation using occupancy-regulated extension. In CIG, pages 351358, 2010. • Press, Teukolsky, Vetterling, Flannery. Numerical Recipes 3rd Edition: The Art of Scientic Computing. Cambridge University Press, New York, NY, USA, 2007. • Ince. Automatic Dynamic Content Generation for Computer Games. PhD thesis, University of Sheeld, 1999. • Compton, Mateas. Procedural level design for platform games. In Proceedings of the 2nd Articial Intelligence and Interactive Digital Entertainment Conference (AIIDE), pages 109111, Marina del Rey, California, June 2006.
  • 90. References • Laskov. Level generation system for platform games based on a reinforcement learning approach. Master's thesis, The University of Edinburgh, School of Informatics, 2009. • Sorenson, Pasquier. Towards a generic framework for automated video game level creation. In EvoApplications (1), pages 131140, 2010. • Prühs, Vaz Alves. Towards a Generic Framework for Procedural Generation of Game Levels. Master’s Thesis, Hamburg University of Applied Sciences, 2011. • Perlin. Noise and Turbulence. http://www.mrl.nyu.edu/~perlin/doc/oscar.html, 1997. • Perlin. Making Noise. http://www.noisemachine.com/talk1/index.html, December 9, 1999. • Zucker. The Perlin noise math FAQ. http://webstaff.itn.liu.se/~stegu/TNM022- 2005/perlinnoiselinks/perlin-noise-math-faq.html#toc-algorithm, February 2001. • Wikipedia. Markow chain. http://en.wikipedia.org/wiki/Markov_chain, September 6, 2014. • Silicon Commader Games. Markow Name Generator. http://www.siliconcommandergames.com/MarkovNameGenerator.htm, May 2016.
  • 92. 5 Minute Review Session • Which categories of procedural content generation do you know? • Name a few opportunities of PCG! • Name a few challenges of using generated content! • In a few words, explain the chunk-based level generation approach! • What is coherent noise, and what can it be used for? • What are Markov chains, and what can they be used for?