The Greedy Wall Building algorithm Rami Khouri. Ideal definition of Wall Either keeps valuable assets in, or enemies out…mostly keep enemies out Impassable,

Slides:



Advertisements
Similar presentations
Artificial Intelligence in Game Design
Advertisements

Wall Building for RTS Games Patrick Schmid. Age of Empires.
Algebra Tiles!.
Heuristic Search techniques
Lecture 15. Graph Algorithms
Problem solving with graph search
AI Pathfinding Representing the Search Space
§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
Joining LANs - Bridges. Connecting LANs 4 Repeater –Operates at the Physical layer no decision making, processing signal boosting only 4 Bridges –operates.
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Multi-tiered AI Patrick Schmid. Multi-tiered AI We already saw a presentation about this topic Remember Ke‘s presentation? Short recap.
Automatic generation and maintenance of maps and walls.
DEFENSIVE POSITIONS.
CSE 380 – Computer Game Programming Pathfinding AI
Generated Waypoint Efficiency: The efficiency considered here is defined as follows: As can be seen from the graph, for the obstruction radius values (200,
Structures and Strategies- Basketball Key Concept 2- Identification of strengths and weaknesses in performance in terms of: roles and relationships; formations;
What is the Best Position? More Advanced Positioning February, R. Baker1.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Chapter 23 Minimum Spanning Trees
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Tirgul 13. Unweighted Graphs Wishful Thinking – you decide to go to work on your sun-tan in ‘ Hatzuk ’ beach in Tel-Aviv. Therefore, you take your swimming.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Routing 2 Outline –Maze Routing –Line Probe Routing –Channel Routing Goal –Understand maze routing –Understand line probe routing.
Tactical AI in Real Time Supervisor: Aleks Jakulin Crew: Damir Arh, Matija Jekovec, Mitja Luštrek Gregor Leban, Martin Žnidaršič, Uroš Čibej Translation:
Alexandria Soccer Association U9-U12 Curriculum: Unit 1
Informed Search Idea: be smart about what paths to try.
1 GRAPHS - ADVANCED APPLICATIONS Minimim Spanning Trees Shortest Path Transitive Closure.
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
1 Game AI Path Finding. A Common Situation of Game AI A Common Situation of Game AI Path Planning Path Planning –From a start position to a destination.
Geography and CS Philip Chan. How do I get there? Navigation Which web sites can give you turn-by-turn directions?
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Civ89 Instructions for PowerPoint. Getting Started Civ89 is a game of military, technological, and economic conquest played with two people, identified.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
Introduction to AI Engine & Common Used AI Techniques Created by: Abdelrahman Al-Ogail Under Supervision of: Dr. Ibrahim Fathy.
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
Shortest Path Problem Weight of the graph –Nonnegative real number assigned to the edges connecting to vertices Weighted graphs –When a graph.
Ch 7.2: Performing Qualitative Terrain Analysis in MoO3.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Toward More Realistic Pathfinding Authored by: Marco Pinter Presentation Date: 11/17/03 Presented by: Ricky Uy.
Random Map Generation and Transport Unit AI for Strategy Games By Russell Kuchar.
Ricochet Robots Mitch Powell Daniel Tilgner. Abstract Ricochet robots is a board game created in Germany in A player is given 30 seconds to find.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
Graphs Upon completion you will be able to:
Artificial Intelligence in Game Design Influence Maps and Decision Making.
CSCE 552 Spring 2010 AI (III) By Jijun Tang. A* Pathfinding Directed search algorithm used for finding an optimal path through the game world Used knowledge.
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Beard & McLain, “Small Unmanned Aircraft,” Princeton University Press, 2012, Chapter 12: Slide 1 Chapter 12 Path Planning.
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
All-pairs Shortest paths Transitive Closure
BackTracking CS255.
CSC317 Shortest path algorithms
Lesson Objectives Aims Understand the following “standard algorithms”:
Artificial Intelligence Problem solving by searching CSC 361
Selection CIS 40 – Introduction to Programming in Python
A* Path Finding Ref: A-star tutorial.
CSE 373: Data Structures and Algorithms
3. Brute Force Selection sort Brute-Force string matching
Conquer the Castle 2D Game Design Pitch.
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
3. Brute Force Selection sort Brute-Force string matching
Informed Search Idea: be smart about what paths to try.
Graphs.
Informed Search Idea: be smart about what paths to try.
3. Brute Force Selection sort Brute-Force string matching
Presentation transcript:

The Greedy Wall Building algorithm Rami Khouri

Ideal definition of Wall Either keeps valuable assets in, or enemies out…mostly keep enemies out Impassable, or slows down opponents in vulnerable positions –Every wall segment has two unique neighbors –Contains an interior protected area –All interior areas are connected through a path

These are not walls Exceptions: Some games will connect blocks on diagonal spaces together, While other games use gates to allow subdivision of inner area. The greedy algorithm is NOT concerned with creating an inner wall.

Greedy Algorithm A plan that takes steps for the best immediate gain…do not plan ahead into the future moves Dijkstra’s Shortest Path is an example of Greedy algorithm that gives optimal results In the case of building a wall, Greedy algorithm does not provide optimal results, but good enough for use.

Basic Premise of Greed… We will try to “push” the walls outward by expanding at the edges Each move is to expand a wall to incorporate one, and only one new space. Moves cannot break the definition of wall as seen earlier – we are always protected

Problem with This Paradigm To push the wall outward, we must have a case for every possible wall configuration. 68 cases if tiles are squares, much more if tiles are hexagonal, more if their octagonal Special cases if the wall is adjacent to a natural barrier. –Thinking of the problem in terms of pushing the wall is complex

Change the paradigm Instead of pushing the walls, expand the inner area Represent the tiles as vertices, and connections between tiles as edges –Now we can have as many edges as we want coming out of a node –We can represent indestructible natural barriers as the absence of an vertex/edge

So how do we apply the algorithm? Keep three lists: –List of all nodes & edges, graph –Closed list: all nodes in the interior space of the wall –Open list: all nodes that are candidates for expansion, in practice this is the perimeter of the enclosed area, i.e. spaces that the wall is occupying Closed Open Graph

List OpenList, ClosedList, Graph WallBuilder (Node Start, Criteria Accept){ While (OpenList != empty && Accept != criteria){ if ( bestChoice.Cost <= affordable){ remove bestChoice() from openList add bestChoice to closedList for each Neighbor of BestChoice(){ if (not in closedList or openList) {add to openList/Build wall on it} }

How to pick the best choice? Pick the move with the highest value and lowest cost. In this case, Value is always 1, so lets worry only about the cost: –Cost of a move is how many wall constructions it would take to seal it from the outside: This is the number of nodes it connects to that are not in the open or closed list Lets call this w(x); for any node x

Demo1 Run Demo1

So now we have Cost(n) = w(n); But now lets extend it to take into account that we want to wall in closer nodes first d(n) = value based on distance, –closer = lower c is a constant higher than max d(n) Cost(n) = c * w(n) + d(n)  what is the effect of this formula in English

Lets extend Cost(n) = 0 if d(n) < minimum distance Cost(n) = infinity > maximum distance Cost(n) = c * w(n) + d(n) Natural barriers have a cost of zero if toughness => walls

Demo2 Run Demo 2

What happens here?

Gates Draw a path to areas of interest (resources or enemy strongholds) On each path place a gate. Gates within a certain distance of each other can be combined

Hierarchy in Strategy Games Division of tasks Maps Message Sending

Demo 3

Without subdivision, movements such as “Human Wave Attacks” are simple: All soldiers: Attack Point (X,Y)” But more complex commands, such as pincer movement, flanking..etc are much harder to implement: Soldier 1 “I am closest to east side, but are there already enough people on that side? Let me ask each soldier and make sure they don’t have too many….etc”

Realistic Solution Army Corps Division Corps Division Brigade Battalion Company Platoon Squad Soldier

Using a realistic solution, we can divide troops into subgroups…troops, squads, platoons…etc. Creating a level of abstraction between the player and individual troops, a concept often used in OOP programming Squad A attack left side Abstracts: soldier move left, then attack from left …… soldier move left, then attack from left

Levels of Hierarchy Unit AI: –Soldier, Tank, Helicopter…etc –Short distance path finding –Report events to Squad –Accept Attack & Move commands Some freedom is given in how to execute move and attack (touched on later)

Element Map: view of unit Unit sees individual elements of the map i.e. soldier will see –A tree –A rock –A destroyed tank –An enemy sniper Soldier know how to select their own targets and engage, and to find strategic locations within a small area when told to attack or support

Squad Interpret commands from higher level (platoon) and send to individual soldiers Set checkpoints for individual soldiers to follow, higher level path finding Maintain reasonable formation, track each unit Receive feedback from units, and move them back up to platoon  move and attack to units. Backup units in need of help

Tile Map: Squad view A Squad can see its own individual troops in detail, but abstracts enemy troop data i.e. enemy attack & Defend Squad abstracts attributes of terrain, i.e. mobility rating, defensive rating, connection to other tiles Defense: 2 Offense:3 Mobility: 4 Cover:5 Defense: 2 Offense:5 Mobility: 7 Cover:2 Defense: 1 Offense:1 Mobility: 10 Cover:0 Defense: 0 Offense:0 Mobility: 10 Cover:1

Platoon Interpret commands from higher level and translate them to squad instructions Platoon movement is handled by setting checkpoints for each squad in a path to destination – let squad handle smaller pathfinding Keep track of squads, interpret messages i.e. squad Strength, encounter enemy, losing fight…etc. Coordinate backup and formation Pass information up to higher levels (Engaging enemy, need backup, need reinforcement…etc)

Tile Map: Platoon view See individual squads of self Abstract enemy values Abstracts attributes of terrain, i.e. mobility rating, defensive rating. Connection to other tiles is most important Basically a continuation of map abstraction from unit to squad, to Platoon Defense: 2 Offense:3 Mobility: 4 Cover:5 Defense: 2 Offense:5 Mobility: 7 Cover:2 Defense: 1 Offense:1 Mobility: 10 Cover:0 Defense: 0 Offense:0 Mobility: 10 Cover:1 Artillery: 14 Speed: 10 Small Arms: 7

Computer Player AI Civilization building –Economics –Technology Building Military Set policy towards neighbors –Offensive/Defensive/Alliance

CPAI map Highest level map. See strength and weakness of enemy See Resources within an area Only pathfinding necessary is “does a path exist”

Interesting Concept! Give commanders of troops personalities! Tactics vary from defensive, aggressive, merciless, highly strategic…etc civilization series, Command & Conquer Generals

Gold:104Offense: 19 Oil:78Defense: 21 Disposition: Friendly Gold:67Offense: 15 Oil:44Defense: 17 Disposition: Hostile Gold:104Offense: 19 Oil:78Defense: 21

SQUAD PLATOON Computer PlayerUNITDefend Path Defend Path (middle) Defend Location Ready Enemy spotted All Units AttackEngaging enemy Back up squad engage Engaging enemy Hold Platoon formation