This document summarizes research on extending the wave function collapse (WFC) algorithm to generate game content on graphs rather than regular grids. It introduces the original WFC method, then describes representing game structures as graphs to allow irregular layouts. Experiments applying the graph-based WFC to Sudoku, map coloring, and navigation meshes are discussed. Future work is noted to handle problems with ordering dependencies and integrate different game structures.
Automatic Generation of Game Content using a Graph-based Wave Function Collapse Algorithm
1. Hongik University
2019.08.23
Hwanhee Kim, Seongtaek Lee, Hyundong Lee,
Taesung Hahn, Shinjin Kang
Automatic Generation of Game Content
using a Graph-based Wave Function
Collapse Algorithm
NCSOFT
2. About me
Hwanhee Kim
Game Designer (8 years)
• Web, Mobile, Console Experience
Technical Designer (6 years)
• JS, python, Flash 😱
Researcher (2 years)
• WFC, Deep Learning
• This is my 1st Paper - Hello world!
2011
2013
2017
4. Original WFC
• Wave Function Collapse
• Motivated by Image Synthesis Algorithm
• Divides input to small chunks(tile), and then rearrange them to
make new contents
https://github.com/mxgmn/WaveFunctionCollapse
5. Original WFC
• There are many applications in the game development scene
• 2 Commercial games
– Caves of Qud
– Bad north
https://twitter.com/unormal/status/805990194939838464
https://twitter.com/OskSta/status/917405214638006273
6. Original WFC
• Many demos
– 2D Platformer map generation by Andy Wallace
https://twitter.com/Andy_Makes/status/976615859069300736
7. Original WFC
• Many demos
– 3D Interior map by Marian
https://twitter.com/marian42_/status/1137111089425059840
8. Original WFC
• Many demos
– My trial
https://twitter.com/greentecq/status/1025348928634408960
10. Original WFC
• What are the common features of the above cases?
– Regularity
11. Original WFC
• What are the common features of the above cases?
– Regularity
– A Regular Grid is a tessellation of n-dimensional Euclidean space by congruent
parallelotopes (e.g. bricks). (Wikipedia)
https://en.wikipedia.org/wiki/Regular_grid#cite_ref-1
13. Original WFC
• Regular Grid is…
– rectangular grid, triangular grid, hexagonal grid…
– Each node constituting the grid has an equal number of neighbors
14. Original WFC
• Regular Grid is…
– rectangular grid, triangular grid, hexagonal grid…
– Each node constituting the grid has an equal number of neighbors
16. Original WFC
• Graph is consists of nodes and edges
– Regular grid is a special subset of the graph
Regular grid
17. Original WFC
• Graph is consists of nodes and edges
– Regular grid is a special subset of the graph
• Can we handle others?
Regular grid
18. Original WFC
• There are two key variables
• Propagator
– WFC propagates information on non-deployable tiles to neighboring nodes
– The adjacency information of two tiles is stored
– Memory size is 3D = [the number of all tiles] * [the number of directions] * [the
number of connectable tiles]
Tileset from https://www.kenney.nl/assets/road-textures
19. Original WFC
• Propagator
– Memory size is 3D = [the number of all tiles(7)] * [the number of directions] * [the
number of connectable tiles]
20. Original WFC
• Propagator
– Memory size is 3D = [the number of all tiles(7)] * [the number of directions(4)] *
[the number of connectable tiles]
left
up
right down
21. Original WFC
• Propagator
– Memory size is 3D = [the number of all tiles(7)] * [the number of directions(4)] *
[the number of connectable tiles(max 7)]
22. Original WFC
• There are two key variables
• Compatible
– The number of tiles that can be connected to any tile by direction at a particular
grid location
– This can be calculated by referring to propagator variable
– Memory size is also 3D = [the number all nodes] * [the number of all tiles] * [the
number of directions]
23. Original WFC
• Compatible
– Once the placement of the tiles begins, the
compatibility will decrease rapidly
– The compatibility of the remaining tiles except for the
tiles placed in the grid will be 0 on that tile and the
forbidden information will be stored
– If the compatibility of any tile in any grid is zero, the
other tiles will not be placed in this grid. This
prohibition information is also spread around
24. Original WFC
• Greedy Algorithm
– The original implementation picks the tiles that are most likely to fail and starts
again from the beginning
– For computational efficiency, several implementations have proposed
backtracking to return to the point of failure
25. Original WFC
• Recap
– 2D or 3D is possible, but on the regular grid
– Propagator, Compatible Direction is important
– Greedy Algorithm Backtracking is needed for efficiency
WFC algorithm process
26. Graph-based WFC
• WFC on the ‘general’ graph
• Of course there are some constraints…
– One edge connects only two different nodes
– Two nodes are connected to only one unique edge
– All edges are Undirected edge
27. Graph-based WFC
• WFC on the ‘general’ graph
• Of course there are some constraints…
– One edge connects only two different nodes
– Two nodes are connected to only one unique edge
– All edges are Undirected edge
2D rect grid
Number of neighbors = 4
Sudoku game board
Number of neighbors = 20
Voronoi cell (irregular grid)
Number of neighbors =
unlimited and variable
28. Graph-based WFC
• Direction checking is important in original WFC
• Since the direction has been lost, Propagator and Compatible
now becomes 2D
– Propagator : [the number of all tiles] * [the number of connectable tiles]
– Compatible : [the number all nodes] * [the number of all tiles]
• Memory usage is reduced! Is it just good?
Propagator Compatible Output
Voronoi grid (n=47)
29. Graph-based WFC
• Propagator Conflict
– Instead of reducing the condition to check, a connection that does not exist in the
original appears in the result
Propagator Propagator Conflict
30. Graph-based WFC
• Propagator Conflict
– Instead of reducing the condition to check, a connection that does not exist in the
original appears in the result
31. Graph-based WFC
• Propagator Conflict
– Instead of reducing the condition to check, a connection that does not exist in the
original appears in the result
– In this case, we call backtrack() function and goes back to the point before the
conflict occurs and runs the search again.
Graph-based WFC algorithm process
32. Graph-based WFC
• Propagator Conflict
– Instead of reducing the condition to check, a connection that does not exist in the
original appears in the result
– In this case, we call backtrack() function and goes back to the point before the
conflict occurs and runs the search again.
– The other algorithm process is very similar to the original
Graph-based
WFC algorithm process
WFC algorithm process
33. Graph-based WFC
• Recap
– WFC on the ‘general’ graph
– Direction is gone Added Propagator Conflict
34. Experiments
• Sudoku
– Base problem of constraint satisfaction
– With simple rule, on grid structure
– With value constraint
Sudoku game board
Number of neighbors = 20
Propagator
35. Experiments
• Sudoku
– Base problem of constraint satisfaction
– With simple rule and graph
– With value constraint
36. Experiments
• Four-color theorem
– Another base problem of constraint satisfaction
– With simple rule, on graph structure (Voronoi)
Propagator Voronoi cell (irregular grid)
Number of neighbors =
unlimited and variable
37. Experiments
• Four-color theorem
– Another base problem of constraint satisfaction
– With simple rule, on graph structure (Voronoi)
n=12 n=32 n=32
38. Experiments
• PCG experiment with navigation mesh
– Specify a node above the navigation mesh and place the node corresponding to
the game content
– The edge connecting each node is determined by finding the reachable distance
with the pathfinding algorithm
Propagator Random node and edge
39. Experiments
• PCG experiment with navigation mesh
– Probability constraint : Adjust the probability that a particular node will arrive
using a stationary variable
40. Future works
• Performance should be improved
• Currently, graph-based WFC can solve problems that are not
related to the order of the solution, but we need to expand the
algorithm to solve the problems related to the order of the
solution
https://youtu.be/et3hgNBrc88
41. Future works
• The graph structure may be used for various game structures -
dungeons, etc.
WFC(Graph Projection)
WFC(Level)
Graph
42. Thank you!
You can find me at @greentecq
Twitter: @greentecq
Mail : greentec91@gmail.com
43. References
• Hendrikx, M., Meijer, S., Velden, J. V. D., and Iosup, A. (2013).
Procedural content generation for games: A survey. ACM
Transactions on Multimedia Computing, Communications, and
Applications 9(1):1.
• Togelius, J., Yannakakis, G., Stanley, K., and Browne, C. (2011).
Search-based procedural content generation: A taxonomy and
survey. IEEE Transactions on Computational Intelligence and AI in
Games 3(3):172186.
• Dahlskog, S., and Togelius, J. (2013). Patterns as objectives for
level generation. In Proceedings of the Second Workshop on
Design Patterns in Games, ACM.
44. References
• Snodgrass, S., and Ontanon, S. (2014). A hierarchical approach to
generating maps using Markov chains. In Proceedings of the
Tenth Artificial Intelligence and Interactive Digital Entertainment
Conference.
• Jain, R., Isaksen, A., Holmgrd, C., and Togelius, J. (2016).
Autoencoders for level generation, repair, and recognition. In
Proceedings of the ICCC Workshop on Computational Creativity
and Games.
• Summerville, A., Guzdial, M., Mateas, M., and Riedl, M. O. (2016).
Learning player tailored content from observation: Platformer
level generation from video traces using LSTMs. In Proceedings of
the Twelfth Artificial Intelligence and Interactive Digital
Entertainment Conference.
45. References
• Shin, S. B., “Game Level Generation Using Neural Networks,”
Gamasutra.
https://www.gamasutra.com/blogs/SeungbackShin/20180227/31
5017/Game%20Level%20Generation%20Using%20Neural%20Net
works.php
• Karth, I., and Smith, A. M. (2017). WaveFunctionCollapse is
constraint solving in the wild. In Proceedings of the 12th
International Conference on the Foundations of Digital Games (p.
68). ACM.
• Karth, I., and Smith, A. M. (2018). Addressing the fundamental
tension of PCGML with discriminative learning. arXiv preprint
arXiv:1809.04432.