Artificial Intelligence in Game Design
description
Transcript of Artificial Intelligence in Game Design
![Page 1: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/1.jpg)
Artificial Intelligence in Game Design
Camera Control
![Page 2: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/2.jpg)
The Camera as a NPC
• Good camera placement vital to good gameplay!– Must maintain clear view of selected character– Must highlight significant events to the player– Must anticipate player movements, providing clear view of where
the player’s character is moving
• Best approach: Treat like an intelligent character– Must move in logical ways to perform goals
• Movement must be smooth, not “jerky” or discontinuous
– Best actions often depend on state of game
![Page 3: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/3.jpg)
Categories of Camera Perspective
• First person: From perspective of player’s character– Implemented by parenting camera to “head” of character– Few AI-related problems, since camera totally controlled by player
![Page 4: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/4.jpg)
Categories of Camera Perspective
• Third person: From point of view of “user” observing world and its inhabitants– Often “birds eye” view showing world around character– Few AI-related problems, since camera usually fixed above player
![Page 5: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/5.jpg)
Categories of Camera Perspective
• “First and a half person”– From POV slightly behind and to side of player– Combines character POV with view of character
![Page 6: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/6.jpg)
“First and a Half” Person
• Usually implemented by parenting camera to position relative to player character– Maintains same relative position/angle to player as player moves
![Page 7: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/7.jpg)
Problems
• Must make sure no obstacles between camera and character– Will have to move camera
around obstacles to keep character visible
• Must make sure camera shot includes all relevant characters– Current opponent NPCs– Player themselves!
![Page 8: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/8.jpg)
Camera Position Selection
• Usually have many viable camera positions for first-and-a-half person perspective
• Choose the “best” one based on current situation
![Page 9: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/9.jpg)
Raycast Method
• Project “rays” in different directions from character relative to camera angle (xangle, yangle)
– (xangle + Θ, yangle)
– (xangle - Θ, yangle)
– (xangle, yangle + Θ)
– (xangle, yangle - Θ)
![Page 10: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/10.jpg)
Raycast Method
• Use raycasting to see if any intersect an obstacle atdistance shorter than distance from camera to character
• These are potential situationswhere camera may be blocked in future dependingon how character moves
• Example: Vector B intersects obstacle
![Page 11: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/11.jpg)
Raycast Method
• Camera should flee vectors that are potential problems– Change relative angle– Potentially change distance/height– Should arrive at original angle
once obstacle cleared
![Page 12: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/12.jpg)
Multipoint Method
• Generate points in region where camera is moving to• Evaluate suitability of each point• Move camera to most suitable point
![Page 13: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/13.jpg)
Defining “Suitability”
• Primarily based on constraints on relative position to character– Distance constraint:
Penalty proportional to how far camera is from desired distance to character
– Height constraint: Penalty proportional to how far camera is from desired height relative to character
– Orientation constraint:Penalty proportional to how far camera is from desired angle relative to character
![Page 14: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/14.jpg)
Defining “Suitability”
• Collision detection and visibility constraints– 0 if all characters visible– 1 if main character not visible
• Possibly defined as “more than half of torso/head occluded”
– 0 < n ≤ 1 based on degree to which other important characters in area of player not visible
![Page 15: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/15.jpg)
Defining “Suitability”
• Different components usually weighted
Suitability = WD distance constraint +WH height constraint +WO orientation constraint +Wv visibility constraint +
(Wv usually larger than others)
• Key idea: Developers can “tune” weights– Can experiment with different values by playing game– Which give most “intuitive” camera behavior?
![Page 16: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/16.jpg)
Regional Constraints
• May want to constrain camera to specific area in space– Example: Showing dialog between two characters should keep
camera locked in torus around the characters
• Points to search limited to those that fall within this region
![Page 17: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/17.jpg)
Smoothing
• Potential problem: Several nearby points might have similar suitability measures
• Camera may oscillate back and forth between them as character moves– “Jerky camera” appearance
![Page 18: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/18.jpg)
Smoothing
• Apply smoothing (averaging) to suitability function
• Suitability (x, y) = 0.5 * Suitability (x, y) + 0.125 * Suitability (x+1, y) +
0.125 * Suitability (x-1, y) +0.125 * Suitability (x, y+1) +0.125 * Suitability (x, y-1) +
• Usually results in one point consistently best over period of time
![Page 19: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/19.jpg)
State-based Suitability
• Different constraint weights best in different game situations– Driving: Fixed angle relative to player
most important
– Jumping: Correct height most important to keep player from jumping out of camera
– Multicharacter battle: Keeping all characters in frame
![Page 20: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/20.jpg)
State-based Suitability
• Can use finite state machine for camera to choose appropriate weights/constraints
Walkingconstraints
Jumpingconstraints
Area with pits
Drivingconstraints
Car reached
![Page 21: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/21.jpg)
Multicharacter Games
• Some games allow player to swap control between several different characters– Camera must show world from perspective of current character– Transition should be smooth to avoid player confusion
Don’t just jump
![Page 22: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/22.jpg)
Multicharacter Games
• Move camera to new character in smooth transition• May have to use steering behaviors
– Arrive at position behind next player character– Flee obstacles, positions where character not visible
![Page 23: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/23.jpg)
Multicharacter Games
• Best approach may be to move over obstacles– Temporarily take “third person” approach
![Page 24: Artificial Intelligence in Game Design](https://reader035.fdocuments.net/reader035/viewer/2022062517/56813b7d550346895da49616/html5/thumbnails/24.jpg)
Camera Events
• Camera must often respond to other game events– Example: Off-screen explosion should cause “camera shaking”
• Camera must be part of game messaging system– List of current world events maintained– Camera must regularly poll list for relevant events, take
appropriate action
Event State
explosion true
… …
GameEngine