36
Announcement Mr. Todd Howard Design, Director and Producer at Bethesda Game Studios will be speaking about the 'Future of Commercial/Entertainment Video Games'. October 8th @ 7:00PM in Harris Theater

Announcement Mr. Todd Howard Design, Director and Producer at Bethesda Game Studios will be speaking about the 'Future of Commercial/Entertainment Video

Embed Size (px)

Citation preview

Announcement

Mr. Todd HowardDesign, Director and Producer

at Bethesda Game Studios will be speaking about the

'Future of Commercial/Entertainment Video Games'.

October 8th @ 7:00PM in Harris Theater

CS425 Lecture 5

Jan M. Allbeck

Preliminary Notes No class next week! No office hours next week, but send email anytime. Make sure you can receive GMU email. Code due Oct. 16th:

Working code integrated into our game code base Way point navigation and A* Reasonable class structure for the characters and objects Loading and placement of objects from the environment

setup Animations on the characters Ability to constraint objects to characters Code should be well/clearly documented Code will represent 10% of your grade (a part of the 50%

for the final project).

Game AI Scripting Finite State Machines Fuzzy Logic Rule-based AI More AI AI for RAMbot

Scripting What is scripting? Scripting Opponent Attributes:CREATURE = 1;

If (LEVEL < 5)INTELLIGENCE = 20;

SPEED = 50;

ELSEINTELLIGENCE = 5;

SPEED = 25;

Need to parse these files and link them to program variables.

Scripting Opponent BehaviorIf (PlayerArmed == TRUE)DoFlee();

ElseDoAttack();

Patterns of movement Explicit paths for characters to follow

Scripting Verbal InteractionsIf (PlayerArmed == DAGGER)Say(“What a cute little knife”);

Dark GDK can load and playback WAV files. Of course these can be varied to take into

account the nature of the characters involved. They can also convey information or respond

to inquiries:If Ask(“What is your name?”)

Say(“I am Merlin.”); More robust if keyword scripting is used.

Essentially search the string for a few keywords to match to.

Script EventsIf (PlayerLocation(120, 76)Trigger(Explosion1);

If (PlayerLocation(10, 45)Trigger(TrapDoor7);

Can we be a bit smarter about this? Link to objects, not locations Program/Implement a list of “effects” and

reference them in a script Package scripts with environment files

Finite State Machines

Finite State Machines

S1

S3

S2

S5

S4

t1

t4t3t2

t5

t5

Ghost Controller

Roam

Chase Evade

See = false

See = falseSee = false

See = true

See = true

See = true blue = trueblue = true

blue = true

ImplementationSwitch(currentState){Case Roam:

If (See(Blue) == true) currentState = Evade;Else if (See(player) == true)

currentState = Chase;

Else if (See(player) == false) currentState = Roam;

Case Chase:…

Case Evade:…

}

Implementation 2 We could also create or use a general finite

state machine software package. Define states or nodes (WE LOVE NODES!). Define transitions Associate states with transitions Define a method that “advances” the state

machine. Parallel state machines State machines can be nodes in other state

machines.

Hostile State Machine? States or behaviors?

Guarding Patrol Frozen Sneak and flip Captured Escape

Transitions or percepts? See robot (non-flipped) Seen by commander or robot Commander says captured Out of building

Fuzzy Logic

Fuzzy Logic What is it? “The essence of fuzzy logic is that everything

is a matter of degree.” Imprecise Uncertainty “Very smart, but kind of slow” as opposed to

intelligence = 170 and speed = 1.2mph Allows us to think more normally There are degrees of fuzziness (0 to 1)

Fuzzy Logic

Crisp Input --- Fuzzy Input

Fuzzy Rules --- Fuzzy Output

Defuzzification--- Crisp Output

Fuzzy Logic in Games Control Threat Assessment Classification

Fuzzy Control Entity traveling toward a target (waypoint,

enemy unit, treasure, home base, etc). Smoother path motions Instead of using exact coordinates use fuzzy

concepts such as to the left, a little to the right, etc.

Relate relative headings to Far Left, Left, Ahead, Right, and Far Right.

Relative Heading Fuzzy Sets

From AI for Game Developers

Membership Calculation Results for 33 deg

Fuzzy Set Degree of Membership

Far Left 0.0

Left 0.0

Ahead 0.0

Right 0.47

Far Right 0.3

Right is a trapezoid membership function and Far right is a grade membership function.http://powerelectronics.tkk.fi/education/s81270/ex7.pdf

NetForce = FarLeft * MFL + Left * MFL + Right * MFR + FarRight * MFR;Where, MFL = maximum force left = -100MFR = maximum force right = 100 Steering force = 77!

http://www.red3d.com/cwr/steer/gdc99/

Fuzzy Threat Assessment Range = near, close, far, very far, etc Size = tiny, small, medium, large, massive,

etc Results in: no threat, low threat, medium

threat, high threat Models the computer as having less-than-

perfect knowledge Allow, for example, the size of a defensive

force to vary smoothly and less predictably.

Fuzzy Classification Rank characters according to combat prowess

Strength, weapon proficiency, number of hit point, armor class, etc.

Yield: wimpy, easy, moderate, tough, etc

Rule-Based AI

Rule-Based AI If-then style statements Expert systems

Medical diagnosis, engineering fault analysis, etc Anticipation

2 components Working memory: what is true about the world Rules: what can be inferred from what is true.

Inference Forward Chaining

Match rules to facts in working memory Conflict resolution: determine what rule we want

to fire Fire rule: assert a new fact, trigger event, call

function Backward Chaining

Have a goal and try to determine how to reach it Open the door

State Machines and Rules What can Finite State Machines do that Rule-

Based systems can’t? What can Rule-Based systems do that Finite

State Machines can’t?

More AI Map perceptions (sequences) to actions

Simple reflexes Characters with memory

Goal-based characters Utility-based characters Environment-based AI

Crowd sims Smart-objects

Searching and search algorithms A*, backgammon, chess, etc

Learning Neural and belief networks Reinforcement learning

Communication between characters

RAMbot AI? Player

Robots

Innocents

Hostiles

Objects?

Search and Rescue Robots (SR-Bots) Needs a snappy name Basic Scenario A team of robots controlled by a commander

are tasked with clearing a building. The buildings may contain weapons and bombs, innocents, bad guys, and furniture and debris. Robots can move weapons to secure locations, detonate bombs, free innocents, and observe bad guys. The commander (i.e. player) instructs the robots to clear the building as quickly as possible.

30

Rules Robots can defuse/detonate bombs without

damage. Bombs defused/detonated in the same room or

hallway as humans will kill them all, causing the player to loose the game.

If seen by a robot, bad guys cannot move. If they approach from behind, bad guys can

disable robots (by flipping them upside down). Frozen bad guys can be captured by the

commander.

31

Rules continued The goal of the bad guys is to escape the building. Paths may be blocked such that the robots cannot

pass. The commander can unblock paths by moving the furniture or debris.

Innocents will remain where they are until their location is visited by a robot or commander. They then exit the building.

If the commander enters a room with bombs, the commander dies.

If the commander enters a room with a bad guy and not a robot, the commander dies.

32

Characters Robots:

a team of robots number of robots varies with size and complexity of environment capable of moving through the environment can set off bombs can pickup and move small items such as guns cannot move larger items such as furniture little intelligence, and hence most be commanded able to navigate from one location to another vulnerable to bad guys if approached from behind

Commander: the player of the game controls the robots vulnerable to bombs and bad guys if not frozen needs to move blockages for robots

33

Characters continued Innocents:

when released by the commander or a robot, they exit the building

while exiting, they are unaffected by anything else in the environment

Bad guys: want to escape the building cannot move if seen by a robot if seen by a robot, can be captured by the commander can disable robots by approaching them from behind will kill commander if in a room alone with him

34

Environment World

Building is laid out on a grid. Objects

Weapons Bombs Furniture/blocks/debris

35

Actions Walk to location Exit building Stay Turn Pickup Drop Defuse/detonate Capture Kill

36