SlideShare a Scribd company logo
1 of 35
Download to read offline
Prof. Pier Luca Lanzi
Procedural Content Generation with Unity
Prof. Pier Luca Lanzi
what’s the basic principle?
Prof. Pier Luca Lanzi
f(x) = sin(x)
float y = 0f;
for (float x = 0f; x<6.28f; x+=.01f) {
y = Mathf.Sin(x);
}
Prof. Pier Luca Lanzi
What the ingredients?
domain knowledge
structured randomness
multi-layering
filters, limits & restrictions
specialized algorithms
artificial intelligence
gameplay integration
Prof. Pier Luca Lanzi
Outline
procedural geometry
colors & music
Prof. Pier Luca Lanzi
Procedural Geometry
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
/// specify vertices
Vector3[] vertices = new Vector3[4];
vertices[0] = new Vector3(0.0f, 0.0f, 0.0f);
vertices[1] = new Vector3(0.0f, 0.0f, m_Length);
vertices[2] = new Vector3(m_Width, 0.0f, m_Length);
vertices[3] = new Vector3(m_Width, 0.0f, 0.0f);
/// specify 2 triangles
int[] indices = new int[6];
/// triangle 1
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
/// triangle 2
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
/// create the mesh
Mesh mesh = new Mesh();
mesh.vertices = vertices;
mesh.triangles = indices;
mesh.RecalculateBounds();
Prof. Pier Luca Lanzi
/// create the normals
Vector3[] normals = new Vector3[4];
normals[0] = Vector3.up;
normals[1] = Vector3.up;
normals[2] = Vector3.up;
normals[3] = Vector3.up;
mesh.normals = normals;
/// create the UV for the full texture
Vector2[] uv = new Vector2[4];
uv[0] = new Vector2(0.0f, 0.0f);
uv[1] = new Vector2(0.0f, 1.0f);
uv[2] = new Vector2(1.0f, 1.0f);
uv[3] = new Vector2(1.0f, 0.0f);
mesh.uv = uv;
/// create the UV for half texture
Vector2[] uv = new Vector2[4];
uv[0] = new Vector2(0.0f, 0.0f);
uv[1] = new Vector2(0.0f, 1.0f);
uv[2] = new Vector2(0.5f, 1.0f);
uv[3] = new Vector2(0.5f, 0.0f);
mesh.uv = uv;
Prof. Pier Luca Lanzi
public class MeshBuilder
{
public List<Vector3> Vertices;
public List<Vector3> Normals;
public List<Vector2> UVs;
public void AddTriangle(int i0, int i1, int i2);
public Mesh CreateMesh()
}
MeshBuilder meshBuilder = new MeshBuilder();
//Set up the vertices and triangles:
meshBuilder.Vertices.Add(new Vector3(0.0f, 0.0f, 0.0f));
meshBuilder.UVs.Add(new Vector2(0.0f, 0.0f));
meshBuilder.Normals.Add(Vector3.up);
...
meshBuilder.AddTriangle(0, 1, 2);
meshBuilder.AddTriangle(0, 2, 3);
...
Prof. Pier Luca Lanzi
MeshBuilder meshBuilder = new MeshBuilder();
for (int i = 0; i < m_SegmentCount; i++)
{
float z = m_Length * i;
for (int j = 0; j < m_SegmentCount; j++)
{
float x = m_Width * j;
Vector3 offset =
new Vector3(x, Random.Range(0.0f, m_Height), z);
BuildQuad(meshBuilder, offset);
}
}
Prof. Pier Luca Lanzi
12
Prof. Pier Luca Lanzi
Ingredients #1 & #2
Domain Knowledge & Artificial Intelligence
• Domain Knowledge
§ To generate something you need to know it
§ PCG typically aims at building an artificial level designer,
usually needs domain knowledge
about level design
• Artificial Intelligence
§ Need algorithms that can work on complex
knowledge and generate plausible content
§ Search-based methods, L-systems, evolutionary
computation, fractals, cellular automata,
agent-based methods, planning, etc.
13
Prof. Pier Luca Lanzi
14
ESEMPIO CON LA CAVE?
ESEMPIO DI DUNGEON?
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
ingredient #3
structured randomness
things look like they have been randomly
generated but it is not completely at random!
Prof. Pier Luca Lanzi
f(x) = sin(x)
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
they both look like “noise”
but one of them feels like it has structure…
it is structured randomness
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
ingredient #4
multi-layering
typically more layers of procedural
content generation are applied in sequence
Prof. Pier Luca Lanzi
• Warzone 2100
§Heights & Cliffs
§Roads
§Textures
§Player Bases
§Local Features
• Civilization 4
§Fractal Heightfield
§Plate Tectonics
§Tile Types
§Rivers and Lakes
§Map Bonuses
Prof. Pier Luca Lanzi
ingredient #5
Filters, Limits & Restrictions
“In Civ3 I would say we even shipped with a sub-standard resource
placement algorithm where all the iron could be concentrated in just
a few small locations on the map, and for one player there may be
literally no way for them to build swordsmen.” – Soren Johnson
"With Civ4 we instituted randomness with limitations. There
always has to be a minimum distance between each element of
iron, or each element of horses, and that completely solved the
problem.” – Soren Johnson
Prof. Pier Luca Lanzi
ingredient #6
specialized algorithms
placing special items, requires special tricks
this tricks must be encoded in the PCG
Prof. Pier Luca Lanzi
1. Connect all bases, the resources,
pick three random points and
connect them
2. Apply a customize A* heuristic
and reuse roads!
3. Customize A* heuristic with
randomize cost of non-road
grid cells.
Prof. Pier Luca Lanzi
ingredient #7
gameplay integration
Is it fun to play? Is the progression adequate?
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
is this all there is?
Prof. Pier Luca Lanzi
PCG
Is it done online?
Or offline?
Is it necessary content?
Or optional?
Do you use random
seeds or parameter
vectors?
Is it stochastic?
Or deterministic?
Generate and test?
Constructive?
Prof. Pier Luca Lanzi
we can do it, so can you!
Prof. Pier Luca Lanzihttp://trackgen.pierlucalanzi.net
Prof. Pier Luca Lanzi
http://www.youtube.com/watch?v=uIUYWzdMXog
Prof. Pier Luca Lanzihttp://www.michelepirovano.com/portfolio_swordgenerator.php
Prof. Pier Luca Lanzihttp://www.michelepirovano.com/portfolio_swordgenerator.php
Prof. Pier Luca Lanzi
http://www.polimigamecollective.org
http://www.facebook.com/polimigamecollective
http://www.youtube.com/PierLucaLanzi

More Related Content

What's hot

DMTM Lecture 09 Other classificationmethods
DMTM Lecture 09 Other classificationmethodsDMTM Lecture 09 Other classificationmethods
DMTM Lecture 09 Other classificationmethodsPier Luca Lanzi
 
DMTM Lecture 04 Classification
DMTM Lecture 04 ClassificationDMTM Lecture 04 Classification
DMTM Lecture 04 ClassificationPier Luca Lanzi
 
DBSCAN : A Clustering Algorithm
DBSCAN : A Clustering AlgorithmDBSCAN : A Clustering Algorithm
DBSCAN : A Clustering AlgorithmPınar Yahşi
 
20211019 When does label smoothing help_shared ver
20211019 When does label smoothing help_shared ver20211019 When does label smoothing help_shared ver
20211019 When does label smoothing help_shared verHsing-chuan Hsieh
 
3.4 density and grid methods
3.4 density and grid methods3.4 density and grid methods
3.4 density and grid methodsKrish_ver2
 
DMTM 2015 - 08 Representative-Based Clustering
DMTM 2015 - 08 Representative-Based ClusteringDMTM 2015 - 08 Representative-Based Clustering
DMTM 2015 - 08 Representative-Based ClusteringPier Luca Lanzi
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscanYan Xu
 
DBSCAN (2014_11_25 06_21_12 UTC)
DBSCAN (2014_11_25 06_21_12 UTC)DBSCAN (2014_11_25 06_21_12 UTC)
DBSCAN (2014_11_25 06_21_12 UTC)Cory Cook
 
Mathematics online: some common algorithms
Mathematics online: some common algorithmsMathematics online: some common algorithms
Mathematics online: some common algorithmsMark Moriarty
 
Optics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structureOptics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structureRajesh Piryani
 
DMTM Lecture 08 Classification rules
DMTM Lecture 08 Classification rulesDMTM Lecture 08 Classification rules
DMTM Lecture 08 Classification rulesPier Luca Lanzi
 
K-means Clustering
K-means ClusteringK-means Clustering
K-means ClusteringAnna Fensel
 

What's hot (20)

DMTM Lecture 09 Other classificationmethods
DMTM Lecture 09 Other classificationmethodsDMTM Lecture 09 Other classificationmethods
DMTM Lecture 09 Other classificationmethods
 
DMTM Lecture 04 Classification
DMTM Lecture 04 ClassificationDMTM Lecture 04 Classification
DMTM Lecture 04 Classification
 
DBSCAN : A Clustering Algorithm
DBSCAN : A Clustering AlgorithmDBSCAN : A Clustering Algorithm
DBSCAN : A Clustering Algorithm
 
Dbscan algorithom
Dbscan algorithomDbscan algorithom
Dbscan algorithom
 
20211019 When does label smoothing help_shared ver
20211019 When does label smoothing help_shared ver20211019 When does label smoothing help_shared ver
20211019 When does label smoothing help_shared ver
 
3.4 density and grid methods
3.4 density and grid methods3.4 density and grid methods
3.4 density and grid methods
 
K means
K meansK means
K means
 
Clique and sting
Clique and stingClique and sting
Clique and sting
 
Db Scan
Db ScanDb Scan
Db Scan
 
DMTM 2015 - 08 Representative-Based Clustering
DMTM 2015 - 08 Representative-Based ClusteringDMTM 2015 - 08 Representative-Based Clustering
DMTM 2015 - 08 Representative-Based Clustering
 
K means Clustering Algorithm
K means Clustering AlgorithmK means Clustering Algorithm
K means Clustering Algorithm
 
Kmeans plusplus
Kmeans plusplusKmeans plusplus
Kmeans plusplus
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscan
 
DBSCAN (2014_11_25 06_21_12 UTC)
DBSCAN (2014_11_25 06_21_12 UTC)DBSCAN (2014_11_25 06_21_12 UTC)
DBSCAN (2014_11_25 06_21_12 UTC)
 
Mathematics online: some common algorithms
Mathematics online: some common algorithmsMathematics online: some common algorithms
Mathematics online: some common algorithms
 
Optics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structureOptics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structure
 
Neural nw k means
Neural nw k meansNeural nw k means
Neural nw k means
 
K means
K meansK means
K means
 
DMTM Lecture 08 Classification rules
DMTM Lecture 08 Classification rulesDMTM Lecture 08 Classification rules
DMTM Lecture 08 Classification rules
 
K-means Clustering
K-means ClusteringK-means Clustering
K-means Clustering
 

Similar to VDP2016 - Lecture 15 PCG with Unity

Pier Luca Lanzi, Michele Pirovano - Procedural Content Generation with Unity
Pier Luca Lanzi, Michele Pirovano - Procedural Content Generation with UnityPier Luca Lanzi, Michele Pirovano - Procedural Content Generation with Unity
Pier Luca Lanzi, Michele Pirovano - Procedural Content Generation with UnityCodemotion
 
Codemotion Milan - November 21 2015
Codemotion Milan - November 21 2015Codemotion Milan - November 21 2015
Codemotion Milan - November 21 2015Pier Luca Lanzi
 
Rust: Reach Further
Rust: Reach FurtherRust: Reach Further
Rust: Reach Furthernikomatsakis
 
Maximizing the spectral gap of networks produced by node removal
Maximizing the spectral gap of networks produced by node removalMaximizing the spectral gap of networks produced by node removal
Maximizing the spectral gap of networks produced by node removalNaoki Masuda
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Siouxnikomatsakis
 
Chord Presentation at Papers We Love SF, August 2016
Chord Presentation at Papers We Love SF, August 2016Chord Presentation at Papers We Love SF, August 2016
Chord Presentation at Papers We Love SF, August 2016Tom Faulhaber
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorialcscarcas
 
Raspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdf
Raspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdfRaspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdf
Raspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdfSANTIAGO PABLO ALBERTO
 
Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)Mostafa G. M. Mostafa
 
Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13specialk29
 
L1 Sudoku
L1 SudokuL1 Sudoku
L1 Sudokubnmoran
 
Pharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkPharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkSerge Stinckwich
 
Minimum Complexity Decoupling Networks for Arbitrary Coupled Loads
Minimum Complexity Decoupling Networks for Arbitrary Coupled LoadsMinimum Complexity Decoupling Networks for Arbitrary Coupled Loads
Minimum Complexity Decoupling Networks for Arbitrary Coupled LoadsDing Nie
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...David Walker
 
Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++Satalia
 
The world is the computer and the programmer is you
The world is the computer and the programmer is youThe world is the computer and the programmer is you
The world is the computer and the programmer is youDavide Carboni
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Gene Leybzon
 
Blockchain and smart contracts day 2
Blockchain and smart contracts day 2Blockchain and smart contracts day 2
Blockchain and smart contracts day 2Gene Leybzon
 

Similar to VDP2016 - Lecture 15 PCG with Unity (20)

Pier Luca Lanzi, Michele Pirovano - Procedural Content Generation with Unity
Pier Luca Lanzi, Michele Pirovano - Procedural Content Generation with UnityPier Luca Lanzi, Michele Pirovano - Procedural Content Generation with Unity
Pier Luca Lanzi, Michele Pirovano - Procedural Content Generation with Unity
 
Codemotion Milan - November 21 2015
Codemotion Milan - November 21 2015Codemotion Milan - November 21 2015
Codemotion Milan - November 21 2015
 
Rust: Reach Further
Rust: Reach FurtherRust: Reach Further
Rust: Reach Further
 
Maximizing the spectral gap of networks produced by node removal
Maximizing the spectral gap of networks produced by node removalMaximizing the spectral gap of networks produced by node removal
Maximizing the spectral gap of networks produced by node removal
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Sioux
 
Chord Presentation at Papers We Love SF, August 2016
Chord Presentation at Papers We Love SF, August 2016Chord Presentation at Papers We Love SF, August 2016
Chord Presentation at Papers We Love SF, August 2016
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
 
Raspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdf
Raspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdfRaspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdf
Raspberry Pi: Python todo en uno para dummies por John Shovic parte 2.pdf
 
Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)
 
Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13
 
Spectral convnets
Spectral convnetsSpectral convnets
Spectral convnets
 
L1 Sudoku
L1 SudokuL1 Sudoku
L1 Sudoku
 
Pharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkPharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source Smalltalk
 
Minimum Complexity Decoupling Networks for Arbitrary Coupled Loads
Minimum Complexity Decoupling Networks for Arbitrary Coupled LoadsMinimum Complexity Decoupling Networks for Arbitrary Coupled Loads
Minimum Complexity Decoupling Networks for Arbitrary Coupled Loads
 
Deep learning (2)
Deep learning (2)Deep learning (2)
Deep learning (2)
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
 
Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++Options and trade offs for parallelism and concurrency in Modern C++
Options and trade offs for parallelism and concurrency in Modern C++
 
The world is the computer and the programmer is you
The world is the computer and the programmer is youThe world is the computer and the programmer is you
The world is the computer and the programmer is you
 
Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3Hands on with Smart Contracts session #3
Hands on with Smart Contracts session #3
 
Blockchain and smart contracts day 2
Blockchain and smart contracts day 2Blockchain and smart contracts day 2
Blockchain and smart contracts day 2
 

More from Pier Luca Lanzi

11 Settembre 2021 - Giocare con i Videogiochi
11 Settembre 2021 - Giocare con i Videogiochi11 Settembre 2021 - Giocare con i Videogiochi
11 Settembre 2021 - Giocare con i VideogiochiPier Luca Lanzi
 
Breve Viaggio al Centro dei Videogiochi
Breve Viaggio al Centro dei VideogiochiBreve Viaggio al Centro dei Videogiochi
Breve Viaggio al Centro dei VideogiochiPier Luca Lanzi
 
Global Game Jam 19 @ POLIMI - Morning Welcome
Global Game Jam 19 @ POLIMI - Morning WelcomeGlobal Game Jam 19 @ POLIMI - Morning Welcome
Global Game Jam 19 @ POLIMI - Morning WelcomePier Luca Lanzi
 
Data Driven Game Design @ Campus Party 2018
Data Driven Game Design @ Campus Party 2018Data Driven Game Design @ Campus Party 2018
Data Driven Game Design @ Campus Party 2018Pier Luca Lanzi
 
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...Pier Luca Lanzi
 
GGJ18 al Politecnico di Milano - Presentazione di apertura
GGJ18 al Politecnico di Milano - Presentazione di aperturaGGJ18 al Politecnico di Milano - Presentazione di apertura
GGJ18 al Politecnico di Milano - Presentazione di aperturaPier Luca Lanzi
 
Presentation for UNITECH event - January 8, 2018
Presentation for UNITECH event - January 8, 2018Presentation for UNITECH event - January 8, 2018
Presentation for UNITECH event - January 8, 2018Pier Luca Lanzi
 
DMTM Lecture 19 Data exploration
DMTM Lecture 19 Data explorationDMTM Lecture 19 Data exploration
DMTM Lecture 19 Data explorationPier Luca Lanzi
 
DMTM Lecture 18 Graph mining
DMTM Lecture 18 Graph miningDMTM Lecture 18 Graph mining
DMTM Lecture 18 Graph miningPier Luca Lanzi
 
DMTM Lecture 17 Text mining
DMTM Lecture 17 Text miningDMTM Lecture 17 Text mining
DMTM Lecture 17 Text miningPier Luca Lanzi
 
DMTM Lecture 16 Association rules
DMTM Lecture 16 Association rulesDMTM Lecture 16 Association rules
DMTM Lecture 16 Association rulesPier Luca Lanzi
 
DMTM Lecture 15 Clustering evaluation
DMTM Lecture 15 Clustering evaluationDMTM Lecture 15 Clustering evaluation
DMTM Lecture 15 Clustering evaluationPier Luca Lanzi
 
DMTM Lecture 10 Classification ensembles
DMTM Lecture 10 Classification ensemblesDMTM Lecture 10 Classification ensembles
DMTM Lecture 10 Classification ensemblesPier Luca Lanzi
 
DMTM Lecture 07 Decision trees
DMTM Lecture 07 Decision treesDMTM Lecture 07 Decision trees
DMTM Lecture 07 Decision treesPier Luca Lanzi
 
DMTM Lecture 06 Classification evaluation
DMTM Lecture 06 Classification evaluationDMTM Lecture 06 Classification evaluation
DMTM Lecture 06 Classification evaluationPier Luca Lanzi
 
DMTM Lecture 05 Data representation
DMTM Lecture 05 Data representationDMTM Lecture 05 Data representation
DMTM Lecture 05 Data representationPier Luca Lanzi
 
DMTM Lecture 03 Regression
DMTM Lecture 03 RegressionDMTM Lecture 03 Regression
DMTM Lecture 03 RegressionPier Luca Lanzi
 
DMTM Lecture 01 Introduction
DMTM Lecture 01 IntroductionDMTM Lecture 01 Introduction
DMTM Lecture 01 IntroductionPier Luca Lanzi
 
DMTM Lecture 02 Data mining
DMTM Lecture 02 Data miningDMTM Lecture 02 Data mining
DMTM Lecture 02 Data miningPier Luca Lanzi
 
VDP2016 - Lecture 16 Rendering pipeline
VDP2016 - Lecture 16 Rendering pipelineVDP2016 - Lecture 16 Rendering pipeline
VDP2016 - Lecture 16 Rendering pipelinePier Luca Lanzi
 

More from Pier Luca Lanzi (20)

11 Settembre 2021 - Giocare con i Videogiochi
11 Settembre 2021 - Giocare con i Videogiochi11 Settembre 2021 - Giocare con i Videogiochi
11 Settembre 2021 - Giocare con i Videogiochi
 
Breve Viaggio al Centro dei Videogiochi
Breve Viaggio al Centro dei VideogiochiBreve Viaggio al Centro dei Videogiochi
Breve Viaggio al Centro dei Videogiochi
 
Global Game Jam 19 @ POLIMI - Morning Welcome
Global Game Jam 19 @ POLIMI - Morning WelcomeGlobal Game Jam 19 @ POLIMI - Morning Welcome
Global Game Jam 19 @ POLIMI - Morning Welcome
 
Data Driven Game Design @ Campus Party 2018
Data Driven Game Design @ Campus Party 2018Data Driven Game Design @ Campus Party 2018
Data Driven Game Design @ Campus Party 2018
 
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
 
GGJ18 al Politecnico di Milano - Presentazione di apertura
GGJ18 al Politecnico di Milano - Presentazione di aperturaGGJ18 al Politecnico di Milano - Presentazione di apertura
GGJ18 al Politecnico di Milano - Presentazione di apertura
 
Presentation for UNITECH event - January 8, 2018
Presentation for UNITECH event - January 8, 2018Presentation for UNITECH event - January 8, 2018
Presentation for UNITECH event - January 8, 2018
 
DMTM Lecture 19 Data exploration
DMTM Lecture 19 Data explorationDMTM Lecture 19 Data exploration
DMTM Lecture 19 Data exploration
 
DMTM Lecture 18 Graph mining
DMTM Lecture 18 Graph miningDMTM Lecture 18 Graph mining
DMTM Lecture 18 Graph mining
 
DMTM Lecture 17 Text mining
DMTM Lecture 17 Text miningDMTM Lecture 17 Text mining
DMTM Lecture 17 Text mining
 
DMTM Lecture 16 Association rules
DMTM Lecture 16 Association rulesDMTM Lecture 16 Association rules
DMTM Lecture 16 Association rules
 
DMTM Lecture 15 Clustering evaluation
DMTM Lecture 15 Clustering evaluationDMTM Lecture 15 Clustering evaluation
DMTM Lecture 15 Clustering evaluation
 
DMTM Lecture 10 Classification ensembles
DMTM Lecture 10 Classification ensemblesDMTM Lecture 10 Classification ensembles
DMTM Lecture 10 Classification ensembles
 
DMTM Lecture 07 Decision trees
DMTM Lecture 07 Decision treesDMTM Lecture 07 Decision trees
DMTM Lecture 07 Decision trees
 
DMTM Lecture 06 Classification evaluation
DMTM Lecture 06 Classification evaluationDMTM Lecture 06 Classification evaluation
DMTM Lecture 06 Classification evaluation
 
DMTM Lecture 05 Data representation
DMTM Lecture 05 Data representationDMTM Lecture 05 Data representation
DMTM Lecture 05 Data representation
 
DMTM Lecture 03 Regression
DMTM Lecture 03 RegressionDMTM Lecture 03 Regression
DMTM Lecture 03 Regression
 
DMTM Lecture 01 Introduction
DMTM Lecture 01 IntroductionDMTM Lecture 01 Introduction
DMTM Lecture 01 Introduction
 
DMTM Lecture 02 Data mining
DMTM Lecture 02 Data miningDMTM Lecture 02 Data mining
DMTM Lecture 02 Data mining
 
VDP2016 - Lecture 16 Rendering pipeline
VDP2016 - Lecture 16 Rendering pipelineVDP2016 - Lecture 16 Rendering pipeline
VDP2016 - Lecture 16 Rendering pipeline
 

Recently uploaded

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 

Recently uploaded (20)

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 

VDP2016 - Lecture 15 PCG with Unity

  • 1. Prof. Pier Luca Lanzi Procedural Content Generation with Unity
  • 2. Prof. Pier Luca Lanzi what’s the basic principle?
  • 3. Prof. Pier Luca Lanzi f(x) = sin(x) float y = 0f; for (float x = 0f; x<6.28f; x+=.01f) { y = Mathf.Sin(x); }
  • 4. Prof. Pier Luca Lanzi What the ingredients? domain knowledge structured randomness multi-layering filters, limits & restrictions specialized algorithms artificial intelligence gameplay integration
  • 5. Prof. Pier Luca Lanzi Outline procedural geometry colors & music
  • 6. Prof. Pier Luca Lanzi Procedural Geometry
  • 8. Prof. Pier Luca Lanzi /// specify vertices Vector3[] vertices = new Vector3[4]; vertices[0] = new Vector3(0.0f, 0.0f, 0.0f); vertices[1] = new Vector3(0.0f, 0.0f, m_Length); vertices[2] = new Vector3(m_Width, 0.0f, m_Length); vertices[3] = new Vector3(m_Width, 0.0f, 0.0f); /// specify 2 triangles int[] indices = new int[6]; /// triangle 1 indices[0] = 0; indices[1] = 1; indices[2] = 2; /// triangle 2 indices[3] = 0; indices[4] = 2; indices[5] = 3; /// create the mesh Mesh mesh = new Mesh(); mesh.vertices = vertices; mesh.triangles = indices; mesh.RecalculateBounds();
  • 9. Prof. Pier Luca Lanzi /// create the normals Vector3[] normals = new Vector3[4]; normals[0] = Vector3.up; normals[1] = Vector3.up; normals[2] = Vector3.up; normals[3] = Vector3.up; mesh.normals = normals; /// create the UV for the full texture Vector2[] uv = new Vector2[4]; uv[0] = new Vector2(0.0f, 0.0f); uv[1] = new Vector2(0.0f, 1.0f); uv[2] = new Vector2(1.0f, 1.0f); uv[3] = new Vector2(1.0f, 0.0f); mesh.uv = uv; /// create the UV for half texture Vector2[] uv = new Vector2[4]; uv[0] = new Vector2(0.0f, 0.0f); uv[1] = new Vector2(0.0f, 1.0f); uv[2] = new Vector2(0.5f, 1.0f); uv[3] = new Vector2(0.5f, 0.0f); mesh.uv = uv;
  • 10. Prof. Pier Luca Lanzi public class MeshBuilder { public List<Vector3> Vertices; public List<Vector3> Normals; public List<Vector2> UVs; public void AddTriangle(int i0, int i1, int i2); public Mesh CreateMesh() } MeshBuilder meshBuilder = new MeshBuilder(); //Set up the vertices and triangles: meshBuilder.Vertices.Add(new Vector3(0.0f, 0.0f, 0.0f)); meshBuilder.UVs.Add(new Vector2(0.0f, 0.0f)); meshBuilder.Normals.Add(Vector3.up); ... meshBuilder.AddTriangle(0, 1, 2); meshBuilder.AddTriangle(0, 2, 3); ...
  • 11. Prof. Pier Luca Lanzi MeshBuilder meshBuilder = new MeshBuilder(); for (int i = 0; i < m_SegmentCount; i++) { float z = m_Length * i; for (int j = 0; j < m_SegmentCount; j++) { float x = m_Width * j; Vector3 offset = new Vector3(x, Random.Range(0.0f, m_Height), z); BuildQuad(meshBuilder, offset); } }
  • 12. Prof. Pier Luca Lanzi 12
  • 13. Prof. Pier Luca Lanzi Ingredients #1 & #2 Domain Knowledge & Artificial Intelligence • Domain Knowledge § To generate something you need to know it § PCG typically aims at building an artificial level designer, usually needs domain knowledge about level design • Artificial Intelligence § Need algorithms that can work on complex knowledge and generate plausible content § Search-based methods, L-systems, evolutionary computation, fractals, cellular automata, agent-based methods, planning, etc. 13
  • 14. Prof. Pier Luca Lanzi 14 ESEMPIO CON LA CAVE? ESEMPIO DI DUNGEON?
  • 16. Prof. Pier Luca Lanzi ingredient #3 structured randomness things look like they have been randomly generated but it is not completely at random!
  • 17. Prof. Pier Luca Lanzi f(x) = sin(x)
  • 19. Prof. Pier Luca Lanzi they both look like “noise” but one of them feels like it has structure… it is structured randomness
  • 21. Prof. Pier Luca Lanzi ingredient #4 multi-layering typically more layers of procedural content generation are applied in sequence
  • 22. Prof. Pier Luca Lanzi • Warzone 2100 §Heights & Cliffs §Roads §Textures §Player Bases §Local Features • Civilization 4 §Fractal Heightfield §Plate Tectonics §Tile Types §Rivers and Lakes §Map Bonuses
  • 23. Prof. Pier Luca Lanzi ingredient #5 Filters, Limits & Restrictions “In Civ3 I would say we even shipped with a sub-standard resource placement algorithm where all the iron could be concentrated in just a few small locations on the map, and for one player there may be literally no way for them to build swordsmen.” – Soren Johnson "With Civ4 we instituted randomness with limitations. There always has to be a minimum distance between each element of iron, or each element of horses, and that completely solved the problem.” – Soren Johnson
  • 24. Prof. Pier Luca Lanzi ingredient #6 specialized algorithms placing special items, requires special tricks this tricks must be encoded in the PCG
  • 25. Prof. Pier Luca Lanzi 1. Connect all bases, the resources, pick three random points and connect them 2. Apply a customize A* heuristic and reuse roads! 3. Customize A* heuristic with randomize cost of non-road grid cells.
  • 26. Prof. Pier Luca Lanzi ingredient #7 gameplay integration Is it fun to play? Is the progression adequate?
  • 28. Prof. Pier Luca Lanzi is this all there is?
  • 29. Prof. Pier Luca Lanzi PCG Is it done online? Or offline? Is it necessary content? Or optional? Do you use random seeds or parameter vectors? Is it stochastic? Or deterministic? Generate and test? Constructive?
  • 30. Prof. Pier Luca Lanzi we can do it, so can you!
  • 31. Prof. Pier Luca Lanzihttp://trackgen.pierlucalanzi.net
  • 32. Prof. Pier Luca Lanzi http://www.youtube.com/watch?v=uIUYWzdMXog
  • 33. Prof. Pier Luca Lanzihttp://www.michelepirovano.com/portfolio_swordgenerator.php
  • 34. Prof. Pier Luca Lanzihttp://www.michelepirovano.com/portfolio_swordgenerator.php
  • 35. Prof. Pier Luca Lanzi http://www.polimigamecollective.org http://www.facebook.com/polimigamecollective http://www.youtube.com/PierLucaLanzi