1 / 29

Introduction

Dive into the basic techniques of game AI, from finite-state machines to coordination transformations. Hands-on labs, assignments, and a final project will enhance your understanding. Join us on this exciting journey!

rebbecad
Download Presentation

Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction GAM 376 Robin Burke Winter 2006

  2. Outline • Introductions • Syllabus • Math / Physics • Break • Lab

  3. Me • Helped create the new GAM degree • A long-time fan of computer games • from Space Invaders to Katamari Damacy • An AI researcher by training • But • not a game developer by training or experience

  4. What is Game AI? • Analogy • game AI is to "real" AI as • stage design is to architecture • The goal of game AI is to give the impression of intelligence • to avoid the impression of stupidity • to provide a reasonable challenge for the player

  5. What we will cover • Finite-state machines • the most basic technique for implementing game AI • fundamental to everything else • Steering behaviors • basic behaviors for avoiding stupidity while navigating the world • Path planning • the surprisingly tricky problem of getting from point A to point B • Action planning • assembling sequences of actions • Fuzzy logic • reasoning by degrees

  6. How we will do it • Classes will be 50% lab • first half in the classroom • second half in Rm 707 • 7th floor Game Development Lab • we will visit there tonight • Tools • Buckland's source code • VS 2003

  7. What we will do • 3 homework assignments • one trivial • two non-trivial • 2 group assignments • soccer team • death match bot • final project • mod for Half-Life 2

  8. Final Project • Add a co-operative character to a HL2 level • The character should • follow along through the level • contribute in some way to completing the level • not hinder the player • The character should not be human • helps keep expectations low

  9. Disclaimer • This class is an experiment • We will probably need to adjust as we go along

  10. Begin math / physics 101 • Vectors • Coordinate spaces • Kinematics

  11. Vector • A multi-dimensional quantity • represented by a tuple of numbers • We will deal mostly with 2-D vectors • <2, 5> • 3-D vectors are more mathematically complex • but not fundamentally different • for AI purposes

  12. Vectors • can represent positions • <1,1> is a position 1 unit north and 1 unit east of the origin • can also represent velocities • <3,-4> is a speed of 5 units in a northwesterly direction • other quantities • orientation, acceleration, angle, etc.

  13. Vector operations • Magnitude • v = <x1, y1> • | v | = magnitude(v) = sqrt(x12+y12) • the length of the vector • Adding • <x1, y1> + <x2, y2> = <x1+x2, y1+y2> • Scalar multiplication • <x1, y1> * z = <x1*z, y1*z> • changes only the length • Normalization • v / |v| • makes a vector of length 1 • does not change the orientation of the vector

  14. More vector operations • dot product • <x1, y1> ● <x2, y2> = • x1 * x2 + y1 *y2 • scalar quantity • related to the angle between vectors • cos (angle) = u ● v / | u | | v | • Note • if u and v are normalized (length = 1) • then u ● v is the cosine of the angle between them

  15. Example • we have two agents: a, b • each has a vector position • and a normalized vector orientation • the direction they are facing • turn to face an enemy • agent: Pa, Oa • enemy: Pb, Ob • vector from agent to enemy • Pba = Pb-Pa • normalize it • compute dot product • Pba ● Og • compute inverse cosine • this is the direction to turn

  16. Coordinate transformations • We will always want to move back and forth between coordinate systems • objects each have their own local coordinate systems • related to each other in "world space" • Example • NPC • a character is at a particular position, facing a particular direction • he defines a coordinate system • Door • the door has its own coordinate system • in that system, the handle is in a particular spot • To make the character reach for the handle • we have to make the two coordinate systems interact

  17. Transformations • We know • where the handle is in door space • where the agent's hand is in agent space • what is the vector in agent space • Set of transformations • transform handle location L0 to world space Lw • transform handle location to agent space La • Each transformation • is a translation (changing the origin) • and a rotation changing the orientation

  18. Affine transformations • Usually coordinate transformations are done through matrix multiplications • we multiply a vector by a matrix and get another vector out • The curious thing is • that to do this we have to use vectors and matrices one size larger than our current number of dimensions • you will see <x, y, 1> as the representation of 2-D vector and <x,y,z,1> for 3-D

  19. Efficiency • Mathematical operations are expensive • especially trigonometric ones (inverse cosine) • also square root • multiplication and division, too • Normalization is particularly expensive • square root, squaring and division • We want to consider ways to make our calculations faster • especially if we are doing them a lot

  20. Kinematics • the physics of motion • we worry about this a lot in computer games • moving through space, collisions, etc. • our NPCs have to understand this too in order to not look stupid

  21. Basic kinematics • position • a vector in space • (point position) • for a large object we use a convenient point • classically the center of mass • velocity • the change of position over time • expressed as a vector • pt+1 = pt + vΔt • if we define the time interval Δt to be 1 • we avoid a multiplication

  22. Basic kinematics II • Acceleration • change in velocity over time • also expressed as a vector • vt+1 = vt + a Δt • Pair of difference equations

  23. Numerical methods • But now we have a problem • there is a lag of 1 time step before acceleration impacts position • not physically accurate • We can improve our simulation • finer time step (very expensive) • improved estimation methods • for example instead of using vt, we can use the average of vt and vt+1

  24. Force • Netwon's law • F = m*a • In other words • acceleration is a function of force and mass • Force is also a vector quantity

  25. Example • When a bat hits a ball • we will want to determine the force imparted to the ball • we could simulate this with the mass of the bat and its speed • more likely, we would just have a built-in value • direction of the force • we need to know the angle of the bat when it strikes the ball

  26. What does this have to do with AI? • Imagine a NPC baseball player • he has to decide when to swing • that judgement has to be based on an estimate of the ball's trajectory • When NPC take physical actions • we have to know what the parameters of those actions should be • very often physics calculations are required • not as detailed as the calculations needed to run the game

  27. More complex motions • To handle rotation • we also have to worry about torque and angular momentum • But for the purposes of this class • we will deal only with "particle systems"

  28. End math / physics 101 • For more, take GAM 350

  29. Break

More Related