Automatic generation and maintenance of maps and walls.

Slides:



Advertisements
Similar presentations
Artificial Intelligence in Game Design
Advertisements

Wall Building for RTS Games Patrick Schmid. Age of Empires.
Heuristic Search techniques
AI Pathfinding Representing the Search Space
Artificial Intelligence Presentation
Traveling Salesperson Problem
Chapter 4: Trees Part II - AVL Tree
Label Placement and graph drawing Imo Lieberwerth.
NUS CS5247 Motion Planning for Camera Movements in Virtual Environments By Dennis Nieuwenhuisen and Mark H. Overmars In Proc. IEEE Int. Conf. on Robotics.
Pathfinding Basic Methods.
CSE 380 – Computer Game Programming Pathfinding AI
Fixed/Variable Partitioning
Generated Waypoint Efficiency: The efficiency considered here is defined as follows: As can be seen from the graph, for the obstruction radius values (200,
Artificial Intelligence in Game Design Introduction to Learning.
Review: Search problem formulation
1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
1 Chapter 4 Search Methodologies. 2 Chapter 4 Contents l Brute force search l Depth-first search l Breadth-first search l Properties of search methods.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
CSE 830: Design and Theory of Algorithms
Intelligent Agents What is the basic framework we use to construct intelligent programs?
File Management.
Routing 2 Outline –Maze Routing –Line Probe Routing –Channel Routing Goal –Understand maze routing –Understand line probe routing.
Chapter 5.4 Artificial Intelligence: Pathfinding.
Chapter 2: Algorithm Discovery and Design
Alexandria Soccer Association U9-U12 Curriculum: Unit 1
CORE MECHANICS. WHAT ARE CORE MECHANICS? Core mechanics are the heart of a game; they generate the gameplay and implement the rules. Formal definition:
The Greedy Wall Building algorithm Rami Khouri. Ideal definition of Wall Either keeps valuable assets in, or enemies out…mostly keep enemies out Impassable,
Artificial Intelligence in Game Design Camera Control.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
CHP - 9 File Structures. INTRODUCTION In some of the previous chapters, we have discussed representations of and operations on data structures. These.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
Chapter 5.4 Artificial Intelligence: Pathfinding.
Genetic Algorithm.
1 State Space of a Problem Lecture 03 ITS033 – Programming & Algorithms Asst. Prof.
Slides are based on Negnevitsky, Pearson Education, Lecture 12 Hybrid intelligent systems: Evolutionary neural networks and fuzzy evolutionary systems.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
WAES 3308 Numerical Methods for AI
Representing and Using Graphs
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
Z-Town Technical Details Ben Trivett, Drew Switzer, Cameron Jett, Ryan Southard Department of Computer Science and Engineering The Ohio State University.
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
Motion Planning in Games Mark Overmars Utrecht University.
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
Artificial Intelligence in Game Design Content Generation.
University of Windsor School of Computer Science Topics in Artificial Intelligence Fall 2008 Sept 11, 2008.
FORS 8450 Advanced Forest Planning Lecture 11 Tabu Search.
For Monday Read chapter 4, section 1 No homework..
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
WORLD NAVIGATION Don’t Fall Asleep Through These Topics  Tile Graphs  Points of Visibility  NavMesh  Path Smoothing  Hierarchical Pathfinding.
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
Random Map Generation and Transport Unit AI for Strategy Games By Russell Kuchar.
KEYS Scott Gajewski ART 389A Spring Contents Premise Getting Started -Players -Set-up -Materials Rules -Basics -Points System -Multiple Players.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Chess Strategies Component Skills Strategies Prototype Josh Waters, Ty Fenn, Tianyu Chen.
Artificial Intelligence in Game Design Influence Maps and Decision Making.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
CSCE 552 Fall 2012 AI By Jijun Tang. Homework 3 List of AI techniques in games you have played; Select one game and discuss how AI enhances its game play.
1 CO Games Development 2 Week 13 Influence Maps Gareth Bellaby.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Chapter 5.4 Artificial Intelligence: Pathfinding
CHP - 9 File Structures.
Heuristic Search Introduction to Artificial Intelligence
CIS 488/588 Bruce R. Maxim UM-Dearborn
Fundaments of Game Design
Presentation transcript:

Automatic generation and maintenance of maps and walls

Content Overview  Generating maps What do we want in a map? Warcraft 3 map editor RTS maps for Empire Earth  Wall Building Generating intelligent barriers  Populating large worlds using limited resources The Waterfall Algorithm

Generating an RTS map

RTS Map Generation: Overview  Place players on the map first  Grow land for each player  Land that has not been allocated is considered water  Analyze terrain and add features  Place resources around players fairly

Scripting for variety  Scripts are used to specify map parameters such that they can be modified quickly without programmer intervention  For example: number of resources per player maximum height of land player land allocation climate

Player placement - Step 1  Inscribe a large disk on the map Inner and outer radii can be set in a script

Player placement - Step 2  1 random point for each player is chosen within the disk; closest points are pushed apart  Closest points are pushed apart iteratively until distribution is satisfactory

Player placement – Step 3  If the game has teams, they are assigned to adjacent player locations

Back it up - dummy players  Player locations will have allotted flat land and resources  We may want other areas of the map to also have these properties for player expansion

Where to put land?  This process is centered around the positions of the players which have just been determined  Why? Land is a very important resource in RTS games: Exhibit AExhibit A  Each player must receive an equal amount of buildable land

Growing land: Clumps  Land is grown in around players in “Clumps”  Attributes of clumps can be set, such as: clump size, number of clumps per player, chaos level  Clumps grow (consume tiles) until they reach the predetermined size  When a clump is completed, a new clump is created a random distance and angle away until the number of clumps required are generated

Two methods for growing clumps  Completion Method: One clump is grown to completion before another is started  Step Method: Grows clumps one tile per iteration. This method is used to lay out each players’ land.

Keeping track of clumps  A 2-D array of all the tiles on the map is initialized such that all tiles are water  When a land clump is grown, it changes the value for its tile in the array to indicate that the tile is part of a land clump  When a land clump is grown for a player, the player’s enumerated value is placed into the land-water array

Different Map Types  Island Map: Require a new land tile for a player is not within some tile distance from another player’s land  Land Map: Allow players’ land to be adjacent to an enemy player’s land

Flat Clumps  While each player has been allocated an equal amount of land, nothing has been set about the conditions on the land  To ensure that each player has the same amount of buildable land, a subset of their land clumps are “Flat Elevation Clumps”  Flat Clumps are grown using the completion method and can only grow in a player’s existing land

Adding interesting terrain  Terrain can be generated using Fractals – “The Diamond-Square Algorithm”The Diamond-Square Algorithm

Resource Allocation  Resources are placed on the map on a per- player basis  Placed within rings centered on a player’s starting location (number of resources and size of ring are attributes which can be changed with scripts)  For a particular resource, random locations in the ring are tried until an acceptable location is found  Why might a location be unacceptable? Cannot be placed on a certain terrain Must have a minimum distance to other resources Cannot be too close to the player’s start location

What about the trees?  Trees are placed last because they are plentiful and restrict path finding.  Forest size, number of forests per player can be specified as attributes  Forest growth is not restricted by the players’ land boundaries (unlike most other resources)  Another type of clumps, “treeClumps” are used to grow forests  Forests cannot grow near other forests, and some areas are marked as forest-free

Flaws with this algorithm  High processing times  No ability to add specific terrain features  Often resulted in maps in which players had vastly different choke points, or even no access to other players  Resource placement system often created a resource advantage for certain players  Example of what these maps look like Example of what these maps look like

Building Walls  Many RTS games allow the player to build walls to impede enemy mobility, so AI players must be able to as well  A good wall building algorithm can make NPC opponents much more formidable  In games with a map editor, an automated wall building feature would make a level designer’s job easier

Defining a Wall  A wall segment is a passive defensive structure which blocks movement over a single tile which it occupies  Wall segments are adjacent if they touch along the edges (not diagonals)  A wall is a set of wall segments which Every wall segment has two adjacent wall segments There is at least one interior tile All interior tiles are connected through edges

To be crystal clear…

Greedy Algorithm  A greedy algorithm is one that always takes the best solution at the time  Must define a heuristic to determine how favorable a given action is  Always choose the solution with the lowest / highest value from the heuristic (depending on how your heuristic is defined)  Disadvantage: There is no guarantee that the overall solution will be optimal even if each step was optimal

Approach #1- Build Wall  Given a starting location which you would like to protect with the wall  Create a simple small rectangular wall directly surrounding the starting point  Using a series of moves, expand the wall until it meets the desired properties  Each “move” moves the interior space outward such that exactly one more tile is walled off and the new wall still meets our wall definition

Analyzing Permutations  In order to decide which move is best, we must consider all permutations  Each 3x3 square generates 68 permutations.  Once all permutations have been determined, calculate their heuristic value (in this case, how many wall segments must be added to accommodate including the interior node)  Option with the lowest cost is chosen

What about natural barriers?  Excellent question!  Natural barriers would create many more permutations, to the point where we are forced to ask the question, “Isn’t there a more efficient way to do this?”  The solution lies in realizing that there is a one-to-one relationship between a wall and the interior space protected by the wall

Paradigm shift  Instead of building the wall, we concentrate on building the space within the wall  We still start with the starting node from before (the location we’d like to defend)  The “move” described before simply becomes adding another tile to the interior space (using the same greedy algorithm)

Managing the nodes (tiles)  Closed list – the list of nodes that have been selected to be in the interior space  Open list – the list of nodes that are candidates for inclusion in the closed list (on the border)  On each iteration, the nodes on the open list are inspected, and the best candidate is moved to the closed list  This process is repeated until the desired size is achieved  Upon completion, the open list becomes the list of tiles on which to build the wall

Pseudocode

Keys to this algorithm  Traversal Function: for a given node, determine successor nodes (that become members of the open list)  Acceptance Function: determines whether or not the current wall is acceptable (# of nodes on the closed list, etc)  Heuristic Function: ranks open nodes, and thusly controls the shape of expansion. Must attempt to maximize area walled off while minimizing cost to do so

More on the Heuristic  Simply using the cost to include a node tends to result in asymmetric walls which stretch in one direction.  To correct this behavior, we add a term to the heuristic equation which increases the cost of nodes proportionally to their distance from the start node.  However, we must ensure that the distance does not out-weigh the cost of building  This results in a formula of this form f(n) = c * w(n) + d(n)

What about natural barriers?  This algorithm allows us to easily incorporate the possibility of natural barriers with some modifications  Traversal Function: must be changed to ignore natural barriers when looking for nodes to include  Heuristic Function: must consider natural barrier nodes to have no cost when considering including the bordering nodes in the open set  With these modifications, the algorithm takes advantage of natural barriers and tries to use them as free walls

Min/Max Distance Requirements  Minimum Distance: We may want to ensure that no wall segments are within a certain distance from the starting node. To accommodate for this, set the heuristic value (cost) of all nodes within the minimum distance to 0.  Maximum Distance: This can be done by monitoring the inclusion of nodes on the open list. If the node is at the maximum distance, add the node to a maximum distance list instead of the open list. Upon completion, we must merge the open list with the maximum distance list to get the full wall

Doors and Gates  We may want to have the ability to move friendly units in and out of the walled area  Brute force method: place openings randomly or at fixed intervals  More sophisticated: create paths (using A*) from starting node to all locations of interest outside the walls. Intersections between these paths and the wall are logical locations for doors

Diagonal Walls  With a few modifications, this algorithm can be adapted to games which do not allow diagonal movement  Heuristic: Cost function must ignore cost of walling off diagonally  Traversal: Ensure diagonal successor nodes are not added to the open list

Populating Large Worlds  Many actors in a large world map can consume an inordinate amount of resources  “Waterfall concept” helps to alleviate pressure on system resources  General idea is to devote the most system resources to units closest to the player, and limit actions of those far away.

Five Functional Components 1. The Context 2. The Character 3. The Personality 4. The Director 5. The Manager  Each of these is represented as a class in the architecture’s implementation

The Context  The “soul” of the AI  Set of all essential variables and data required to represent the state of an agent Is the agent currently active? Visual representation being used State of thought process  Information is used by the Character class to affect agent behavior

The Character  Takes an instance of Context and uses the data contained therein to generate input for the agent- causes it to behave in a certain manner  Can be thought of as a script for the role the agent is playing  Will be sub-classed to generate a range of behaviors

The Personality  Allows multiple agents with the same Character to act in slightly different ways Example: if an agent drives a vehicle ○ Character: Agent drives fast ○ Personality: provides a range from which the Character provides a range of minimum speed values  Ensures that agents are unique

The Director  Responsible for determining when agents fall in and out of the waterfall based on a complex set of rules This helps maintain the illusion of a world teeming with active agents  Also chooses which Character an agent should use when it falls back into the “waterfall”

The Manager  Holds, instantiates, updates, renders, and destroys all AI agents  These functions could be absorbed into the Director if desired, but separating them eases management and encapsulates functionality  Deals with the physical aspect of AI: instantiates visual and functional piece of the game the user sees

Mechanics  Director determines if the Context needs to exit the waterfall If yes, a new location is chosen for the Context, and agent is placed there If not, a Character is chosen for the Context and the Context is assigned to a Character

Mechanics cont…  Next, the Character is allowed to operate on the Context Path information Collision information Friend / foe information  Character never directly moves the agent; it leaves ‘suggestions’ the agent can use to affect its physical representation  The Director then determines if the agent has left the waterfall

Flow of the Waterfall  Purpose is to focus on the most interesting AI activity close to the player  Agents that have “exited” the waterfall may be recycled into a visible position or replaced with other agents  Most effective in a game where the player moves at a steady predictable rate  There must be a well-defined set of rules for when agents will enter and exit the waterfall

Exit Rules  Dependant on the type of game and visibility / line-of-sight distances (the shorter these distances, the better the system will work)  Examples of exit rules The agent is farther than a certain distance away The agent is behind the camera for a certain amount of time The agent is outside the view cone for a certain amount of time

Entry Rules  Where to spawn the agent? Very specific to the player’s location, movement, viewing direction Some example rules ○ Enter agents behind the player, speed them up so they pass the player ○ Enter agents just out of player’s view distance ○ Enter agents into predetermined locations in anticipation of player’s arrival  What type of Character to spawn? Are there too few agents with this Character in the Waterfall? Are agents of this Character relevant to the game in the player’s current situation? E.g. more cops if the player is doing something illegal

Optimization  Just don’t do it If an agent too far away or occluded, turn off unnecessary functions (animation, collision checks)  Do it, but only so often Some things can be done just once in a while (update pathfinding, searching for downhill direction, other long searches)

Summary  Map Generation: Algorithm described can create some good maps, but still has its flaws  Wall Generation: good walls can make an AI opponent more formidable; the algorithm described here adapts to natural barriers and makes player-like walls  Resource management: On a large map, you can’t afford to have all AI agents perform all of their actions all the time. The Waterfall algorithm can help alleviate pressure on processing time

Questions?