rts presentation

59
RTS Presentation by Alex Dulmovits and Luis Villegas

Upload: tod

Post on 24-Feb-2016

51 views

Category:

Documents


0 download

DESCRIPTION

RTS Presentation. by Alex Dulmovits and Luis Villegas. History. History of RTS Games. History. Precursors to RTS Utopia (1982) Direct manipulation of unit and resources for combat Turn-based Legionnaire (1982) Real-time No resource or economy/production concepts. History. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: RTS Presentation

RTS Presentationby Alex Dulmovits and Luis

Villegas

Page 2: RTS Presentation

History

History of RTS Games

Page 3: RTS Presentation

History...Precursors to RTS• Utopia (1982)

o Direct manipulation of unit and resources for combat

o Turn-based• Legionnaire (1982)

o Real-timeo No resource or economy/production concepts

Page 4: RTS Presentation

History...First RTS Games• Dune II (1992)

Page 5: RTS Presentation

History...First RTS Games• Warcraft: Orcs & Humans (1994)

• Command and Conquer

• Age of Empires (1997)

• Starcraft (1998)

Page 6: RTS Presentation

History...Transition to 3D and Refinement• Total Annihilation (1997)

o 1st RTS with 3D elements

Page 7: RTS Presentation

History...Transition to 3D and Refinement• Empire Earth (2001)

o Researching techo Advancing Epochs

Page 8: RTS Presentation

History...Evolution of the RTS Formula• Sins of a Solar Empire (2008)

o Grand-Scale stellar empire building

Page 9: RTS Presentation

History...Evolution of the RTS Formula• Achron

o Time-travel elements

Page 10: RTS Presentation

History...Evolution of the RTS Formula• Halo Wars

o Modern RTS on a console

Page 11: RTS Presentation

Architecting an RTS AI

Page 12: RTS Presentation

RTS Game Components• Civilization• Build• Unit• Resource• Research• Combat

Page 13: RTS Presentation

Game Components: Civilization Manager• Highest-level manager responsible for

development of the computer player's economy

• Responsible for coordination between the build, unit, resource and research managers

• Responsible for spending limits• Computer player expansion, upgrading

and epoch advancement (EE)

Page 14: RTS Presentation

Game Components: Build Manager• Responsible for placement of

structures and towns• Receives requests from the unit

manager for training buildings• Receives requests from the civilization

manager for support buildings• All site evaluation occurs here

Page 15: RTS Presentation

Game Components: Build Manager• Where buildings can and cannot be

placedo RTS games restrict component placemento Red usually signifies invalid placement

Page 16: RTS Presentation

Game Components: Build Manager• Take "area of effect" buildings into

account• Buildings with an area of effect are

placed near resources, where most units are likely to congregate

Page 17: RTS Presentation

Game Components: Build Manager• Military Buildings

o Nearby resources, but shouldn't interfere with area of effect buildings

o Built in a ring around immediate area of resources

• Other Buildingso Farms, airports, walls, docks, towers require

specialized placementso Depends on terrain analysis engineo Place towers in choke points, avoid building

near enemies

Page 18: RTS Presentation

Game Components: Unit Manager• Responsible for training units• Keeps track of what units are in

training in various buildings• Monitors the computer player's

population limits• Prioritizes unit training requests

Page 19: RTS Presentation

Game Components: Unit Manager• If training building not currently

available, unit manager communicates with build manager

• Attempts to maintain a similar unit count to the human players in the game to balance difficulty of game

• By not allowing AI unit count to get too high, we lessen the CPU load of the game

Page 20: RTS Presentation

Game Components: Resource Manager• Responsible for tasking citizens to

gather resources in response from both the unit and build managers.

• Balances gathering duties • Governs the expansion of the computer

player to newly explored resource sites

Page 21: RTS Presentation

Game Components: Research Manager• Responsible for directed research of

computer player• Technologies are examined and

selected based on their usefulness and cost

Page 22: RTS Presentation

Game Components: Combat Manager• Responsible for directing military units

on the battlefield• Requests units to be trained via unit

manager• Deploys units in whatever offensive or

defensive position is most beneficial

Page 23: RTS Presentation

Game Components: Combat Manager• Keeps track of units via a personnel

manager• Periodically updates the status,

movement and actions of various attack groups

• Offense and Defense are sub-managers within the combat manager.

Page 24: RTS Presentation

Game Components: Combat Manager• Depending on what programming

language is used, the combat manager communicates with the other managers in different ways.

• In C++, with the managers implemented as classes, public methods can be used as a means to communicate.

Page 25: RTS Presentation

Game Components: Combat Manager• Example: TrainUnit method in Empire

Earth's Unit Managero Responsible for for bringing new units into the

worldo Parameters: unit type, number desired, where

is the unit required? (optional)o Communicates with Resource Manager to

ensure sufficient resources, checks population headroom, communicates with Build Manager if training building needed

Page 26: RTS Presentation

Game Components: Combat Manager• Example: TrainUnit method in Empire

Earth's Unit Managero Use training orders as a mechanism to

determine when the request was completeo Training Orders are simple classes that

contain information about the request and a method to call to check if and when something is complete

Page 27: RTS Presentation

Game Components: Combat Manager• RTS Combat AI Example

o Shogun 2

Page 28: RTS Presentation

Game Components• All the game components will be

communicating with each other• The problem comes when changing a

manager• Small changes have profound effects

on AI• AI becomes unpredicatable• Tracking down chains of cause and

effect becomes the focus of late development testing

Page 29: RTS Presentation

Difficulty Levels

Page 30: RTS Presentation

The Difficult Problem of Difficulty• Games are played by players with a

broad range of experience• Tailor games to fit level of competence

of player• Need to find a way for AI that can learn

from the player as it goes along• Settle for pre-set difficulty levels• Avoid just adding more computer

players for expert players. (more work for player and CPU)

Page 31: RTS Presentation

The Difficult Problem of Difficulty• Goal should be to develop an AI that is

good enough to give challenge to an expert player in a 1-to-1 match

• Then tone down AI for intermediate and beginners

• Hire expert players to help programmers do balancing

• More difficult to start with an easy AI and increase its intelligence

Page 32: RTS Presentation

The Difficult Problem of Difficulty• Choose what modifications to make to

differentiate difficulty levels (narrow down)

• The more variables you have, the harder it will be to test changes

• Testing difficulty level changes is very time-consuming

• Consider Cheating• Biggest Challenge: random maps

Page 33: RTS Presentation

Priorities in Goal-Based RTS AI

Page 34: RTS Presentation

Goal Engine Architecture• Responsible for making all strategic-

level decisions in the opposing player AI

• Decides what actions to take, where to take those actions, and what resources to apply to each

Page 35: RTS Presentation

Actors• Things within the game controlled by a

human or AI players• Buildings: immobile actors

o Defensive structures: can attack thingso Economic buildings: provide some nonmilitary advantage

• Units: movable actorso Military Units: can attack thingso Builders: construct and/or repair buildings

Combat Value (CV): numerical measureof an actor's effectiveness in a fight

Page 36: RTS Presentation

Goals• Used to represent every action a player can take

in the gameo attack, defend, explore, recruit, construct, and repair

• Influenced by resources (units, money)• Goal status: active/inactive/selected/finished• Base priority: priority of certain goal given the

current state• Current priority: takes into account resource

assignments as well as game state

Change of priority by red team: http://youtu.be/0b1uSwY48r0?t=3m23s

Page 37: RTS Presentation

Generating Goal Priorities (Part 1)• Common Tools: balance varying factors going into a priority

o Make more realistic/human- likeo Less predictable

• Multipliers• Exponents• Min. values• Max. values• Inversion• Bonuses• One-time Bonuses• Repeat penalties• Random Bonuses

• Fuzzy Factor: random bonus added to base priority of every goal• Goal Inertia: any bonus added to goals selected previously• Goal Commitment: even though requirements might not be met

at the moment, still selected

Page 38: RTS Presentation

Generating Goal Priorities (Part 2)• Money Value: AI needs to understand the value

of resources such as: gold, wood, iron, foodo How much? - More needed?

• Actor Value: the value of an actor plays a large role in the priority of a goalo Some considerations that affect the

determination of the actor priority• effect an actor has on the economy• the combat value of an actor• the strategic value of the actor's

position• the location in the AI's territory

Page 39: RTS Presentation

Generating Goal Priorities (Part 3)• Build Template: where buildings should be built with

respect to one anothero Bonuses for building certain buildings close to one another

• Map Analysis: spatial reasoningo Region: map split up into rectangles where units can move

freelyo Pathfinding: using pathfinding system, can calculate

distance between points which will encourage units to move to closer goals

o Military Influence: every actor adds an influence to the region they are in depending on their CV Equation:

Page 40: RTS Presentation

Attack Goal

• Attack goals are directed at an entire region• Base priority takes into account:

o maximum number of a player's CV in a certain regiono value that any capturable enemy actors would provide if they

were controlled• Current priority takes into account:

o CV ratio (ratio of friendly CV to hostile CV)o value of friendly CV in neighboring regionso whether or not there are known hostile units along path to

attack region

Page 41: RTS Presentation

Goal Based AI Conclusion

• Advantageso Flexible and powerfulo Complexity scales fairly well as AI growso Can execute more than one goal at a timeo Emergent behavior (to an extent)

• Disadvantages:o Priority calculations (“Bucket of Floats”)o Emergent behavior (becomes predictable)

Page 42: RTS Presentation

RTS Citizen AI

Page 43: RTS Presentation

Citizens

• Responsible for the building and gathering of resources within a town

• Usually low CV• Problem:

o Citizens can be instructed by player on what to do

o But after completing their task what do they do?

• Solution:o AI uses build and gather goals to

instruct when/where to build and gather resources

Page 44: RTS Presentation

Goals

• A player can give citizens high-level goals• A citizen accomplishes these goals by following

an FSM of varying actions• Citizens will continue their cycle of actions until

sent a trigger by the player which will cause them to move onto another action

Page 45: RTS Presentation

Building and Repairing

• When a player selects to create a building with certain citizens, the citizens must:o Establish a build site (location where the citizen is to position

themselves in order to build the building)o Find a path to the build siteo Begin to build the building (by gradually adding hit points to

it)o Once the building is complete, the citizen goes idle and waits

for next trigger from the player• For repairs:

o Similar to building, except the building location has already been determined

o Each hit point repaired to the building, cost the player resources

o If the player runs out of resources, the citizen goes idle

Page 46: RTS Presentation

Building and Repairing

• Build Site Selection:o must find a location around the desired buildingo must take other citizens' build sites into account

before determining theirs• Citizen Build Queues

o player can issue a queue of commands to a citizeno additional commands are added onto the back of

the queue• Three-Phase Building Construction

o Foundation: - must be cleared before construction begins

- when in construction does not block pathso Scaffolding: - stage during construction

- becomes visible to other players in range - more citizens working, the faster it is built

o Completed

Page 47: RTS Presentation

Gathering

• Citizens must gather resources from a resource unit (gold ore, trees, etc.) and bring to a storage unit (town center, mill, etc.):o A player gives selected citizens a command to gather a

certain resourceo Citizens pathfind to the resourceo They gather until their capacity is reachedo Then they locate the nearest storage unit and dump the

resources off adding to the player's totalo Repeat

• If a citizen can't find a resource unit or storage unit, it will become idle

Page 48: RTS Presentation

Citizen AI Example: Empire Earthhttp://youtu.be/GUWnK25BdJE?t=2m30s

Page 49: RTS Presentation

RTS Terrain Analysis

Page 50: RTS Presentation

RTS Terrain Analysis

• First need to know information about the terrain to determine what tactic the AI should perform

• Some questions that can be used to determine terrain information:o Are my troops in a single region?o Are there enemy forces in the same region as my troops?o Does my region have connections to others?o What regions have important strategic value?

Page 51: RTS Presentation

Geometric Terrain Analysis Approach• Uses Voronoi diagrams using geometric

information• Useful for dividing map into different areas which

can later be classified by an algorithm• Drawbacks:

o doesn't take into account changing map features (such as water and land)

o provides no information about strategic value of areaVoronoi diagram of obstacles consists of a set of points which are equidistant from two or more distinct obstacles

Created from 2D Segment computer programs

Page 52: RTS Presentation

Pathfinding Simulation Analysis Approach• Attempts to find important paths on map• Useful to help determine paths and avenues of

approach that are most likely to be used• After a pathfinding technique is used, determines

the paths that were travelled the mosto Higher concentration of paths = more

important the location is• Drawbacks:

o No information about logical areaso No information about connectionso No information from the paths about which of

their waypoints are important

Page 53: RTS Presentation

Combined Approach

• Both Geometric Terrain Analysis and Pathfinding Simulation Analysis Approaches have drawbacks

• Use a combination of the two approaches• Geometric Terrain Analysis

o Used to detect logical areas and their connections

• Pathfinding Simulation Analysiso Determine the importance of paths

Page 54: RTS Presentation

Basic Concepts

• Passability Map: map that shows what regions are passableo Black pixels: represent passable areaso White pixels: represent impassable areas (slope too steep or

river)o Bridges displayed since they affect passabilityo Other buildings or trees not included

• Regions: passable areas surrounded by impassable terrain or regions of different typeo Game zones: broad, open passable areaso Chokepoints: narrow corridors between game zones

• Connections: logical links between chokepoints and game zones

• Hotspot: best position to defend a game zone from attacks coming through a particular chokepoint

Page 55: RTS Presentation

Terrain Analysis Algorithm

• Noise Reductiono Cleans passability map

Removes small islands or pockets of impassable terrain that produce useless divisions

o Selects zones of impassable terraino Fills small areas with black pixels

• Random Pathfindingo Takes information of terrain heightmap and pathfinding

data Finds most likely used paths by enemy

o Calculates a large number of random paths and stores them

Page 56: RTS Presentation

Terrain Analysis Algorithm

• Iterative Image Processingo Takes in a clean passability mapo Generates an output image on which each region

is clearly marked by different colors:• passable terrain• impassable terrain• game zone• choke point

• Combining Image Processing and Pathfinding Datao Computes a hotspot for each connection between a

chokepoint and game zoneo Returns list of game zones connected by the chokepointo Returns hotspot for each chokepointo Direction from the hotspot to the game zone connected to it

Page 57: RTS Presentation

Terrain Analysis Depiction

1. Select impassable terrain2. Expand selection3. Invert selection4. Fill (Free spaces)5. Expand selection 6. Invert selection7. Deselect impassable8. Fill (Choke points)

Page 58: RTS Presentation

Terrain Analysis Conclusion: Use of Map Information• AI system can use this knowledge to help defeat the

enemyo Properties of each regiono Which areas contain allied and enemy unitso Hotspots: which connections must be defended or attacked

depending on enemy positiono Direction of hotspot: where to place units at appropriate

locations relative to the connectiono Weighting information: which regions and connections are

most important

Page 59: RTS Presentation

Conclusion

Recap:• History• Architecting an RTS AI• Difficulty Levels• Priorities in Goal-Based RTS AI• RTS Citizen AI• RTS Terrain Analysis

The future of RTS games/graphicsTotal War: Shogun 2http://youtu.be/RgglJXnjNe4?hd=1&t=36s