CSCE 590E Spring 2007 - PowerPoint PPT Presentation

Loading...

PPT – CSCE 590E Spring 2007 PowerPoint presentation | free to download - id: 5a4159-ZmYwN



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

CSCE 590E Spring 2007

Description:

... due on Monday Hardcopy should be turned in before the class Artificial ... movement is generally ... organizes cooperation between agents ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 110
Provided by: JT4
Learn more at: http://www.cse.sc.edu
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: CSCE 590E Spring 2007


1
CSCE 590E Spring 2007
  • AI/Audio

By Jijun Tang
2
Announcements
  • April 30th demos
  • Show progress/difficulties
  • Risk analysis
  • Final Demo May 8th, 530pm, Amoco Hall
  • No extension is possible
  • Make sure you equipment works on site
  • High school outreach
  • Anyone can contact their high school admin to
    arrange direct talks to students
  • Of course, in SC only

3
Homework
  • Page 591 question 1
  • 5 points, due on Monday
  • Hardcopy should be turned in before the class

4
Artificial Intelligence
  • Intelligence embodied in a man-made device
  • Human level AI still unobtainable
  • The difficulty is comprehension

5
Goals of anAI Game Programmer
  • Different than academic or defense industry
  • 1. AI must be intelligent, yet purposely flawed
  • 2. AI must have no unintended weaknesses
  • 3. AI must perform within the constraints
  • 4. AI must be configurable by game designers or
    players
  • 5. AI must not keep the game from shipping

6
Game Agents
  • May act as an
  • Opponent
  • Ally
  • Neutral character
  • Continually loops through the
  • Sense-Think-Act cycle
  • Optional learning or remembering step

7
Sense-Think-Act CycleSensing
  • Agent can have access to perfect information of
    the game world
  • May be expensive/difficult to tease out useful
    info
  • Game World Information
  • Complete terrain layout
  • Location and state of every game object
  • Location and state of player
  • But isnt this cheating???

8
Sense-Think-Act Cycle Thinking
  • Sensed information gathered
  • Must process sensed information
  • Two primary methods
  • Process using pre-coded expert knowledge
  • Use search to find an optimal solution

9
Sense-Think-Act CycleActing
  • Sensing and thinking steps invisible to player
  • Acting is how player witnesses intelligence
  • Numerous agent actions, for example
  • Change locations
  • Pick up object
  • Play animation
  • Play sound effect
  • Converse with player
  • Fire weapon

10
Extra Step in CycleLearning and Remembering
  • Optional 4th step
  • Not necessary in many games
  • Agents dont live long enough
  • Game design might not desire it

11
Making Agents Stupid
  • Sometimes very easy to trounce player
  • Make agents faster, stronger, more accurate
  • Sometimes necessary to dumb down agents, for
    example
  • Make shooting less accurate
  • Make longer reaction times
  • Engage player only one at a time
  • Change locations to make self more vulnerable

12
Agent Cheating
  • Players dont like agent cheating
  • When agent given unfair advantage in speed,
    strength, or knowledge
  • Sometimes necessary
  • For highest difficultly levels
  • For CPU computation reasons
  • For development time reasons
  • Dont let the player catch you cheating!
  • Consider letting the player know upfront

13
Common Game AI Techniques
  • A Pathfinding
  • Command Hierarchy
  • Dead Reckoning
  • Emergent Behavior
  • Flocking
  • Formations
  • Influence Mapping

14
A Pathfinding
  • Directed search algorithm used for finding an
    optimal path through the game world
  • Used knowledge about the destination to direct
    the search
  • A is regarded as the best
  • Guaranteed to find a path if one exists
  • Will find the optimal path
  • Very efficient and fast

15
Command Hierarchy
  • Strategy for dealing with decisions at different
    levels
  • From the general down to the foot soldier
  • Modeled after military hierarchies
  • General directs high-level strategy
  • Foot soldier concentrates on combat

16
Dead Reckoning
  • Method for predicting objects future position
    based on current position, velocity and
    acceleration
  • Works well since movement is generally close to a
    straight line over short time periods
  • Can also give guidance to how far object could
    have moved
  • Example shooting game to estimate the leading
    distance

17
Emergent Behavior
  • Behavior that wasnt explicitly programmed
  • Emerges from the interaction of simpler behaviors
    or rules
  • Rules seek food, avoid walls
  • Can result in unanticipated individual or group
    behavior

18
Flocking
  • Example of emergent behavior
  • Simulates flocking birds, schooling fish
  • Developed by Craig Reynolds
  • 1987 SIGGRAPH paper
  • Three classic rules
  • 1. Separation avoid local flockmates
  • 2. Alignment steer toward average heading
  • 3. Cohesion steer toward average position

19
Formations
  • Group movement technique
  • Mimics military formations
  • Similar to flocking, but actually distinct
  • Each unit guided toward formation position
  • Flocking doesnt dictate goal positions

20
Influence Mapping
  • Method for viewing/abstracting distribution of
    power within game world
  • Typically 2D grid superimposed on land
  • Unit influence is summed into each grid cell
  • Unit influences neighboring cells with falloff
  • Facilitates decisions
  • Can identify the front of the battle
  • Can identify unguarded areas
  • Plan attacks
  • Sim-city influence of police around the city

21
Level-of-Detail AI
  • Optimization technique like graphical LOD
  • Only perform AI computations if player will
    notice
  • For example
  • Only compute detailed paths for visible agents
  • Off-screen agents dont think as often

22
Manager Task Assignment
  • Manager organizes cooperation between agents
  • Manager may be invisible in game
  • Avoids complicated negotiation and communication
    between agents
  • Manager identifies important tasks and assigns
    them to agents
  • For example, a coach in an AI football team

23
Terrain Analysis
  • Analyzes world terrain to identify strategic
    locations
  • Identify
  • Resources
  • Choke points
  • Ambush points
  • Sniper points
  • Cover points

24
Trigger System
  • Highly specialized scripting system
  • Uses if/then rules
  • If condition, then response
  • Simple for designers/players to understand and
    create
  • More robust than general scripting
  • Tool development simpler than general scripting

25
Promising AI Techniques
  • Show potential for future
  • Generally not used for games
  • May not be well known
  • May be hard to understand
  • May have limited use
  • May require too much development time
  • May require too many resources

26
Bayesian Networks
  • Performs humanlike reasoning when faced with
    uncertainty
  • Potential for modeling what an AI should know
    about the player
  • Alternative to cheating
  • RTS Example
  • AI can infer existence or nonexistence of player
    build units

27
Blackboard Architecture
  • Complex problem is posted on a shared
    communication space
  • Agents propose solutions
  • Solutions scored and selected
  • Continues until problem is solved
  • Alternatively, use concept to facilitate
    communication and cooperation

28
Decision Tree Learning
  • Constructs a decision tree based on observed
    measurements from game world
  • Best known game use Black White
  • Creature would learn and form opinions
  • Learned what to eat in the world based on
    feedback from the player and world

29
Filtered Randomness
  • Filters randomness so that it appears random to
    players over short term
  • Removes undesirable events
  • Like coin coming up heads 8 times in a row
  • Statistical randomness is largely preserved
    without gross peculiarities
  • Example
  • In an FPS, opponents should randomly spawn from
    different locations (and never spawn from the
    same location more than 2 times in a row).

30
Genetic Algorithms
  • Technique for search and optimization that uses
    evolutionary principles
  • Good at finding a solution in complex or poorly
    understood search spaces
  • Typically done offline before game ships
  • Example
  • Game may have many settings for the AI, but
    interaction between settings makes it hard to
    find an optimal combination

31
N-Gram Statistical Prediction
  • Technique to predict next value in a sequence
  • In the sequence 18181810181, it would predict 8
    as being the next value
  • Example
  • In street fighting game, player just did Low Kick
    followed by Low Punch
  • Predict their next move and expect it

32
Neural Networks
  • Complex non-linear functions that relate one or
    more inputs to an output
  • Must be trained with numerous examples
  • Training is computationally expensive making them
    unsuited for in-game learning
  • Training can take place before game ships
  • Once fixed, extremely cheap to compute

33
Planning
  • Planning is a search to find a series of actions
    that change the current world state into a
    desired world state
  • Increasingly desirable as game worlds become more
    rich and complex
  • Requires
  • Good planning algorithm
  • Good world representation
  • Appropriate set of actions

34
Player Modeling
  • Build a profile of the players behavior
  • Continuously refine during gameplay
  • Accumulate statistics and events
  • Player model then used to adapt the AI
  • Make the game easier player is not good at
    handling some weapons, then avoid
  • Make the game harder player is not good at
    handling some weapons, exploit this weakness

35
Production (Expert) Systems
  • Formal rule-based system
  • Database of rules
  • Database of facts
  • Inference engine to decide which rules trigger
    resolves conflicts between rules
  • Example
  • Soar used experiment with Quake 2 bots
  • Upwards of 800 rules for competent opponent

36
Reputation System
  • Models players reputation within the game world
  • Agents learn new facts by watching player or from
    gossip from other agents
  • Based on what an agent knows
  • Might be friendly toward player
  • Might be hostile toward player
  • Affords new gameplay opportunities
  • Play nice OR make sure there are no witnesses

37
Smart Terrain
  • Put intelligence into inanimate objects
  • Agent asks object how to use it how to open the
    door, how to set clock, etc
  • Agents can use objects for which they werent
    originally programmed for
  • Allows for expansion packs or user created
    objects, like in The Sims
  • Enlightened by Affordance Theory
  • Objects by their very design afford a very
    specific type of interaction

38
Speech Recognition
  • Players can speak into microphone to control some
    aspect of gameplay
  • Limited recognition means only simple commands
    possible
  • Problems with different accents, different
    genders, different ages (child vs adult)

39
Text-to-Speech
  • Turns ordinary text into synthesized speech
  • Cheaper than hiring voice actors
  • Quality of speech is still a problem
  • Not particularly natural sounding
  • Intonation problems
  • Algorithms not good at voice acting the mouth
    needs to be animated based on the text
  • Large disc capacities make recording human voices
    not that big a problem
  • No need to resort to worse sounding solution

40
Artificial Intelligence Pathfinding
41
Introduction
  • Almost every game requires pathfinding
  • Agents must be able to find their way around the
    game world
  • Pathfinding is not a trivial problem
  • The fastest and most efficient pathfinding
    techniques tend to consume a great deal of
    resources

42
Representing the Search Space
  • Agents need to know where they can move
  • Search space should represent either
  • Clear routes that can be traversed
  • Or the entire walkable surface
  • Search space typically doesnt represent
  • Small obstacles or moving objects
  • Most common search space representations
  • Grids
  • Waypoint graphs
  • Navigation meshes

43
Grids
  • 2D grids intuitive world representation
  • Works well for many games including some 3D games
    such as Warcraft III
  • Each cell is flagged
  • Passable or impassable
  • Each object in the world can occupy one or more
    cells

44
Characteristics of Grids
  • Fast look-up
  • Easy access to neighboring cells
  • Complete representation of the level

45
Waypoint Graph
  • A waypoint graph specifies lines/routes that are
    safe for traversing
  • Each line (or link) connects exactly two waypoints

46
Characteristicsof Waypoint Graphs
  • Waypoint node can be connected to any number of
    other waypoint nodes
  • Waypoint graph can easily represent arbitrary 3D
    levels
  • Can incorporate auxiliary information
  • Such as ladders and jump pads
  • Radius of the path

47
Navigation Meshes
  • Combination of grids and waypoint graphs
  • Every node of a navigation mesh represents a
    convex polygon (or area)
  • As opposed to a single position in a waypoint
    node
  • Advantage of convex polygon
  • Any two points inside can be connected without
    crossing an edge of the polygon
  • Navigation mesh can be thought of as a walkable
    surface

48
Navigation Meshes (continued)

49
Characteristics of Navigation Meshes
  • Complete representation of the level
  • Ties pathfinding and collision detection together
  • Can easily be used for 2D and 3D games

50
Searching for a Path
  • A path is a list of cells, points, or nodes that
    an agent must traverse
  • A pathfinding algorithm finds a path
  • From a start position to a goal position
  • The following pathfinding algorithms can be used
    on
  • Grids
  • Waypoint graphs
  • Navigation meshes

51
Criteria for Evaluating Pathfinding Algorithms
  • Quality of final path
  • Resource consumption during search
  • CPU and memory
  • Whether it is a complete algorithm
  • A complete algorithm guarantees to find a path if
    one exists

52
Random Trace
  • Simple algorithm
  • Agent moves towards goal
  • If goal reached, then done
  • If obstacle
  • Trace around the obstacle clockwise or
    counter-clockwise (pick randomly) until free path
    towards goal
  • Repeat procedure until goal reached

53
Random Trace (continued)
  • How will Random Trace do on the following maps?

54
Random Trace Characteristics
  • Not a complete algorithm
  • Found paths are unlikely to be optimal
  • Consumes very little memory

55
Understanding A
  • To understand A
  • First understand Breadth-First, Best-First, and
    Dijkstra algorithms
  • These algorithms use nodes to represent candidate
    paths

56
Understanding A
  • class PlannerNode
  • public
  • PlannerNode m_pParent
  • int m_cellX, m_cellY
  • ...
  • The m_pParent member is used to chain nodes
    sequentially together to represent a path

57
Understanding A
  • All of the following algorithms use two lists
  • The open list
  • The closed list
  • Open list keeps track of promising nodes
  • When a node is examined from open list
  • Taken off open list and checked to see whether it
    has reached the goal
  • If it has not reached the goal
  • Used to create additional nodes
  • Then placed on the closed list

58
Overall Structure of the Algorithms
  • 1. Create start point node push onto open list
  • 2. While open list is not empty
  • A. Pop node from open list (call it currentNode)
  • B. If currentNode corresponds to goal, break
    from step 2
  • C. Create new nodes (successors nodes) for cells
    around currentNode and push them onto open list
  • D. Put currentNode onto closed list

59
Breadth-First
  • Finds a path from the start to the goal by
    examining the search space ply-by-ply

60
Breadth-First Characteristics
  • Exhaustive search
  • Systematic, but not clever
  • Consumes substantial amount of CPU and memory
  • Guarantees to find paths that have fewest number
    of nodes in them
  • Not necessarily the shortest distance!
  • Complete algorithm

61
Best-First
  • Uses problem specific knowledge to speed up the
    search process
  • Head straight for the goal
  • Computes the distance of every node to the goal
  • Uses the distance (or heuristic cost) as a
    priority value to determine the next node that
    should be brought out of the open list

62
Best-First (continued)
63
Best-First (continued)
  • Situation where Best-First finds a suboptimal
    path

64
Best-First Characteristics
  • Heuristic search
  • Uses fewer resources than Breadth-First
  • Tends to find good paths
  • No guarantee to find most optimal path
  • Complete algorithm

65
Dijkstra
  • Disregards distance to goal
  • Keeps track of the cost of every path
  • No guessing
  • Computes accumulated cost paid to reach a node
    from the start
  • Uses the cost (called the given cost) as a
    priority value to determine the next node that
    should be brought out of the open list

66
Dijkstra Characteristics
  • Exhaustive search
  • At least as resource intensive as Breadth-First
  • Always finds the most optimal path
  • Complete algorithm

67
A
  • Uses both heuristic cost and given cost to order
    the open list
  • Final Cost Given Cost (Heuristic Cost
    Heuristic Weight)

68
A (continued)
  • Avoids Best-First trap!

69
A Characteristics
  • Heuristic search
  • On average, uses fewer resources than Dijkstra
    and Breadth-First
  • Admissible heuristic guarantees it will find the
    most optimal path
  • Complete algorithm

70
Summary
  • Two key aspects of pathfinding
  • Representing the search space
  • Searching for a path

71
Audio Programming
72
Audio Programming
  • Audio in games is more important than ever before

73
Programming Basic Audio
  • Most gaming hardware has similar capabilities (on
    similar platforms)
  • Mostly programming interfaces differ
  • Learning fundamental concepts of audio
    programming is important

74
API Choices
  • DirectSound (part of DirectX API)
  • Only available on Windows platforms
  • OpenAL
  • Newer API
  • Available on multiple platforms
  • Proprietary APIs
  • Typically available on consoles
  • 3rd Party Licensable APIs
  • Can offer broad cross-platform solutions

75
Analog Sound Wave
76
Basic Audio Terminology and Physics
  • Amplitude
  • Measurement of a sound waves pressure
  • Frequency
  • Measurement of the interval between wave cycles,
    typically measured in Hertz
  • Pitch
  • The perception of frequency
  • Tuning
  • Musical distribution of frequencies over keys
  • Decibel
  • Measures sound amplitude

77
Digital Representation of a Sound Wave
78
Digital Representationof a Sound Wave
  • Most common technique known as sampling
  • Sampling involves measuring the amplitude of the
    analog wave file at discrete intervals
  • The frequency of sampling is known as sampling
    rate
  • Each sample is typically stored in a value
    ranging from 4 to 24 bits in size
  • The size of the sample value in bits is known as
    the bit depth
  • Music CDs have a sample rate and bit depth of
    44.1 kHz (samples/sec) and 16 bits (sample size)

79
Quantization Error in Sampling
80
Bit Depth and Signal Noise
  • Bit depth of sample data affects signal noise
  • Signal to noise ratio number of available bits
    / 1
  • For example, 8-bit samples have a 2561 SNR (48
    dB), and 16-bit samples have a 65,5361 SNR (96
    dB)
  • Decibel ratio is calculated using 10 x log10
    (ratio) or 8.685890 x log e (ratio)

81
Sampling Frequency and Frequency Reproduction
  • Sampling frequency affects range and quality of
    high-frequency reproduction
  • Nyquist Limit
  • Frequencies up to one-half the sampling rate can
    be reproduced
  • Audio quality degrades as frequency approaches
    this limit

82
Sampling Errors vs. Sampling Frequency
83
Modern Audio Hardware
  • Samples are piped into sound channels
  • Often a hardware pipeline from this point
  • Various operations, such as volume, pan, and
    pitch may be applied
  • 3D sounds may apply HRTF algorithms and/or mix
    the sound into final output buffers.

84
Sound Playback Techniques
  • Two basic playback methods
  • 1. Play sample entirely from memory buffer
  • 2. Stream data in real-time from storage medium
  • Streaming is more memory efficient for very large
    audio files, such as music tracks, dialogue, etc
  • Streaming systems use either a circular buffer
    with read-write pointers, or a double-buffering
    algorithm

85
Playback
86
Sample Playback and Manipulation
  • Three basic operations you should know
  • Panning is the attenuation of left and right
    channels of a mixed sound
  • Results in spatial positioning within the aural
    stereo field
  • Pitch allows the adjustment of a samples
    playback frequency in real-time
  • Volume control typically attenuates the volume of
    a sound
  • Amplification is generally never supported

87
Compressed Audio Format
  • Compressed audio formats allow sound and music to
    be stored more compactly
  • Bit reduction codecs generally are lightweight
  • ADPCM compression is implemented in hardware on
    all the major current video game console systems
  • Psycho-acoustic codecs often have better
    compression
  • Discard sounds our ears would not typically be
    able to hear
  • Require substantially more computational
    horsepower to decode

88
MP3, Ogg Vorbis,Licensing Patent Issues
  • The MP3 format is patented
  • Any commercial game is subject to licensing terms
    as determined by Fraunhofer Thompson
    Multimedia, the holders of the patents
  • Ogg Vorbis is similar to MP3 in many ways
  • Open source and patent-free (royalty-free)
  • Be aware of patent and license restrictions when
    using 3rd party software

89
3D Audio
  • Two sets of data required when working in world
    coordinates
  • Listener Data
  • Composed of world position and orientation
    (virtual microphone in the world)
  • Source Data
  • Composed of sound position, orientation,
    velocity, etc (virtual sound source in the world)

90
Listener/Source
91
Environmental Effects
  • Environmental effects nearly always implemented
    in hardware
  • Sound transmission is categorized in three ways
  • Direct transmission
  • Early reflections (echo)
  • Late reflections (reverberation)

92
Sound Transmission Categories
93
EnvironmentalEffects Standards
  • EAX 2.0 and beyond
  • EAX 2.0 developed by Creative Labs and released
    as an open standard
  • EAX 3.0 and 4.0 remain proprietary Creative Labs
    standards
  • I3DL2
  • Open standard developed by IA-SIG, similar to EAX
    2.0 in functionality

94
Programming Music Systems
  • Two common music systems
  • MIDI-based systems
  • (Musical Instrument Digital Interface)
  • Digital audio streaming systems
  • (CD audio, MP3 playback, etc)

95
Advantages and Disadvantages of MIDI
  • Actual music data size is negligible
  • Easy to control, alter, and even generate in
    real-time
  • High quality music is more difficult to compose
    and program
  • Only effective if you can guarantee playback of a
    common instrument set

96
Example
97
Other MIDI-based technologies to be aware of
  • DLS (DownLoadable Sound) Format
  • A standardized format for instrument definition
    files
  • iXMF (Interactive eXtensible Music Format)
  • New proposed standard for a container format for
    interactive music

98
Advantages / Disadvantages of Digital Audio
Streams
  • Superb musical reproduction is guaranteed
  • Allows composers to work with any compositional
    techniques
  • Some potential interactivity is sacrificed for
    expediency and musical quality
  • Generally high storage requirements

99
A Conceptual Interactive Music Playback System
  • Divide music into small two to eight-bar chunks
    that well call segments.
  • A network of transitions from segment to segment
    (including loops and branches) is called a theme.
  • Playing music is now as simple as choosing a
    theme to play. The transition map tracks the
    details.

100
Advanced Audio Programming
  • 3D Audio Environmental Effects Integration
  • Audio Scripting and Engine Integration
  • Lip-sync Technology
  • Advanced Voice Playback
  • Voice Recognition

101
3D Audio Environmental Effects Integration
  • Environmental effects should be driven by a
    rooms shape and material composition.
  • Can determining the optimal effect settings be
    done automatically?
  • This may be important as game worlds become
    larger and more complex

102
3D Audio Environmental Effects Integration (cont)
  • Sound occlusion and damping is a particularly
    difficult problem to solve
  • This is essentially a pathfinding problem for
    audio.
  • Doors can dynamically affect a sounds properties
  • Very few titles have even attempted a robust,
    general-purpose, and automated solution to these
    problems.

103
Room Acoustics
104
Dynamic Occlusion
105
Audio Scripting and Engine Integration
  • Very little audio programming should be done by
    general game programmers
  • Game Engine should offer robust support for audio
    triggers and scripts
  • Engine should deal with audio scripts, not sound
    files
  • Why is this so important?

106
Audio Scripting
  • Many situations require much more information
    than can be embedded in a linear audio file
  • Sound Variation
  • Sound Repetition
  • Complex Sound Looping
  • Background Ambience

107
Lip-sync Technology
  • Lip-sync technology is a blending of audio and
    visual techniques to create realistic-looking
    speech by in-game actors.
  • Simple techniques such as waveform amplitude
    measurement has worked previously, but
  • In future titles, it will be considered
    inadequate.
  • Much work can still be done in this field.

108
Advanced Voice Playback
  • Real-time spoken feedback is especially important
    in sports titles (simulated announcers)
  • Game are reaching the limits of what current
    techniques (canned, prerecorded phrases combined
    in series) can provide.
  • Again, this is an opportunity for future
    groundbreaking audio work.

109
Voice Recognition
  • Spoken commands are much easier to deliver in
    certain situations.
  • A great example of this? Squad-based tactical
    shooters.
  • Current generation systems are still very error
    prone. A great opportunity for breakout audio
    technology.
About PowerShow.com