Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wall Building for RTS Games Patrick Schmid. Age of Empires.

Similar presentations

Presentation on theme: "Wall Building for RTS Games Patrick Schmid. Age of Empires."— Presentation transcript:

1 Wall Building for RTS Games Patrick Schmid

2 Age of Empires


4 Stronghold

5 Walls Barbed wire Fences Sandbags Force fields

6 Intelligent Wall Placement Locations to protect Use natural barriers Wall cost Distance from a given location Size of protected area

7 Possible Solutions Build rectangular wall Add walls to level via map editor Wall-building algorithm

8 Problem Definition Protect a given location by blocking the movement of enemy units Implies: –Block all access routes –No breaks

9 Preliminaries Restricted to tile-based maps Obstruction footprints confined to tiles Wall segment –Passive defensive structure –Blocks unit movement over a single tile Two wall segments are adjacent when they touch along the edges (not diagonals) Four adjacent wall segments (neighbors) for each free standing wall segment Each wall segment of a wall has two neighbors

10 Definitions A wall is a set of wall segments connected together in such a way that –Every wall segments has exactly two unique neighbors ( wall segments linked in circular fashion) –At least one interior tile (tile inside the walled- off area) –All interior tiles (interior area) are connected through edges (not diagonally).

11 Examples

12 Acceptance Criteria Minimum / maximum distance from location to protect Minimum / maximum number of interior tiles Maximum number of wall segments (cost of building wall)

13 Definition of Problem On a given tile map, build a wall that fits the definition, protects the given location, and meets the given acceptance criteria.

14 Wall-building algorithm Starting location (given) that needs to be protected Apply an initial wall around this location Move wall outwards greedily: remove an existing wall segment and place it in a different location, so that –Net gain of exactly one interior tile –Resulting wall still meets the wall definition Some moves might require addition of extra wall segments Stop when acceptance criteria are met

15 Possible wall segments

16 Possible moves

17 Does this work? Every group allows 17 possible moves = 68 possible moves Common patterns can be used to reduce number of cases Natural barriers act similarly to wall segments Natural barriers will greatly increase the number of possible moves Large number of moves

18 Is there a better way? Instead of expanding wall, expand interior area Once expansion is done, generate wall around interior area

19 Definitions Node = representation of the smallest area, e.g. a tile or a waypoint, that can be obstructed by the placement of game objects Graph with every edge connecting two nodes Edge defines path units can take Nodes sharing same edge are called adjacent

20 Definitions (cont.) A node can have any number of adjacent nodes A wall segment that is part of a wall still only has two neighbors Interior tile interior node Interior area set of interior nodes Starting location starting node Move process of adding new nodes to the interior area

21 New wall-building algorithm Start with starting node Expand interior area by adding one node per step Select the node to add using a greedy methodology ( heuristic function) Stop when acceptance criteria are met

22 Data structures Closed list –Nodes in the interior area Open list –Nodes bordering the interior area –Ranked by heuristic function –After node was moved to closed list, add new neighboring nodes


24 Traversal Function Get all successor nodes for a particular node Power to block individual node to prevent the interior area from spreading into undesirable areas Frequently used by heuristic function to get list of successor nodes for cost calculation

25 Heuristic Function f(n) is cost function representing the cost of adding node n to interior area c is a constant larger than the maximum possible distance from the starting node w(n) is the cost of walling off node n d(n) is the distance from node n to the starting node

26 w(n) Number of wall segments needed to keep the new node walled off from the outside area Only w(n) generates asymmetric walls stretching in only one direction –Why? –List of successor nodes tends to be arranged in a certain order. –Beginning of list gets preference over nodes with same cost further down the list –Leads to expansion in general direction of successor node at the top of the list

27 d(n) Add distance from starting node Maximize the minimum wall distance from the starting node for same wall cost good for defensive purposes Distance-related part has to be less significant than portion related to walling-off Achieve this by multiplying cost of walling off with the maximum distance (c)

28 Minimum distance Gives priority (0) to the nodes closer than the required minimum distance Need to adjust acceptance function to require that all nodes have reached minimum distance Used to protected important location, e.g. building, from enemy fire

29 What about natural barriers? Traversal has to ignore natural barriers Heuristic function needs to treat barriers as free wall segments and ignore them in the calculation of w(n) Efficient implementation: Change node traversal to ignore barriers

30 Map Edges? Inaccessible, maybe even permanent fog of war –Requires impassable terrain around them –Treated as natural barriers Embraced as part of game play –Traversal cannot find nodes past the map edges –Heuristic function has no cost for those nodes –Area past the edges treated as invisible natural barrier

31 Maximum Distance? Do not let open nodes at maximum distance become interior nodes Undermines functionality of open list! Introduce maximum distance list –Holds nodes located at max distance –Before adding a node to open list, check its distance –If equal to max distance, add it to max distance list –Upon completion, merge open and max distance list to get final solution Used to place wall within manageable distance, or ensure protective cover of tower fire

32 Doors and Gates? A wall without doors and gates is not that useful! Simply place gates at evenly spaced locations in the wall –Dumb solution –Might place a gate right in front of a natural barrier –Might not get us to all interesting locations Smart solution: Create paths from starting location to interesting outside locations. Where path and wall intersect, place a gate.

33 Diagonal Walls? Walls might be connectable diagonally Cost function needs to ignore cost of walling off a diagonal direction Diagonal successor nodes may not be added to open list

34 Demonstration

35 Actual Games Author of chapter (Mario Grimani) worked on –Age of Empires II: The Age of Kings –Age of Empires II: The Conquerors –Age of Mythology –Sovereign –Everquest II

36 Reference Mario Grimani – Wall Building for RTS Games. AI Game Programming Wisdom 2

Download ppt "Wall Building for RTS Games Patrick Schmid. Age of Empires."

Similar presentations

Ads by Google