Probability and Risk CS 4730 Computer Game Design - - PowerPoint PPT Presentation

probability and risk
SMART_READER_LITE
LIVE PREVIEW

Probability and Risk CS 4730 Computer Game Design - - PowerPoint PPT Presentation

Probability and Risk CS 4730 Computer Game Design Credit: Several slides from Walker White (Cornell) CS 4730 Quick Recap The game state


slide-1
SLIDE 1

CS ¡4730 ¡

Probability ¡and ¡Risk ¡

CS ¡4730 ¡– ¡Computer ¡Game ¡Design ¡ ¡ ¡ Credit: ¡Several ¡slides ¡from ¡Walker ¡White ¡(Cornell) ¡

slide-2
SLIDE 2

CS ¡4730 ¡

Quick ¡Recap ¡

  • The ¡game ¡state ¡is ¡the ¡current ¡posiBoning/value

¡

  • f ¡all ¡enBBes ¡in ¡the ¡game ¡world ¡
  • AcBons ¡a ¡player ¡takes ¡is ¡input ¡into ¡the ¡current ¡

game ¡state ¡

  • An ¡interacBon ¡is ¡a ¡funcBon ¡between ¡game ¡

states ¡as ¡determined ¡by ¡the ¡acBons ¡(of ¡both ¡ player ¡and ¡world) ¡in ¡generaBng ¡a ¡new ¡game ¡ state ¡

  • The ¡Game ¡Loop ¡

2

slide-3
SLIDE 3

CS ¡4730 ¡

The ¡Game ¡Loop ¡

  • In ¡general: ¡

– Handling ¡Bme ¡ – Gathering ¡player ¡input ¡ – Networking ¡ – SimulaBon ¡ – Collision ¡detecBon ¡and ¡response ¡ – Object ¡updates ¡ – Rendering ¡ – Other ¡miscellaneous ¡tasks ¡

3

slide-4
SLIDE 4

CS ¡4730 ¡

In ¡MonoGame ¡

  • IniBalize() ¡

– Network, ¡DB, ¡etc. ¡

  • LoadContent() ¡

– Graphics ¡and ¡other ¡assets ¡loaded ¡

  • Update(GameTime) ¡

– Update ¡the ¡game ¡state ¡based ¡on ¡input ¡

  • Draw(GameTime) ¡

– Refresh ¡the ¡screen ¡

4

slide-5
SLIDE 5

CS ¡4730 ¡

MonoGame ¡

  • Design ¡doc ¡due ¡Friday ¡

– Follow ¡requirements ¡for ¡WriZen ¡Word ¡

  • Prototype ¡due ¡next ¡Friday ¡

– We ¡will ¡expect ¡at ¡least ¡one ¡realized ¡mechanic ¡in ¡ the ¡game ¡ – We ¡do ¡NOT ¡expect ¡great ¡art, ¡music, ¡etc. ¡ – If ¡you ¡expect ¡controller ¡input ¡later, ¡we ¡expect ¡that ¡ now ¡

¡

5

slide-6
SLIDE 6

CS ¡4730 ¡

It ¡All ¡Start ¡With ¡Numbers ¡

  • Hope ¡you ¡remember ¡your ¡APMA ¡classes… ¡
  • Sta)s)cs ¡is ¡the ¡study ¡of ¡what ¡HAS ¡happened ¡
  • Probability ¡predicts ¡what ¡WILL ¡happen ¡
  • The ¡interesBng ¡this ¡is ¡that ¡people ¡are ¡

reasonably ¡good ¡at ¡staBsBcs, ¡but ¡horrible ¡at ¡ probability ¡

  • “What’s ¡the ¡likelihood ¡it ¡will ¡rain ¡tomorrow?” ¡

6

slide-7
SLIDE 7

CS ¡4730 ¡

Randomness ¡

  • Computers ¡are ¡actually ¡horrible ¡at ¡being ¡truly ¡

random ¡

  • Which ¡is ¡both ¡good ¡and ¡bad ¡
  • Bad ¡for ¡security ¡purposes ¡
  • Good ¡for ¡networked ¡games ¡to ¡have ¡the ¡same ¡

state ¡without ¡transmibng ¡that ¡state ¡

  • Probability ¡of ¡any ¡value ¡is ¡wriZen ¡as ¡P(x) ¡

7

slide-8
SLIDE 8

CS ¡4730 ¡

TradiBonal ¡Randomness ¡

  • Cards ¡and ¡dice ¡are ¡sBll ¡used ¡as ¡metaphors ¡for ¡

randomness ¡

  • (and ¡non-­‑metaphors…) ¡
  • We ¡sBll ¡uses ¡these ¡items ¡in ¡both ¡board ¡and ¡

video ¡games ¡for ¡randomness ¡

8

slide-9
SLIDE 9

CS ¡4730 ¡

Cards ¡and ¡Dice ¡

  • Card ¡notaBon: ¡ ¡

– 4S ¡– ¡4 ¡of ¡Spades ¡ – AH ¡– ¡Ace ¡of ¡Hearts ¡

  • Dice ¡notaBon ¡

– xdn, ¡where ¡x ¡is ¡the ¡number ¡of ¡dice ¡to ¡roll ¡and ¡n ¡is ¡ the ¡number ¡of ¡sides ¡on ¡each ¡dice ¡ – 2d6 ¡– ¡roll ¡2 ¡6-­‑sided ¡dice, ¡values ¡will ¡be ¡2-­‑12 ¡ – 3d8+4 ¡– ¡roll ¡3 ¡8-­‑sided ¡dice ¡and ¡add ¡4 ¡to ¡the ¡result, ¡ values ¡will ¡be ¡7-­‑28 ¡

9

slide-10
SLIDE 10

CS ¡4730 ¡

The ¡Outcome ¡Tree ¡

  • We ¡can ¡calculate ¡the ¡probability ¡of ¡any ¡random

¡ event ¡by ¡working ¡out ¡the ¡outcome ¡tree ¡and ¡ counBng ¡the ¡possibility ¡

  • Monte ¡Carlo ¡simulaBons ¡run ¡the ¡funcBon ¡for ¡a ¡

large ¡number ¡of ¡Bmes ¡and ¡using ¡that ¡to ¡ determine ¡percentages ¡

10

slide-11
SLIDE 11

CS ¡4730 ¡

Combining ¡ProbabiliBes ¡

  • P(not ¡A) ¡= ¡1 ¡– ¡P(A) ¡
  • P(A ¡or ¡B) ¡= ¡P(A) ¡+ ¡P(B) ¡
  • P(A ¡and ¡B) ¡= ¡P(A) ¡* ¡P(B) ¡

11

slide-12
SLIDE 12

CS ¡4730 ¡

Expected ¡Value ¡

  • The ¡expected ¡value ¡is ¡the ¡average ¡of ¡all ¡the ¡

possibiliBes ¡of ¡a ¡random ¡variable ¡

  • Each ¡value ¡is ¡weighted ¡by ¡its ¡probability ¡
  • E(x) ¡= ¡Sum(k ¡* ¡P(“x=k”)) ¡over ¡the ¡possible ¡

values ¡of ¡k ¡

  • E(1d2) ¡= ¡1 ¡* ¡P(“x=1”) ¡+ ¡2 ¡* ¡P(“x=2”) ¡

¡ ¡= ¡1 ¡* ¡.5 ¡+ ¡2 ¡* ¡.5 ¡ ¡ ¡= ¡1.5 ¡

12

slide-13
SLIDE 13

CS ¡4730 ¡

Dice ¡Expected ¡Values ¡

  • E(1d4) ¡= ¡2.5 ¡
  • E(1d6) ¡= ¡3.5 ¡
  • E(1d8) ¡= ¡4.5 ¡
  • E(1d10) ¡= ¡5.5 ¡
  • E(1d12) ¡= ¡6.5 ¡
  • E(1d20) ¡= ¡10.5 ¡

13

slide-14
SLIDE 14

CS ¡4730 ¡

Variance ¡

  • What ¡is ¡the ¡distribuBon ¡of ¡possible ¡values ¡

about ¡the ¡expected ¡value? ¡

  • Var(x) ¡= ¡E((x ¡– ¡E(x))2) ¡
  • Uniform ¡(high ¡variance) ¡
  • Bimodal ¡(low ¡and ¡high ¡variance) ¡
  • Gaussian ¡(low ¡and ¡high ¡variance) ¡
  • Zero ¡variance ¡

14

slide-15
SLIDE 15

CS ¡4730 ¡

Compound ¡Expressions ¡

  • E(x ¡+ ¡y) ¡= ¡E(x) ¡+ ¡E(y) ¡
  • E(x ¡+ ¡c) ¡= ¡E(x) ¡+ ¡c ¡
  • E(c ¡* ¡x) ¡= ¡c ¡* ¡E(x) ¡
  • E(x ¡* ¡y) ¡= ¡E(x) ¡* ¡E(y) ¡
  • Var(x ¡+ ¡y) ¡= ¡Var(x) ¡+ ¡Var(y) ¡
  • Var(x ¡+ ¡c) ¡= ¡Var(x) ¡
  • Var(c ¡* ¡x) ¡= ¡c2 ¡* ¡Var(x) ¡

15

slide-16
SLIDE 16

CS ¡4730 ¡

ProbabiliBes ¡of ¡Catan ¡

  • Let’s ¡look ¡at ¡the ¡math ¡of ¡Catan ¡to ¡figure ¡out ¡

how ¡probabiliBes ¡play ¡into ¡the ¡game ¡

  • Quick ¡overview ¡of ¡the ¡rules ¡of ¡SeZlers ¡of ¡Catan ¡

– hZp://www.catan.com/service/game-­‑rules ¡

16

slide-17
SLIDE 17

CS ¡4730 ¡

SeZlers ¡of ¡Catan ¡

17

slide-18
SLIDE 18

CS ¡4730 ¡

ProbabiliBes ¡of ¡Catan ¡

  • It’s ¡actually ¡preZy ¡easy ¡to ¡know ¡what’s ¡the ¡

“best” ¡opBon ¡

– Just ¡add ¡up ¡the ¡dots! ¡

  • Probability ¡and ¡randomness ¡plays ¡a ¡HUGE ¡role ¡

in ¡Catan ¡working ¡“correctly.” ¡

  • What ¡about ¡games ¡in ¡which ¡probability ¡and ¡

randomness ¡is ¡the ¡enBre ¡game? ¡

18

slide-19
SLIDE 19

CS ¡4730 ¡

Chutes ¡and ¡Ladders ¡

19

slide-20
SLIDE 20

CS ¡4730 ¡

Chutes ¡and ¡Ladders ¡

  • The ¡game ¡is ¡ALL ¡RANDOM. ¡
  • But ¡a ¡video ¡game ¡that ¡is ¡ALL ¡SKILL ¡can ¡

eventually ¡get ¡boring! ¡

– You’ve ¡learned ¡every ¡paZern ¡ – You’ve ¡seen ¡every ¡level ¡and ¡enemy ¡ – Nothing ¡varies! ¡

  • We ¡need ¡to ¡consider ¡games ¡that ¡have ¡some ¡

aspects ¡of ¡both! ¡

20

slide-21
SLIDE 21

CS ¡4730 ¡

Why ¡do ¡people ¡gamble? ¡

  • Let’s ¡face ¡it ¡– ¡gambling ¡in ¡Vegas ¡is ¡a ¡losing ¡

proposiBon ¡

  • Over ¡Bme, ¡everyone ¡loses ¡money ¡
  • But ¡in ¡the ¡(very) ¡short ¡term, ¡it’s ¡definitely ¡

possible ¡to ¡win ¡

  • And ¡besides ¡– ¡risk ¡and ¡uncertainty ¡can ¡be ¡a ¡lot ¡
  • f ¡fun! ¡

21

slide-22
SLIDE 22

CS ¡4730 ¡

Psychology ¡of ¡Randomness ¡

  • Player’s ¡like ¡longshots! ¡

– How ¡many ¡Bmes ¡have ¡you ¡gone ¡for ¡the ¡“super ¡ move” ¡to ¡win ¡the ¡game? ¡ – Even ¡if ¡it’s ¡a ¡low ¡probability, ¡players ¡will ¡opBmize ¡ for ¡it! ¡

  • Player’s ¡suffer ¡from ¡too ¡much ¡Monte ¡Carlo ¡

– “Oh, ¡I’ve ¡goZen ¡bad ¡results ¡for ¡so ¡long… ¡a ¡good ¡ card/good ¡roll ¡has ¡to ¡come ¡up ¡soon!” ¡ – Probability ¡does ¡not ¡care ¡what ¡the ¡last ¡roll ¡was, ¡but ¡ players ¡will ¡think ¡the ¡game ¡is ¡“unfair” ¡otherwise! ¡

22

slide-23
SLIDE 23

CS ¡4730 ¡

Psychology ¡of ¡Randomness ¡

  • But ¡think ¡about ¡it ¡another ¡way ¡– ¡I ¡bet ¡you ¡

remember ¡those ¡big ¡payoff ¡moments ¡

  • And ¡THAT’S ¡what ¡gets ¡you ¡coming ¡back ¡to ¡a ¡

game! ¡

23

slide-24
SLIDE 24

CS ¡4730 ¡

Other ¡Forms ¡of ¡Risk ¡

  • Imperfect ¡informaBon ¡can ¡add ¡to ¡the ¡

challenge/risk ¡in ¡a ¡game ¡without ¡as ¡much ¡ randomness ¡

  • Perhaps ¡you ¡don’t ¡know ¡everything ¡about ¡the ¡

game ¡state ¡

– Either ¡AI ¡or ¡another ¡player ¡

  • Perhaps ¡don’t ¡know ¡about ¡the ¡game ¡might ¡

change ¡

24

slide-25
SLIDE 25

CS ¡4730 ¡

Fog ¡of ¡War ¡-­‑ ¡ParBal ¡

25

slide-26
SLIDE 26

CS ¡4730 ¡

Fog ¡of ¡War ¡-­‑ ¡Total ¡

26

slide-27
SLIDE 27

CS ¡4730 ¡

InformaBon ¡Types ¡

  • Info ¡known ¡to ¡all ¡players ¡
  • Info ¡known ¡by ¡one ¡player ¡
  • Info ¡known ¡by ¡the ¡game ¡only ¡

– Some ¡game ¡state ¡informaBon, ¡like ¡next ¡card ¡in ¡the ¡ deck ¡

  • Info ¡unknown ¡

– Next ¡random ¡number ¡to ¡be ¡generated ¡

27

slide-28
SLIDE 28

CS ¡4730 ¡

Difference ¡Between ¡Video ¡and ¡Board ¡

  • Table ¡top ¡games ¡rely ¡on ¡randomness ¡to ¡work ¡

– InformaBon ¡that ¡the ¡game ¡only ¡knows ¡can ¡be ¡hard ¡ to ¡manage ¡ – D&D ¡does ¡this ¡through ¡a ¡Dungeon ¡Master ¡

  • However, ¡while ¡computers ¡aren’t ¡as ¡good ¡at ¡

randomness, ¡they ¡are ¡fantasBc ¡at ¡managing ¡ informaBon ¡

  • ImplementaBon ¡and ¡adherence ¡to ¡rules ¡also ¡

varies ¡greatly ¡

28