class: center, middle # AI in Digital Entertainment ### Terrain Generation --- class: center, middle # Terrains --- # Terrain Generation * Say we have a 3D game where you visit a variety of islands * We want to generate each island procedurally * How do we do that? --- # Terrain Representation * For now, let's ignore caves * Each island is a 2D surface in 3D space * We can "just" store (and generate) the height value for each point * However, that will still be way too many values, so we use a grid instead --- # Grid-based Heightmap
--- # Bilinear Interpolation Artifacts
--- # Bicubic Interpolation
--- # Bicubic Interpolation
--- # Spline Interpolation
--- class: center, middle # Noise-Based Terrain Generation --- # Noise-Based Terrain Generation * What is noise? Random numbers (more or less) * So, let's generate a terrain by picking height values at random * What could possibly go wrong? --- # Random Terrain
--- # Difference-Based Terrain Generation * When we just pick random numbers, adjacent grid cells may have very different values * This will lead to a very rugged looking terrain * What would be more realistic? Don't let the height values *change* between adjacent vertices arbitrarily * Instead, use the existing values of the neighbors, and *add* a small difference value --- # Difference-Based Terrain
--- # Perlin Noise Terrain Generation * The terrain already looks a lot better, and we may control how rugged it looks by controlling how much the difference can be at most * It could be smoother, though! * Idea: Instead of controlling the difference between heights, we control the difference of the difference in height, or rather: We generate a smooth derivative * Perlin Noise uses this idea! --- # Perlin Noise Terrain
--- class: center, middle # Agent-Based Terrain Generation --- class: medium # Agent-Based Terrain Generation * Instead of generating the entire terrain at once, it may be worthwhile to divide the task into smaller subtasks * We can then implement an agent for each subtask * What is the general process of creating landscapes? - Coastline generation - Landform generation - Erosion --- class: medium # Coastline Generation * Coastline agents draw the outline of the landscape * Generation starts with one agent that splits until each agent is responsible for a small enough part of the map * Within this part, the agent determines random points, using attractors and repulsor points for the coast line * The agents work concurrently on different parts of the map * When the agents finish, smoothing agents wander around and change the elevation of nodes according to their neighbors --- # Coastlines
--- class: medium # Beaches and Mountains * Beach agents wander around the parts of the map that are close to sea level * They may create beaches by flattening the land * Likewise, mountain agents wander the parts of the map that are above a certain height level * When they find such spots, they may increase the height to create mountains * They will wander in a certain direction to create a ridge, with a chance to turn * After beaches and mountains are created, the landscape is smoothed again --- # Beaches and Mountains
--- # Rivers * After beaches and mountains are created, it is time to make rivers * For each river, a start-point in the mountains, and an end point on the coast are determined * An agent starts at the end-point and tries to wander uphill towards the start-point * If they succeed, they then go back downhill and dig a bed for the river --- # Rivers
--- # Agent-Based Terrain Generation * Each agent has several parameters that determine how it generates "its" feature * By varying these parameters, different types of landscapes can be generated * For example, the mountain agent creates ridges, but turns with a certain probability. Changing this probability controls how straight mountain-ridges will be * The number of agents of each type also dictates how prevalent each feature is --- class: center, middle # Cellular Automata-Based Terrain Generation --- class: small # Cellular Automata * Cellular Automata are zero-player games on a grid * The basic idea is: Every cell has some states (sometimes just "on" and "off"), and there are rules for how to update the grid * Most famous Cellular Automaton rules: Conway's Game of Life - If a cell is "on" and has two or three (of its eight) neighbors that are also "on", it will continue being "on", otherwise it is turned "off" - If a cell is "off" and has exactly three (of its eight) neighbors that are "on", it will turn "on", otherwise it stays turned "off" --- # Cellular Automata
--- class: small # Cellular Automata * How is this useful? * Different rules make different shapes! * Let's say we want to generate caves: - Fill the grid randomly with "on" and "off" cells - A cell is turned "on" if five or more of its neighbors are "on" - Run for a number of generations --- # Cellular Automata
--- # Cellular Automata Terrain Generation * We can also interpret our states as "lower" and "raise" terrain * The rules determine how much raised/lowered neighbors influence a cell to be raised/lowered * The terrain output also depends on how many generations we run * Alternatively: Each state determines the "type" of terrain of a larger map fragment (beach, mountain, plains, etc.) --- # Cellular Automata Terrain
--- # Next Week * Project Presentations * Keep your presentation to about 15-20 minutes --- class: center, middle # Conclusion --- # Conclusion - It was the first time I taught this class, I enjoyed it a lot! - I hope you enjoyed taking it, too - Y'all were a great audience! - I hope you all had fun with your projects - If you are interested in pursuing research around game AI (in Costa Rica or elsewhere), come talk to me! --- class: small # My Research - I am currently working on non-verbal communication in video games - For example, how can an AI agent use facial expression analysis to understand a human player better - We're also looking at the timing of actions, and eye tracking - Currently our applications are cooperative games, such as Hanabi or Pandemic - I'm interested in AI for games that plays with human players - If you're interested in working with me, come talk to me! --- # My previous research: One Night Ultimate Werewolf
--- # My research: Hanabi
--- # My student's research: Pandemic
--- # Feedback - If there is an official evaluation, please participate - You can also let me know if there is anything you particularly liked/disliked (for example by posting anonymously and/or privately on Piazza) - What was your favorite/least favorite part of the class (if you want to share)? --- class: center, middle ## Thank you all for your participation! --- class: small # References * Chapter 4 of [Procedural Content Generation](http://pcgbook.com/) by Noor Shaker, Julian Togelius, and Mark J. Nelson (free PDF available) * [Controlled Procedural Terrain Generation Using Software Agents](http://larc.unt.edu/ian/pubs/terrain.pdf), by Jonathon Doran and Ian Parberry * [Cave Generation with Cellular Automata](https://www.raywenderlich.com/2425-procedural-level-generation-in-games-using-a-cellular-automaton-part-1) * [Algorithmic Terrain with Cellular Automata](https://demonstrations.wolfram.com/AlgorithmicTerrainWithCellularAutomata/) Wolfram Alpha Demonstration Project * [Generating Terrain with Cellular Automata](http://ideabyre.com/world-building/erosion/erosion_model)