game ai
play

Game AI CS 2501 Computer Game Design Some slides - PowerPoint PPT Presentation

Game AI CS 2501 Computer Game Design Some slides courtesy Tiffany Barnes, NCSU CS 2501 The Loop of Life Games are driven by a


  1. Game ¡AI ¡ CS ¡2501 ¡– ¡Computer ¡Game ¡Design ¡ ¡ Some ¡slides ¡courtesy ¡Tiffany ¡Barnes, ¡NCSU ¡ CS ¡2501 ¡

  2. The ¡Loop ¡of ¡Life ¡ • Games ¡are ¡driven ¡by ¡a ¡game ¡loop ¡that ¡ performs ¡a ¡series ¡of ¡tasks ¡every ¡frame ¡ • Some ¡games ¡have ¡separate ¡loops ¡for ¡the ¡front ¡ and ¡and ¡the ¡game ¡itself ¡ • Other ¡games ¡have ¡a ¡unified ¡main ¡loop ¡ CS ¡2501 ¡ 2

  3. The ¡Game ¡Loop ¡ • Tasks ¡ – Handling ¡Jme ¡ – Gathering ¡player ¡input ¡ – Networking ¡ – SimulaJon ¡ – Collision ¡detecJon ¡and ¡response ¡ – Object ¡updates ¡ – Rendering ¡ – Other ¡miscellaneous ¡tasks ¡ CS ¡2501 ¡ 3

  4. The ¡Game ¡Loop ¡ • Tasks ¡ – Handling ¡Jme ¡ – Gathering ¡player ¡input ¡ – Networking ¡ – Simula:on ¡ – Collision ¡detecJon ¡and ¡response ¡ – Object ¡updates ¡ – Rendering ¡ – Other ¡miscellaneous ¡tasks ¡ CS ¡2501 ¡ 4

  5. What ¡all ¡do ¡you ¡have ¡to ¡simulate? ¡ • Physics ¡ • Environments ¡ • LighJng ¡ • Sounds ¡ • Behaviors ¡ CS ¡2501 ¡ 5

  6. Some ¡Terms ¡To ¡Know ¡ • AI: ¡ArJficial ¡Intelligence ¡– ¡does ¡not ¡have ¡to ¡ mean ¡perfect ¡human-­‑like ¡intelligence! ¡ • Turing ¡Test: ¡ ¡Can ¡a ¡normal ¡user ¡tell ¡the ¡ difference ¡between ¡interacJng ¡with ¡a ¡ computer ¡and ¡a ¡person ¡ • NPC: ¡ ¡Non-­‑Player ¡Character ¡– ¡any ¡thing ¡in ¡the ¡ world ¡that ¡needs ¡to ¡be ¡modeled, ¡can ¡make ¡ decisions, ¡and ¡can ¡potenJally ¡have ¡player ¡ interacJon ¡ CS ¡2501 ¡ 6

  7. Discussion ¡ • How ¡good ¡should ¡the ¡AI ¡be? ¡ CS ¡2501 ¡ 7

  8. Discussion ¡ • Are ¡people ¡more ¡fun ¡than ¡NPCs? ¡ ¡Why? ¡ CS ¡2501 ¡ 8

  9. What ¡Makes ¡“Good ¡AI”? ¡ • Perceived ¡by ¡user ¡as ¡challenging ¡ – Cruel, ¡but ¡fair! ¡ • User ¡is ¡surprised ¡by ¡the ¡game ¡ – but ¡later ¡understands ¡why ¡ • Feeling ¡that ¡reality ¡will ¡provide ¡answers ¡ – able ¡to ¡make ¡progress ¡solving ¡problem ¡ • What ¡games ¡have ¡used ¡AI ¡effecJvely? ¡ CS ¡2501 ¡ 9

  10. The ¡Bar ¡To ¡Reach ¡ • Have ¡you ¡failed ¡in ¡your ¡a]empt ¡to ¡create ¡a ¡ game ¡if ¡your ¡NPCs ¡can’t ¡pass ¡the ¡Turing ¡Test? ¡ • NO! ¡ ¡Of ¡course ¡not! ¡ • SomeJmes ¡NPCs ¡can ¡pass ¡the ¡Turing ¡Test ¡in ¡ very ¡specific ¡circumstances ¡ – Computer ¡chess ¡player ¡ • SomeJmes ¡NPCs ¡will ¡never ¡pass ¡the ¡Turing ¡ Test ¡and ¡we’re ¡okay ¡with ¡that! ¡ – Koopa ¡Troopas ¡in ¡Super ¡Mario ¡Bros. ¡3 ¡ CS ¡2501 ¡ 10

  11. “Good ¡Enough” ¡ • Your ¡AI ¡needs ¡to ¡be ¡“good ¡enough ¡for ¡the ¡ player ¡to ¡be ¡challenged…” ¡ • And ¡“bad ¡enough ¡for ¡the ¡player ¡to ¡have ¡fun…” ¡ • Games ¡are ¡ocen ¡played ¡to ¡escape ¡from ¡reality ¡ • Playing ¡against ¡an ¡AI ¡that’s ¡“too ¡good” ¡is ¡ incredibly ¡frustraJng ¡ • Imagine ¡a ¡computer ¡player ¡of ¡Othello ¡or ¡ Scrabble ¡that ¡ONLY ¡took ¡opJmal ¡moves ¡ CS ¡2501 ¡ 11

  12. The ¡AI ¡Loop ¡ • Given ¡the ¡changes ¡to ¡the ¡environment, ¡what ¡ should ¡the ¡NPC ¡do? ¡ • CogniJon ¡of ¡the ¡NPC ¡ – PercepJon ¡(processing ¡the ¡state ¡of ¡the ¡ environment) ¡or ¡“Sense” ¡ – Decision ¡making ¡(decide ¡what ¡to ¡do ¡based ¡on ¡ percepJon) ¡or ¡“Plan” ¡ – Control ¡(update ¡NPC ¡one ¡Jme ¡step) ¡or ¡“Act” ¡ CS ¡2501 ¡ 12

  13. PercepJon ¡ • The ¡NPC’s ¡esJmaJon ¡of ¡game-­‑related ¡ informaJon ¡ • Includes ¡perceived ¡strategies ¡of ¡PCs ¡ • IdenJfies ¡most ¡important ¡factors ¡for ¡the ¡NPC ¡ to ¡respond ¡to ¡ • Think ¡of ¡it ¡as ¡the ¡NPCs ¡“a]enJon ¡span” ¡ CS ¡2501 ¡ 13

  14. Decision ¡Making ¡ • Determining ¡a ¡course ¡of ¡acJon ¡for ¡this ¡Jme ¡ step ¡for ¡this ¡parJcular ¡state ¡of ¡the ¡game ¡ • Usually ¡requires ¡a ¡trade ¡off ¡between ¡accuracy ¡ of ¡the ¡decision ¡and ¡speed ¡of ¡computaJon ¡ • Computer ¡COULD ¡simulate ¡out ¡several ¡steps ¡to ¡ make ¡a ¡“be]er” ¡decision, ¡but ¡at ¡a ¡cost ¡of ¡speed ¡ and ¡potenJally ¡“fun” ¡ CS ¡2501 ¡ 14

  15. Control ¡ • AdjusJng ¡the ¡appropriate ¡variables ¡of ¡the ¡NPC ¡ to ¡carry ¡out ¡the ¡decision ¡made ¡ – Steering ¡or ¡thro]le ¡in ¡a ¡racing ¡game ¡ – Crouching ¡or ¡taking ¡a ¡shot ¡in ¡an ¡FPS ¡ – Using ¡a ¡poJon ¡or ¡casJng ¡a ¡spell ¡in ¡an ¡RPG ¡ CS ¡2501 ¡ 15

  16. The ¡Sum ¡Of ¡The ¡Parts ¡ • The ¡sum ¡of ¡all ¡these ¡parts ¡makes ¡up ¡the ¡AI ¡of ¡ an ¡NPC ¡ • It ¡can ¡be ¡incredibly ¡complex ¡ – Large ¡fight ¡in ¡a ¡tacJcal ¡shooter ¡ • It ¡can ¡be ¡pa]ern ¡based ¡ – Behaviors ¡of ¡a ¡sentry ¡in ¡Metal ¡Gear ¡Solid ¡ – Behaviors ¡of ¡any ¡boxer ¡in ¡Punch ¡Out ¡ • It ¡can ¡be ¡… ¡well, ¡stupid ¡ – Goombas ¡or ¡Koopas ¡in ¡Super ¡Mario ¡Bros. ¡3 ¡ CS ¡2501 ¡ 16

  17. Pong ¡AI ¡ • What ¡is ¡the ¡challenge ¡in ¡creaJng ¡the ¡AI ¡for ¡ Pong? ¡ CS ¡2501 ¡ 17

  18. Chase/Evade ¡ • Consider ¡a ¡very ¡ ¡simple ¡AI ¡task ¡ • Algorithm ¡for ¡ ¡ the ¡predator? ¡ CS ¡2501 ¡

  19. AI ¡Strategies ¡ • ReacJon ¡vs. ¡DeliberaJon ¡ • When ¡having ¡the ¡NPC ¡make ¡a ¡decision, ¡how ¡ much ¡thought ¡goes ¡into ¡the ¡next ¡move? ¡ • How ¡is ¡the ¡AI ¡different ¡in: ¡ – Frozen ¡Synapse ¡ – Kingdom ¡Hearts ¡ – CivilizaJon ¡ – Halo ¡ CS ¡2501 ¡ 19

  20. AI ¡Strategies ¡ • ReacJon-­‑Based ¡ – Fast, ¡but ¡limited ¡capabiliJes ¡ • ImplementaJons ¡ – Finite-­‑State ¡Machines ¡ – Rule-­‑Based ¡Systems ¡ – Set ¡Pa]ern ¡ CS ¡2501 ¡ 20

  21. AI ¡Strategies ¡ • DeliberaJon-­‑Based ¡ – Much ¡slower, ¡but ¡more ¡adaptable ¡ • ImplementaJons ¡ – A* ¡/ ¡Dijkstra ¡ – Roadmaps ¡ – GeneJc ¡Algorithms ¡ CS ¡2501 ¡ 21

  22. Set ¡Pa]ern ¡ • Describe ¡the ¡AI ¡behavior ¡of ¡a ¡Koopa ¡Troopa ¡ – Or ¡any ¡other ¡bad ¡guy ¡from ¡SMB3 ¡ CS ¡2501 ¡ 22

  23. Finite-­‑State ¡Machines ¡ • An ¡abstract ¡construct ¡for ¡determining ¡the ¡ behavior ¡of ¡an ¡NPC ¡ • Any ¡given ¡behavior ¡state ¡is ¡represented ¡along ¡ with ¡rules ¡for ¡transiJoning ¡between ¡states ¡ • The ¡standard ¡bad ¡guys ¡in ¡Metal ¡Gear ¡Solid ¡are ¡ excellent ¡examples ¡of ¡this ¡ CS ¡2501 ¡ 23

  24. Switch ¡FSM ¡ CS ¡2501 ¡ 24

  25. Switch ¡FSM ¡ void RunLogic( int * state ) { switch( state ) { case 0: //Wander Wander(); if( SeeEnemy() ) { *state = 1; } break; case 1: //Attack Attack(); if( LowOnHealth() ) { *state = 2; } if( NoEnemy() ) { *state = 0; } break; case 2: //Flee Flee(); if( NoEnemy() ) { *state = 0; } break; } } ¡ CS ¡2501 ¡ 25

  26. Switch ¡FSM ¡ • Within ¡each ¡state ¡can ¡be ¡more ¡complex ¡AI ¡ • In ¡Metal ¡Gear ¡Solid, ¡when ¡an ¡enemy ¡sees ¡you, ¡ they ¡follow ¡you ¡as ¡long ¡as ¡you ¡are ¡“discovered” ¡ • When ¡the ¡discovery ¡period ¡expires, ¡the ¡ enemies ¡return ¡to ¡their ¡previous ¡state, ¡which ¡is ¡ set ¡pa]ern ¡ CS ¡2501 ¡ 26

  27. More ¡Advanced ¡FSM ¡ CS ¡2501 ¡ 27

  28. Problems ¡with ¡State ¡Machines ¡ • Too ¡Predictable ¡ – SomeJmes ¡a ¡good ¡thing, ¡someJmes ¡not ¡ • Limited ¡ – Can ¡have ¡a ¡very ¡small ¡set ¡of ¡opJons ¡available ¡at ¡ any ¡one ¡Jme ¡ CS ¡2501 ¡ 28

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend