![Page 1: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/1.jpg)
Algorithms for Computer Games
Jouni Smed Department of Information Technology
University of Turku
http://www.iki.fi/smed
![Page 2: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/2.jpg)
Course syllabus
n credits: 5 cp (3 cu) n prerequisites
n fundamentals of algorithms and data structures (e.g., Cormen et al., Introduction to Algorithms)
n knowledge in programming (e.g., with Java)
n assessment n examination only (no exercises)
![Page 3: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/3.jpg)
Lectures
n Lecture times n Tuesdays 10–12 a.m. n Thursdays 10–12 a.m.
n September 8 – October 8, 2009 n Lecture room B2033, ICT Building
![Page 4: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/4.jpg)
Examinations 1(2)
n examination dates (to be confirmed) 1. ?? (possibly October 2009) 2. ?? (possibly November 2009) 3. ?? (possibly January 2010)
n check the exact times and places at http://www.it.utu.fi/opetus/tentit/
n remember to enrol! https://ssl.utu.fi/nettiopsu/
![Page 5: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/5.jpg)
Examinations 2(2)
n questions n based on both lectures and the textbook n two questions, à 5 points n to pass the examination, at least 5 points (50%) are
required n grade: g = ⎡p − 5⎤ n questions are in English, but you can answer in
English or in Finnish
![Page 6: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/6.jpg)
Web page
http://www.iki.fi/smed/a4cg
n news and announcements n slides, code examples, additional material n discussion forum
![Page 7: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/7.jpg)
Follow-up course: Multiplayer Computer Games
n focus: networking in computer games n credits: 5 cp (3 cu) n schedule:
n October 27 – November 26, 2009 n Tuesdays 10–12 a.m., and Thursdays 10–12 a.m.
n web page: http://www.iki.fi/smed/mcg
![Page 8: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/8.jpg)
Textbook
n Jouni Smed & Harri Hakonen: Algorithms and Networking for Computer Games, John Wiley & Sons, 2006.
n http://www.wiley.com/go/smed
![Page 9: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/9.jpg)
Computer games
![Page 10: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/10.jpg)
In the beginning...
“If, when walking down the halls of MIT, you should happen to hear strange cries of ‘No! No! Turn! Fire! ARRRGGGHHH!!,’ do not be alarmed. Another western is not being filmed—MIT students and others are merely participating in a new sport, SPACEWAR!”
D. J. Edwards & J. M. Graetz, “PDP-1 Plays at Spacewar”, Decuscope, 1(1):2–4, April 1962
![Page 11: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/11.jpg)
...and then
n 1962: Spacewar n 1971: Nutting: Computer Space n 1972: Atari: Pong n 1978: Midway: Space Invaders n 1979: Roy Trubshaw: MUD n 1980: Namco: Pac-Man n 1981: Nintendo: Donkey Kong n 1983: Commodore 64
n 1985: Alexei Pajitnov: Tetris n 1989: Nintendo Game Boy n 1993: id Software: Doom n 1994: Sony Playstation n 1997: Origin: Ultima Online n 2001: Microsoft Xbox n 2006: Nintendo Wii
![Page 12: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/12.jpg)
Three academic perspectives to computer games
GAME
Humanistic perspective
Administrative/ business
perspective
Technical perspective
Game design
Game programming
Software development
n rules n graphics n animation n audio
n gfx & audio n simulation n networking n AI
n design patterns n architectures n testing n reuse
![Page 13: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/13.jpg)
Game development is team work
source: Game Developer, 2005
![Page 14: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/14.jpg)
Intention of this cource
n to provide a glance into the world of computer games as seen from the perspective of a computer scientist
![Page 15: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/15.jpg)
Contents
§1 Introduction §2 Random Numbers §3 Tournaments §4 Game Trees §5 Path Finding §6 Decision-making §7 Modelling Uncertainty
![Page 16: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/16.jpg)
§1 Introduction
n definitions: play, game, computer game n anatomy of computer games n synthetic players n multiplaying n games and story-telling n other game design considerations
![Page 17: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/17.jpg)
First, a thought game
n what features are common to all games?
![Page 18: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/18.jpg)
Components of a game
n players: willing to participate for enjoyment, diversion or amusement
n rules: define limits of the game n goals: gives a sense of purpose n opponents: give arise to contest and rivarly n representation: concretizes the game
![Page 19: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/19.jpg)
player
rules goal
opponent representation
definition
CHALLENGE
obstruction
CONFLICT
correspondence
PLAY
Components, relationships and aspects of a game
![Page 20: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/20.jpg)
Definition for ‘computer game’
n a game that is carried out with the help of a computer program
n roles: n coordinating the game process n illustrating the situation n participating as a player
→ Model–View–Controller architectural pattern
![Page 21: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/21.jpg)
Model–View–Controller
control logic
driver
proto-view
rendering
state instance core structures
input device
action
configuration
instance data
synthetic view
synthetic player
script output device
human player
options
perception
model
view controller
![Page 22: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/22.jpg)
Synthetic players
n synthetic player = computer-generated actor in the game n displays human-like features n has a stance towards the human player
n games are anthropocentric!
![Page 23: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/23.jpg)
Humanness
n human traits and characteristics n fear and panic (Half-Life, Halo)
n computer game comprising only synthetic players n semi-autonomous actors (The Sims) n fully autonomous actors (Core War, AOE2)
![Page 24: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/24.jpg)
Stance towards the player
n enemy
ally
neutral
![Page 25: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/25.jpg)
Enemy
n provides challenge n opponent
n must demonstrate intelligent (or at least purposeful) behaviour
n cheating n quick-and-dirty methods n when the human player cannot observe enemy’s
actions
![Page 26: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/26.jpg)
Ally
n augmenting the user interface n hints and guides
n aiding the human player n reconnaissance officer n teammate, wingman
n should observe the human point of view n provide information in an accessible format n consistency of actions
![Page 27: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/27.jpg)
Neutral
n commentator n highlighting events and providing background
information
n camera director n choosing camera views, angles and cuts
n referee n judging the rule violations
n should observe the context and conventions
![Page 28: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/28.jpg)
Studying synthetic players: AIsHockey
n simplified ice hockey: n official IIHF rules n realistic measures and
weights n Newtonian physics
engine
n distributed system n client/server
architecture
n implemented with Java n source code available
(under BSD licence)
![Page 29: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/29.jpg)
Example: MyAI.java
import fi.utu.cs.hockey.ai.*; public class MyAI extends AI implements Constants { public void react() { if (isPuckWithinReach()) { head(headingTo(0.0, THEIR_GOAL_LINE)); brake(0.5); shoot(1.0); say(1050L); } else { head(headingTo(puck())); dash(1.0); } } }
![Page 30: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/30.jpg)
Try it yourself!
n challenge: implement a team of autonomous collaborating synthetic players
n the platform and ready-to-use teams available at: http://www.iki.fi/smed/aishockey
![Page 31: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/31.jpg)
Multiplaying
n multiple human players sharing the same game n methods:
n divide the screen n divide the playtime n networking
All this and more in the follow-up course Multiplayer Computer Games starting October 27, 2009.
![Page 32: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/32.jpg)
Games and story-telling
n traditional, linear story-telling n events remain from time to time (almost) unchangeable n books, theatre, cinema n participant (reader, watcher) is passive
n interactive story-telling n events change and adapt to the choices the participant makes n computer games n participant (player) is active
![Page 33: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/33.jpg)
A story is always told to human beings
n story-telling is not about actions but reasons for actions n humans use a story (i.e., a narrative) to understand
intentional behaviour n how can we model and generate this?
n story-telling is about humans n humans humanize the characters’ behaviour and
understand the story through themselves n how can we model and generate this?
All this and more in the course Interactive Storytelling lectured in the Autumn 2010.
![Page 34: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/34.jpg)
Other game design considerations
n customization n tutorial n profiles n modification n replaying
→ parameterization!
![Page 35: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/35.jpg)
§2 Random Numbers
n what is randomness? n linear congruential method
n parameter choices n testing
n random shuffling n uses in computer games
![Page 36: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/36.jpg)
What are random numbers good for (according to D.E.K.)
n simulation n sampling n numerical analysis n computer programming n decision-making n aesthetics n recreation
![Page 37: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/37.jpg)
Random numbers?
n there is no such thing as a ‘random number’ n is 42 a random number?
n definition: a sequence of statistically independent random numbers with a uniform distribution n numbers are obtained by chance n they have nothing to do with the other numbers in
the sequence
n uniform distribution: each possible number is equally probable
![Page 38: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/38.jpg)
Methods
n random selection n drawing balls out of a ‘well-stirred urn’
n tables of random digits n decimals from π
n generating data n white noise generators n cosmic background radiation
n computer programs?
![Page 39: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/39.jpg)
Generating random numbers with arithmetic operations
n von Neumann (ca. 1946): middle square method n take the square of previous number and extract the
middle digits
n example: four-digit numbers n ri = 8269 n ri + 1 = 3763 (ri
2 = 68376361) n ri + 2 = 1601 (ri + 1
2 = 14160169) n ri + 3 = 5632 (ri + 2
2 = 2563201)
![Page 40: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/40.jpg)
Truly random numbers?
n each number is completely determined by its predecessor!
n sequence is not random but appears to be n → pseudo-random numbers n all random generators based arithmetic
operation have their own in-built characteristic regularities
n hence, testing and analysis is required
![Page 41: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/41.jpg)
Middle square (revisited)
n another example: n ri = 6100 n ri + 1 = 2100 (ri
2 = 37210000) n ri + 2 = 4100 (ri + 1
2 = 4410000) n ri + 3 = 8100 (ri + 2
2 = 16810000) n ri + 4 = 6100 = ri (ri + 3
2 = 65610000)
n how to counteract?
![Page 42: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/42.jpg)
Words of the wise
n ‘random numbers should not be generated with a method chosen at random’ — D. E. Knuth
n ‘Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin.’ — J. von Neumann
![Page 43: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/43.jpg)
Even the wise get humbled 1(2)
source: Knuth, 1998
![Page 44: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/44.jpg)
Even the wise get humbled 2(2)
source: Knuth, 1998
![Page 45: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/45.jpg)
Words of the more (or less) wise
n ‘We guarantee that each number is random individually, but we don’t guarantee that more than one of them is random.’ — anonymous computer centre’s programming consultant (quoted in Numerical Recipes in C)
![Page 46: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/46.jpg)
Other concerns
n speed of the algorithm n ease of implementation n parallelization techniques n portable implementations
![Page 47: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/47.jpg)
Linear congruential method
n D. H. Lehmer (1949) n choose four integers
n modulus: m (0 < m) n multiplier: a (0 ≤ a < m) n increment: c (0 ≤ c < m) n starting value (or seed): X0 (0 ≤ X0 < m)
n obtain a sequence 〈Xn〉 by setting Xn + 1 = (aXn + c) mod m (n ≥ 0)
![Page 48: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/48.jpg)
Linear congruential method (cont’d)
n let b = a – 1 n generalization:
Xn + k = (akXn + (ak – 1) c/b) mod m (k ≥ 0, n ≥ 0)
n random floating point numbers Un ∈ [0, 1): Un = Xn / m
![Page 49: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/49.jpg)
![Page 50: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/50.jpg)
Random integers from a given interval
n Monte Carlo methods n approximate solution n accuracy can be improved at the cost
of running time
n Las Vegas methods n exact solution n termination is not guaranteed
n Sherwood methods n exact solution, termination guaranteed n reduce the difference between good
and bad inputs
![Page 51: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/51.jpg)
![Page 52: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/52.jpg)
![Page 53: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/53.jpg)
Choice of modulus m
n sequence of random numbers is finite → period (repeating cycle)
n period has at most m elements → modulus should be large
n recommendation: m is a prime n reducing modulo: m is a power of 2
n m = 2i : x mod m = x п (2i – 1)
![Page 54: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/54.jpg)
Choice of multiplier a
n period of maximum length n a = c = 1: Xn + 1 = (Xn + 1) mod m n hardly random: …, 0, 1, 2, …, m – 1, 0, 1, 2, …
n results from Theorem 2.1.1 n if m is a product of distinct primes, only a = 1 produces full
period n if m is divisible by a high power of some prime, there is
latitude when choosing a
n rules of thumb n 0.01m < a < 0.99m n no simple, regular bit patterns in the binary representation
![Page 55: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/55.jpg)
Choice of increment c
n no common factor with m n c = 1 n c = a
n if c = 0, addition operation can be eliminated n faster processing n period length decreases
![Page 56: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/56.jpg)
Choice of starting value X0
n determines from where in the sequence the numbers are taken
n to guarantee randomness, initialization from a varying source n built-in clock of the computer n last value from the previous run
n using the same value allows to repeat the sequence
![Page 57: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/57.jpg)
Tests for randomness 1(2)
n Frequency test n Serial test n Gap test n Poker test n Coupon collector’s test
![Page 58: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/58.jpg)
Tests for randomness 2(2)
n Permutation test n Run test n Collision test n Birthday spacings test n Spectral test
![Page 59: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/59.jpg)
Spectral test
n good generators will pass it n bad generators are likely to fail it n idea:
n let the length of the period be m n take t consecutive numbers n construct a set of t-dimensional points:
{ (Xn, Xn + 1, …, Xn + t – 1) | 0 ≤ n < m }
n when t increases the periodic accuracy decreases n a truly random sequence would retain the accuracy
![Page 60: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/60.jpg)
Spectral test results 1(3)
source: Knuth, 1998
![Page 61: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/61.jpg)
Spectral test results 2(3)
source: Hellekalek, 1998
![Page 62: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/62.jpg)
Spectral test results 3(3)
source: Hellekalek, 1998
![Page 63: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/63.jpg)
Random shuffling
n generate random permutation, where all permutations have a uniform random distribution
n shuffling ≈ inverse sorting (!) n ordered set S = 〈s1, …, sn〉 to be shuffled n naïve solution
n enumerate all possible n! permutations n generate a random integer [1, n!] and select the corresponding
permutation n practical only when n is small
![Page 64: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/64.jpg)
Random sampling without replacement
n guarantees that the distribution of permutations is uniform n every element has a probability 1/n to become selected in the
first position n subsequent position are filled with the remaining n – 1
elements n because selections are independent, the probability of any
generated ordered set is 1/n · 1/(n – 1) · 1/(n – 2) · … · 1/1 = 1/n!
n there are exactly n! possible permutations → generated ordered sets have a uniform distribution
![Page 65: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/65.jpg)
![Page 66: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/66.jpg)
Riffle shuffle
![Page 67: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/67.jpg)
Perfect shuffle
![Page 68: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/68.jpg)
Premo: Standard order
![Page 69: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/69.jpg)
Premo: After a riffle shuffle and card insertion
![Page 70: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/70.jpg)
Probability of success: 52 cards, m shuffles, n guesses
m n
2 3 4 5 6 7 8 9 10 11 12 ∞
1 997 839 288 088 042 028 023 021 020 020 019 019
2 1000 943 471 168 083 057 047 042 040 039 039 038
3 1000 965 590 238 123 085 070 063 061 059 058 058
13 1000 998 884 617 427 334 290 270 260 254 252 250
26 1000 999 975 835 688 596 548 524 513 505 503 500
cut-off
![Page 71: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/71.jpg)
Cut-off phenomenon: distance d from the perfect shuffle, critical number k0
source: Aldous & Diaconis, 1986
![Page 72: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/72.jpg)
Random numbers in games
n terrain generation n events n character creation n decision-making n game world compression n synchronized simulation
![Page 73: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/73.jpg)
Game world compression
n used in Elite (1984) n finite and discrete galaxy n enumerate the positions n set the seed value n generate a random value for each position
n if smaller than a given density, create a star n otherwise, space is void
n each star is associated with a randomly generated number, which used as a seed when creating the star system details (name, composition, planets)
n can be hierarchically extended
![Page 74: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/74.jpg)
![Page 75: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/75.jpg)
![Page 76: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/76.jpg)
![Page 77: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/77.jpg)
Example: Elite
![Page 78: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/78.jpg)
Random game world generation
n discrete game worlds n example: Nethack, Age of Empires n rooms, passages, item placements
n continuous game worlds n random world is not believable n modular segments put together randomly
n terrain generation
![Page 79: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/79.jpg)
Example: Age of Empires 2
![Page 80: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/80.jpg)
Terraing generation: height map
![Page 81: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/81.jpg)
Terrain generation methods
n simple random n limited random n particle deposition n fault line n circle hill n midpoint displacement
![Page 82: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/82.jpg)
Simple random terrain
![Page 83: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/83.jpg)
![Page 84: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/84.jpg)
Limited random terrain
![Page 85: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/85.jpg)
![Page 86: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/86.jpg)
Particle deposition terrain
![Page 87: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/87.jpg)
![Page 88: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/88.jpg)
![Page 89: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/89.jpg)
![Page 90: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/90.jpg)
Fault line terrain
![Page 91: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/91.jpg)
![Page 92: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/92.jpg)
![Page 93: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/93.jpg)
Circle hill terrain
![Page 94: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/94.jpg)
![Page 95: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/95.jpg)
Midpoint displacement terrain
![Page 96: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/96.jpg)
![Page 97: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/97.jpg)
![Page 98: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/98.jpg)
![Page 99: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/99.jpg)
§3 Tournaments
n rank adjustment (or challege) tournament n each match is a challenge for a rank exchange n types: ladder, hill climbing, pyramid, king of the hill
n elimination tournament (or cup) n each match eliminates the loser from the tournament n types: single elimination
n scoring tournament n each match rewards the winner n types: round robin
n hybridizations
![Page 100: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/100.jpg)
Other uses
n game balancing n duelling synthetic players n adjusting point rewarding schemes
n heuristic search n selecting suboptimal candidates for a genetic algorithm
n group behaviour n modelling pecking order
n learning player characteristics n managing history knowledge
![Page 101: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/101.jpg)
Example: Hill climbing tournament
Juhani
Tuomas
Aapo
Simeoni
Timo
Lauri
Eero
m0
m3
m1
m4
m2
m5
![Page 102: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/102.jpg)
Example: Elimination tournament
Juhani
Tuomas
Aapo
Simeoni
Timo
Lauri
Eero
m0
m1
m2
m3
m4
m5
![Page 103: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/103.jpg)
Example: Scoring tournament
Tuomas Aapo Simeoni Timo Lauri Eero
Juhani m0 m6 m11 m15 m18 m20
Tuomas m1 m7 m12 m16 m19
Aapo m2 m8 m13 m17
Simeoni m3 m9 m14
Timo m4 m10
Lauri m5
![Page 104: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/104.jpg)
Terms
n players: p0…pn − 1
n match between pi and pj: match(i, j) n outcome: WIN, LOSE, TIE
n rank of pi: rank(i) n players with the rank r: rankeds(r) n round: a set of (possibly) concurrent matches n bracket: diagram of match pairings and rounds
![Page 105: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/105.jpg)
Rank adjustment tournaments
n a set of already ranked players n matches
n independent from one another n outcome affects only the participating players
n suits on-going tournaments n example: boxing
n matches can be limited by the rank difference
![Page 106: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/106.jpg)
Ladder and pyramid tournaments
pi: rank(i) = 0
pj: rank(j) = 1
pk: rank(k) = 2
pm: rank(m) = 3
pn: rank(n) = 4
pi: rank(i) = 0
pj: rank(j) = 1
pk: rank(k) = 2
pm: rank(m) = 2
pn: rank(n) = 2
rankeds(2) = { k, m, n }
![Page 107: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/107.jpg)
![Page 108: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/108.jpg)
Hill-climbing tournament
n a.k.a. n top-of-the-mountain tournament n last man standing tournament
n specialization of the ladder tournament n reigning champion defends the title against challlengers n similarly: king of the hill tournament specializes the pyramid
tournament
n initialization n based on previous competitions n random
![Page 109: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/109.jpg)
![Page 110: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/110.jpg)
Elimination tournaments
n loser of a match is eliminated from the tournament n no ties! → tiebreak competition
n winner of a match continues to the next round n how to assign pairings for the first round?
n seeding
n examples n football cups, snooker tournaments
![Page 111: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/111.jpg)
Single elimination
pi
pj
pk
pm
pn
pq
pr
ps
final
semifinal
quarter-final
![Page 112: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/112.jpg)
Bye
bye
pi
pj
pk
pm
pn
pq
pr
![Page 113: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/113.jpg)
Seeding
n some match pairing will not occur in a single elimination tournament
n pairings for the first round (i.e., seeding) affects the future pairings
n seeding can be based on existing ranking n favour the top-ranked players n reachability: give the best players an equal
opportunity to proceed the final rounds
![Page 114: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/114.jpg)
Seeding methods
n random n does not favour any player n does not fulfil reachability criterion
n standard and ordered standard n favours the top-ranked players n ordered standard: matches are listed in increasing order
n equitable n in the first round, the rank difference between the players is
the same for each match
![Page 115: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/115.jpg)
![Page 116: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/116.jpg)
Byes and fairness
n the byes have bottom ranks so that they get paired with best players
n the byes appear only in the first round
![Page 117: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/117.jpg)
Runners-up
n we find only the champion n how to determine the runners-up (e.g. silver and
bronze medallists)?
n random pairing can reduce the effect of seeding n best players are put into different sub-brackets n the rest is seeded randomly
n re-seed the players before each round n previous matches indicate the current position
n multiple matches per round (best-of-m)
![Page 118: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/118.jpg)
Double elimination tournament
n two brackets n winners’ bracket n losers’ (or consolation) bracket
n initially everyone is in the winners’ bracket n if a player loses, he is moved to the losers’ bracket n if he loses again, he is out from the tournament
n the brackets are combined at some point n for example, the champion of the losers’ bracket
gets to the semifinal in the winners’ bracket
![Page 119: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/119.jpg)
Scoring tournaments
n round robin: everybody meets everybody else once
n scoring table determines the tournament winner n players are rewarded with scoring points n winner and tie
n matches are independent from one another
![Page 120: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/120.jpg)
Reduction to a graph
n n players n clique Kn n players as vertices, matches as edges n how to organize the rounds?
n a player has at most one match in a round n a round has as many matches as possible
K5
![Page 121: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/121.jpg)
Reduction to a graph (cont’d)
n if n is odd, partition the edges of the clique to (n − 1) / 2 disjoint sets n in each turn, one player is resting n player pi rests in the round i
n if n is even, reduce the problem n player pn − 1 is taken out from the clique n solve the pairings for n − 1 players as above n for each round, pair the resting player pi with
player pn − 1
![Page 122: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/122.jpg)
![Page 123: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/123.jpg)
Round robin with seven players
round matches resting
0 1 – 6 2 – 5 3 – 4 0
1 2 – 0 3 – 6 4 – 5 1
2 3 – 1 4 – 0 5 – 6 2
3 4 – 2 5 – 1 6 – 0 3
4 5 – 3 6 – 2 0 – 1 4
5 6 – 4 0 – 3 1 – 2 5
6 0 – 5 1 – 4 2 – 3 6
![Page 124: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/124.jpg)
![Page 125: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/125.jpg)
Real-world tournament examples
n boxing n reigning champion and challengers
n sport wrestling n double elimination: consolation bracket
n professional wrestling n royal rumble
n World Cup n ice hockey championship n snooker
![Page 126: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/126.jpg)
matches (n = 15) 14 14 14 105
rounds 14 6 4 15
champion’s matches
1…14 1…6 3…4 14
match in a round 1 1…4 1…7 7
![Page 127: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/127.jpg)
Practical considerations
n home matches n venue bookings n travelling times n risk management n other costs
![Page 128: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/128.jpg)
§4 Game Trees
n perfect information games n no hidden information
n two-player, perfect information games n Noughts and Crosses n Chess n Go
n imperfect information games n Poker n Backgammon n Monopoly
n zero-sum property n one player’s gain equals another player’s loss
![Page 129: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/129.jpg)
Game tree
n all possible plays of two-player, perfect information games can be represented with a game tree n nodes: positions (or states) n edges: moves
n players: MAX (has the first move) and MIN
n ply = the length of the path between two nodes n MAX has even plies counting from the root node n MIN has odd plies counting from the root node
![Page 130: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/130.jpg)
Division Nim with seven matches
![Page 131: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/131.jpg)
![Page 132: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/132.jpg)
Problem statement
Given a node v in a game tree find a winning strategy for MAX (or MIN) from v
or (equivalently) show that MAX (or MIN) can force a win from v
![Page 133: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/133.jpg)
Minimax
n assumption: players are rational and try to win n given a game tree, we know the outcome in the leaves
n assign the leaves to win, draw, or loss (or a numeric value like +1, 0, –1) according to MAX’s point of view
n at nodes one ply above the leaves, we choose the best outcome among the children (which are leaves) n MAX: win if possible; otherwise, draw if possible; else loss n MIN: loss if possible; otherwise, draw if possible; else win
n recurse through the nodes until in the root
![Page 134: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/134.jpg)
Minimax rules
1. If the node is labelled to MAX, assign it to the maximum value of its children.
2. If the node is labelled to MIN, assign it to the minimum value of its children.
n MIN minimizes, MAX maximizes → minimax
![Page 135: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/135.jpg)
MAX
MAX
MAX
MIN
MIN
MIN +1
–1
+1
+1
+1 –1
–1 +1 +1 –1
–1 –1 –1
–1
![Page 136: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/136.jpg)
![Page 137: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/137.jpg)
![Page 138: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/138.jpg)
Analysis
n simplifying assumptions n internal nodes have the same branching factor b n game tree is searched to a fixed depth d
n time consumption is proportional to the number of expanded nodes n 1 — root node (the initial ply) n b — nodes in the first ply n b2 — nodes in the second ply n bd — nodes in the dth ply
n overall running time O(bd)
![Page 139: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/139.jpg)
Rough estimates on running times when d = 5
n suppose expanding a node takes 1 ms n branching factor b depends on the game n Draughts (b ≈ 3): t = 0.243 s n Chess (b ≈ 30): t = 6¾ h
n Go (b ≈ 300): t = 77 a
n alpha-beta pruning reduces b
![Page 140: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/140.jpg)
Controlling the search depth
n usually the whole game tree is too large → limit the search depth → a partial game tree → partial minimax
n n-move look-ahead strategy n stop searching after n moves n make the internal nodes (i.e., frontier nodes) leaves n use an evaluation function to ‘guess’ the outcome
![Page 141: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/141.jpg)
Evaluation function
n combination of numerical measurements mi(s, p) of the game state n single measurement: mi(s, p) n difference measurement: mi(s, p) − mj(s, q) n ratio of measurements: mi(s, p) / mj(s, q)
n aggregate the measurements maintaining the zero-sum property
![Page 142: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/142.jpg)
Example: Noughts and Crosses
n heuristic evaluation function e: n count the winning lines open to MAX
n subtract the number of winning lines open to MIN
n forced wins n state is evaluated +∞, if it is a forced win for MAX
n state is evaluated –∞, if it is forced win for MIN
![Page 143: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/143.jpg)
Examples of the evaluation
e(•) = 6 – 5 = 1
e(•) = 4 – 5 = –1
e(•) = +∞
![Page 144: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/144.jpg)
Drawbacks of partial minimax
n horizon effect n heuristically promising path can lead to an unfavourable
situation n staged search: extend the search on promising nodes n iterative deepening: increase n until out of memory or time n phase-related search: opening, midgame, end game n however, horizon effect cannot be totally eliminated
n bias n we want to have an estimate of minimax but get a minimax of
estimates n distortion in the root: odd plies → win, even plies → loss
![Page 145: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/145.jpg)
The deeper the better...?
n assumptions: n n-move look-ahead n branching factor b, depth d, n leaves with uniform random distribution
n minimax convergence theorem: n n increases → root value converges to f(b, d)
n last player theorem: n root values from odd and even plies not comparable
n minimax pathology theorem: n n increases → probability of selecting non-optimal move
increases (← uniformity assumption!)
![Page 146: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/146.jpg)
Alpha-beta pruning
n reduce the branching factor of nodes n alpha value
n associated with MAX nodes n represents the worst outcome MAX can achieve n can never decrease
n beta value n associated with MIN nodes n represents the worst outcome MIN can achieve n can never increase
![Page 147: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/147.jpg)
Example
n in a MAX node, α = 4 n we know that MAX can make a move which will
result at least the value 4 n we can omit children whose value is less than or
equal to 4
n in a MIN node, β = 4 n we know that MIN can make a move which will result
at most the value 4 n we can omit children whose value is greater than or
equal to 4
![Page 148: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/148.jpg)
![Page 149: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/149.jpg)
Rules of pruning
1. Prune below any MIN node having a beta value less than or equal to the alpha value of any of its MAX ancestors.
2. Prune below any MAX node having an alpha value greater than or equal to the beta value of any of its MIN ancestors
Or, simply put: If α ≥ β, then prune below!
![Page 150: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/150.jpg)
![Page 151: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/151.jpg)
![Page 152: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/152.jpg)
Example: αβ-pruning 1(3)
![Page 153: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/153.jpg)
Example: αβ-pruning 2(3)
![Page 154: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/154.jpg)
Example: αβ-pruning 3(3)
![Page 155: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/155.jpg)
Best-case analysis
n omit the principal variation n at depth d – 1 optimum pruning: each node
expands one child at depth d n at depth d – 2 no pruning: each node expands all
children at depth d – 1 n at depth d – 3 optimum pruning n at depth d – 4 no pruning, etc. n total amount of expanded nodes: Ω(bd/2)
![Page 156: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/156.jpg)
Principal variation search
n alpha-beta range should be small n limit the range artificially → aspiration search n if search fails, revert to the original range
n if we find a move between α and β, assume we have found a principal variation node n search the rest of nodes the assuming they will not produce a
good move n if the assumption fails, re-search the node
n works well if the principal variation node is likely to get selected first
![Page 157: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/157.jpg)
Games of chance
n minimax trees assume determistic moves n what about indeterministic events like tossing a coin,
casting a die or shuffling cards?
n chance nodes: *-minimax tree n expectiminimax
n if node v is labelled to CHANCE, multiply the probability of a child with its expectiminimax value and return the sum over all v’s children
n otherwise, act as in minimax
![Page 158: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/158.jpg)
§5 Path Finding
n common problem in computer games n routing characters, troops etc.
n computationally intensive problem n complex game worlds n high number of entities n dynamically changing environments n real-time response
![Page 159: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/159.jpg)
Problem statement
n given a start point s and a goal point r, find a path from s to r minimizing a given criterion
n search problem formulation n find a path that minimizes the cost
n optimization problem formulation n minimize cost subject to the constraint of the path
![Page 160: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/160.jpg)
The three phases of path finding
1. discretize the game world n select the waypoints and connections
2. solve the path finding problem in a graph n let waypoints = vertices, connections = edges,
costs = weights n find a minimum path in the graph
3. realize the movement in the game world n aesthetic concerns n user-interface concerns
![Page 161: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/161.jpg)
![Page 162: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/162.jpg)
![Page 163: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/163.jpg)
![Page 164: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/164.jpg)
Discretization
n waypoints (vertices) n doorways, corners, obstacles, tunnels, passages, …
n connections (edges) n based on the game world geometry, are two
waypoints connected
n costs (weights) n distance, environment type, difference in altitude, …
n manual or automatic process? n grids, navigation meshes
![Page 165: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/165.jpg)
Grid
n regular tiling of polygons n square grid n triangular grid n hexagonal grid
n tile = waypoint n tile’s neighbourhood =
connections
![Page 166: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/166.jpg)
![Page 167: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/167.jpg)
![Page 168: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/168.jpg)
Navigation mesh
n convex partitioning of the game world geometry n convex polygons covering the game world n adjacent polygons share only two points and one
edge n no overlapping
n polygon = waypoint n middlepoints, centre of edges
n adjacent polygons = connections
![Page 169: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/169.jpg)
![Page 170: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/170.jpg)
Solving the convex partitioning problem
n minimize the number of polygons n points: n n points with concave interior angle (notches): r ≤ n − 3
n optimal solution n dynamic programming: O(r2n log n)
n Hertel–Mehlhorn heuristic n number of polygons ≤ 4 × optimum n running time: O(n + r log r) n requires triangulation
n running time: O(n) (at least in theory) n Seidel’s algorithm: O(n lg* n) (also in practice)
![Page 171: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/171.jpg)
![Page 172: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/172.jpg)
![Page 173: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/173.jpg)
Path finding in a graph
n after discretization form a graph G = (V, E) n waypoints = vertices (V) n connections = edges (E) n costs = weights of edges (weight : E → R+)
n next, find a path in the graph
![Page 174: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/174.jpg)
Graph algorithms
n breadth-first search n running time: O(|V| + |E|)
n depth-first search n running time: Θ(|V| + |E|)
n Dijkstra’s algorithm n running time: O(|V|2) n can be improved to O(|V| log |V| + |E|)
![Page 175: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/175.jpg)
Heuristical improvements
n best-first search n order the vertices in the neighbourhood according to
a heuristic estimate of their closeness to the goal n returns optimal solution
n beam search n order the vertices but expand only the most
promising candidates n can return suboptimal solution
![Page 176: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/176.jpg)
![Page 177: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/177.jpg)
Evaluation function
n expand vertex minimizing f(v) = g(s ~> v) + h(v ~> r)
n g(s ~> v) estimates the minimum cost from the start vertex to v
n h(v ~> r) estimates (heuristically) the cost from v to the goal vertex
n if we had exact evaluation function f *, we could solve the problem without expanding any unnecessary vertices
![Page 178: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/178.jpg)
Cost function g
n actual cost from s to v along the cheapest path found so far n exact cost if G is a tree n can never underestimate the cost if G is a general
graph
n f(v) = g(s ~> v) and unit cost → breadth-first search
n f(v) = –g(s ~> v) and unit cost → depth-first search
![Page 179: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/179.jpg)
Heuristic function h
n carries information from outside the graph n defined for the problem domain n the closer to the actual cost, the less superfluous
vertices are expanded n f(v) = g(s ~> v) → cheapest-first search n f(v) = h(v ~> r) → best-first search
![Page 180: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/180.jpg)
![Page 181: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/181.jpg)
Admissibility
n let Algorithm A be a best-first search using the evaluation function f
n search algorithm is admissible if it finds the minimal path (if it exists) n if f = f *, Algorithm A is admissible
n Algorithm A* = Algorithm A using an estimate function h n A* is admissible, if h does not overestimate the
actual cost
![Page 182: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/182.jpg)
Monotonicity
n h is locally admissible → h is monotonic n monotonic heuristic is also admissible n actual cost is never less than the heuristic cost
→ f will never decrease n monotonicity → A* finds the shortest path to
any vertex the first time it is expanded n if a vertex is rediscovered, path will not be shorter n simplifies implementation
![Page 183: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/183.jpg)
Optimality
n Optimality theorem: The first path from s to r found by A* is optimal.
n Proof: textbook p. 105
![Page 184: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/184.jpg)
Informedness
n the more closely h approximates h*, the better A* performs
n if A1 using h1 will never expand a vertex that is not also expanded by A2 using h2, A1 is more informed that A2
n informedness → no other search strategy with the same amount of outside knowledge can do less work than A* and be sure of finding the optimal solution
![Page 185: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/185.jpg)
Algorithm A*
n because of monotonicity n all weights must be positive n closed list can be omitted
n the path is constructed from the mapping π starting from the goal vertex n s → … → π(π(π(r))) → π(π(r)) → π(r) → r
![Page 186: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/186.jpg)
![Page 187: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/187.jpg)
![Page 188: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/188.jpg)
A* example 1(6)
![Page 189: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/189.jpg)
A* example 2(6)
![Page 190: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/190.jpg)
A* example 3(6)
![Page 191: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/191.jpg)
A* example 4(6)
![Page 192: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/192.jpg)
A* example 5(6)
![Page 193: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/193.jpg)
A* example 6(6)
![Page 194: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/194.jpg)
Practical considerations
n computing h n despite the extra vertices expanded, less informed h
may yield computationally less intensive implementation
n suboptimal solutions n by allowing overestimation A* becomes
inadmissible, but the results may be good enough for practical purposes
![Page 195: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/195.jpg)
Realizing the movement
n movement through the waypoints n unrealistic: does not follow the game world
geometry n aesthetically displeasing: straight lines and sharp
turns
n improvements n line-of-sight testing n obstacle avoidance
n combining path finding to user-interface n real-time response
![Page 196: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/196.jpg)
![Page 197: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/197.jpg)
![Page 198: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/198.jpg)
Recapitulation
1. discretization of the game world n grid, navigation mesh n waypoints, connections, costs
2. path finding in a graph n Algorithm A*
3. realizing the movement n geometric corrections n aesthetic improvements
![Page 199: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/199.jpg)
Alternatives?
n Although this is the de facto approach in (commercial) computer games, are there alternatives?
n possible answers n AI processors (unrealistic?) n robotics: reactive agents (unintelligent?) n analytical approaches (inaccessible?)
![Page 200: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/200.jpg)
§6 Decision-Making
n decision-making and games n levels of decision-making n modelled knowledge n method
n example methods n finite state machines n flocking algorithms n influence maps
n this will not be a comprehensive guide into decision-making!
![Page 201: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/201.jpg)
MVC (revisited)
control logic
driver
proto-view
rendering
state instance core structures
input device
action
configuration
instance data
synthetic view
synthetic player
script output device
human player
options
perception
model
view controller
![Page 202: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/202.jpg)
Decision-making system
World Pattern recognition
Observed events and states
Decision-making system
Requested actions
Possible actions
Primitive events and states
Previous primitives
![Page 203: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/203.jpg)
Three perspectives for decision-making in computer games
n level of decision-making n strategic, tactical, operational
n use of the modelled knowledge n prediction, production
n methods n optimization, adaptation
![Page 204: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/204.jpg)
Level of decision-making
n strategic n what should be done
n tactical n how to actuate it
n operational n how to carry it out
![Page 205: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/205.jpg)
Strategic level
n long-term decisions n infrequent → can be computed offline or in the
background
n large amount of data, which is filtered to bring forth the essentials n quantization problem?
n speculative (what-if scenarios) n the cost of a wrong decision is high
![Page 206: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/206.jpg)
Tactical level
n medium-term decisions n intermediary between strategic and operational
levels n follow the plan made on the strategic level n convey the feedback from the operational level
n considers a group of entities n a selected set of data to be scrutinized n co-operation within the group
![Page 207: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/207.jpg)
Operational level
n short-term decisions n reactive, real-time response
n concrete and closely connected to the game world
n considers individual entities n the cost of a wrong decision is relatively low
n of course not to the entity itself
![Page 208: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/208.jpg)
Use of the modelled knowledge
n time series data n world = a generator of events and states, which
can be labelled with symbols n prediction
n what the generator will produce next?
n production n simulating the output of the generator
n how to cope with uncertainty?
![Page 209: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/209.jpg)
Prediction
Modeller
maximum probability Generator
![Page 210: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/210.jpg)
Production
Modeller
random selection from
probability distribution
![Page 211: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/211.jpg)
Decision-making methods
n optimization n find an optimal solution for a given objective
function n affecting factors can be modelled
n adaption n find a function behind the given solutions n affecting factors are unknown or dynamic
![Page 212: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/212.jpg)
Optimization
solution
optimality
local optimum
global optimum
objective function
![Page 213: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/213.jpg)
Optimization methods
n hill-climbing n how to escape local optima?
n tabu search n simulated annealing n genetic algorithms
n multiple search traces
n swarm algorithms
![Page 214: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/214.jpg)
Adaptation
solution
feedback
sample cases
fitted function
![Page 215: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/215.jpg)
Adaptation methods
n neural networks n training
n supervised learning n unsupervised learning (e.g., self-organizing maps)
n execution
n hidden Markov model n recurring structures
![Page 216: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/216.jpg)
Finite state machine (FSM)
n components: n states n transitions n events n actions
n state chart: fully connected directed graph n vertices = states n edges = transitions
![Page 217: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/217.jpg)
![Page 218: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/218.jpg)
Properties of FSM
1. acceptor n does the input sequence fulfil given criteria?
2. transducer n what is the corresponding output sequence for a
given input sequence?
3. computator n what is the sequence of actions for a given input
sequence?
n these properties are independent!
![Page 219: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/219.jpg)
![Page 220: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/220.jpg)
Mealy and Moore machines
n theoretical cathegories for FSMs n Mealy machine
n actions are in transitions n the next action is determined by the current state and the
occurring event n more compact but harder to comprehend
n Moore machine n actions are in states n the next action is determined by the next state
n helps to understand and use state machines in UML
![Page 221: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/221.jpg)
![Page 222: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/222.jpg)
Implementation
n design by contract n two parties: the supplier and the client n formal agreement using interfaces
n FSM software components n environment: view to the FSM (client) n context: handles the dynamic aspects of the FSM
(supplier) n structure: maintains the representation of the FSM
(supplier)
![Page 223: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/223.jpg)
![Page 224: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/224.jpg)
Noteworthy
n structure is static n hard to modify
n reactivity n memoryless representation of all possible walks from the
initial state n states are mutually exclusive: one state at a time
n not for continuous or multivalued values n combinatorial explosion
n if the states and events are independent n risk of total rewriting
n high cohesion of actions
![Page 225: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/225.jpg)
Flocking
n C. W. Reynolds: “Flocks, herds, and schools: A distributed behavioral model” (1987)
n a flock seems to react as autonomous entity although it is a collection of individual beings
n flocking algorithm emulates this phenomenon n results resemble various natural group
movements n boid = an autonomous agent in a flock
![Page 226: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/226.jpg)
Rules of flocking
1. Separation: Do not crowd flockmates. 2. Alignment: Move in the same direction as
flockmates. 3. Cohesion: Stay close to flockmates. 4. Avoidance: Avoid obstacles and enemies. → boid’s behavioural urges
![Page 227: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/227.jpg)
![Page 228: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/228.jpg)
![Page 229: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/229.jpg)
![Page 230: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/230.jpg)
![Page 231: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/231.jpg)
![Page 232: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/232.jpg)
Observations
n stateless algorithm n no information needs to be maintained n boid re-evaluates the environment on each update
cycle
n no centralized control n emergent behaviour
![Page 233: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/233.jpg)
Other uses for flocking
n swarm algorithms n solution candidate = boid n solution space = flying space n separation prevents crowding the local optima
n obstacle avoidance in path finding n steer away from obstacles along the path
![Page 234: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/234.jpg)
Influence maps
n discrete representation of the synthetic player’s knowledge of the world
n strategic and tactical information n frontiers, control points, weaknesses
n influence n type n repulsiveness/alluringness
n recall path finding and terrain generation
![Page 235: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/235.jpg)
Assumptions
n a regular grid over the game world n each tile holds numeric information of the
corresponding area n positive values: alluringness n negative values: repulsiveness
![Page 236: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/236.jpg)
Construction
1. initialization n assign values to the tiles where the influence exists
2. propagation n spread the effect to the neighbouring tiles n linear or exponential fall-off n cut-off point
![Page 237: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/237.jpg)
Example: Initialization and propagation
5 10 20 10 5
10 20 40 20 10
5 10 20 10 5
2 5 10 5 2
1 2 5 2 1
0 -1 -2 -2 -2
-1 -2 -6 -4 -6
-2 -6 -12 -10 -10
-5 -10 -20 -12 -10
-2 -5 -10 -6 -4
![Page 238: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/238.jpg)
Aggregation
n influence map can be combined n the same (or compatible) granularity
n example n map 1 = my troops n map 2 = enemy’s troops n map 3 = map 1 + map 2 = battlefield
n aggregation n operator: sum, product n weights: to balance the effects
![Page 239: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/239.jpg)
Example: Aggregation
5 9 18 8 3
9 18 36 16 4
3 4 8 0 -5
-3 -5 -10 -7 -8
-1 -3 -5 -4 -3
![Page 240: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/240.jpg)
Evaluation
n static features: compute beforehand n periodical updates
n categorize the maps based on the rate of change n lazy evaluation
![Page 241: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/241.jpg)
![Page 242: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/242.jpg)
![Page 243: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/243.jpg)
![Page 244: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/244.jpg)
Key questions for synthetic players
n how to achieve real-time response? n how to distribute the synthetic players in a
network? n how autonomous the synthetic players should
be? n how to communicate with other synthetic
players?
![Page 245: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/245.jpg)
§7 Modelling Uncertainty
n probabilistic uncertainty n probability of an outcome n dice, shuffled cards n statistical reasoning
n Bayesian networks, Dempster-Shafer theory
n possibilistic uncertainty n possibility of classifying object n sorites paradoxes n fuzzy sets
![Page 246: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/246.jpg)
Probabilistic or possibilistic uncertainty?
n Is the vase broken? n Is the vase broken by a burglar? n Is there a burglar in the closet? n Is the burglar in the closet a man? n Is the man in the closet a burglar?
![Page 247: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/247.jpg)
Bayes’ theorem
n hypothesis H n evidence E n probability of the hypothesis P(H) n probability of the evidence P(E) n probability of the hypothesis based on the
evidence P(H|E) = (P(E|H) · P(H)) / P(E)
![Page 248: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/248.jpg)
Example
n H — there is a bug in the code n E — a bug is detected in the test n E|H — a bug is detected in the test given that
there is a bug in the code n H|E — there is a bug in the code given that a
bug is detected in the test
![Page 249: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/249.jpg)
Example (cont’d)
n P(H) = 0.10 n P(E|H) = 0.90 n P(E|¬H) = 0.10 n P(E) = P(E|H) · P(H) + P(E|¬H) · P(¬H)
= 0.18 n from Bayes’ theorem:
P(H|E) = 0.5 n conclusion: a detected bug has fifty-fifty chance
that it is not in the actual code
![Page 250: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/250.jpg)
Bayesian networks
n describe cause-and-effect relationships with a directed graph n vertices = propositions or variables n edges = dependencies as probabilities
n propagation of the probabilities n problems:
n relationships between the evidence and hypotheses are known
n establishing and updating the probabilities
![Page 251: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/251.jpg)
![Page 252: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/252.jpg)
![Page 253: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/253.jpg)
Dempster-Shafer theory
n belief about a proposition as an interval [ belief, plausability ] ⊆ [ 0, 1]
n belief supporting A: Bel(A) n plausability of A: Pl(A) = 1 − Bel(¬A) n Bel(intruder) = 0.3, Pl(intruder) = 0.8
n Bel(no intruder) = 0.2 n 0.5 of the probability range
is indeterminate
![Page 254: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/254.jpg)
Belief interval
0 1 Bel(A) Pl(A)
Belief Uncertainty Non-belief
Plausability
Doubt
![Page 255: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/255.jpg)
Example 1(5)
n hypotheses: animal, weather, trap, enemy n Θ = { A, W, T, E}
n task: assign a belief value for each hypothesis n evidence can affect one or more hypotheses
n mass function m(H) = current belief to the set H of hypotheses n in the beginning m(Θ) = 1
n evidence ‘noise’ supports A, W and E n mass function mn({ A, W, E }) = 0.6, mn(Θ) = 0.4
![Page 256: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/256.jpg)
![Page 257: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/257.jpg)
Example 2(3)
n evidence ‘footprints’ supports A, T, E n mf({ A, T, E }) = 0.8, mf(Θ) = 0.2
n combination with Dempster’s rule: n mnf({A, E}) = 0.48, mnf({W, A, E}) = 0.12,
mnf({A, T, E}) = 0.32, mnf(Θ) = 0.08
n enemy, trap, trap or enemy, weather, or animal? n Bel(E) = 0, Pl(E) = 1 n Bel(T) = 0, Pl(T) = 0.4 n Bel(T, E) = 0, Pl(T, E) = 1 n Bel(W) = 0, Pl(W) = 0.2 n Bel(A) = 0, Pl(A) = 1
![Page 258: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/258.jpg)
Example 3(3)
n evidence ‘candy wrapper’ supports T, E n mc({E}) = 0.6, mc({T}) = 0.3, mc(Θ) = 0.1
n combination with Dempster’s rule: n mnfc({E}) = 0.73, mnfc({T}) = 0.15,
mnfc({A, E}) = 0.06, mnfc({A, T, E}) = 0.04, mnfc({W, A, E}) = 0.01, mnfc(Θ) = 0.01
n enemy, trap, trap or enemy, weather, or animal? n Bel(E) = 0.73, Pl(E) = 0.85 n Bel(T) = 0.15, Pl(T) = 0.2 n Bel(T, E) = 0.88, Pl(T, E) = 1 n Bel(W) = 0, Pl(W) = 0.02 n Bel(A) = 0, Pl(A) = 0.03
![Page 259: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/259.jpg)
Fuzzy sets
n element x has a membership in the set A defined by a membership function μA(x) n not in the set: μA(x) = 0 n fully in the set: μA(x) = 1 n partially in the set: 0 < μA(x) < 1
n contrast to classical ‘crisp’ sets n not in the set: χA(x) = 0 n in the set: χA(x) = 1
![Page 260: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/260.jpg)
Membership function
U
μ
1
0
A
x
μA(x)
![Page 261: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/261.jpg)
![Page 262: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/262.jpg)
How to assign membership functions?
n real-word data n physical measurements n statistical data
n subjective evaluation n human experts’ cognitive knowledge n questionnaires, psychological tests
n adaptation n neural networks, genetic algorithms
n → simple functions usually work well enough as long as they model the general trend
![Page 263: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/263.jpg)
Fuzzy operations
n union: μC(x) = max{μA(x), μB(x)} n intersection: μC(x) = min{μA(x), μB(x)} n complement: μC(x) = 1 − μA(x)
n note: operations can be defined differently
![Page 264: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/264.jpg)
Fuzzy operations (cont’d)
U
μ 1
0
A B
A ∪ B
A ∩ B
A
![Page 265: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/265.jpg)
![Page 266: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/266.jpg)
![Page 267: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/267.jpg)
![Page 268: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/268.jpg)
Uses for fuzzy sets
n approximate reasoning n fuzzy constraint satisfaction problem n fuzzy numbers n almost any ‘crisp’ method can be fuzzified!
![Page 269: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/269.jpg)
Constraint satisfaction problem
n constraint satisfaction problem (CSP): n a set of n variables X n a domain Di for each variable xi in X n a set of constraints restricting the feasibility of the
tuples (x0, x1,…, xn – 1) ∈ D0 × … × Dn – 1
n solution: an assignment of value to each variable so that every constraint is satisfied n no objective function → not an optimization
problem
![Page 270: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/270.jpg)
Example: n queens problem as a CSP
n problem: place n queens on a n × n chessboard so that they do not threat one another
n CSP formulation n variables: xi for each row i n domain: Di = { 1, 2,…, n } n constraints:
n xi ≠ xj n xi – xj ≠ i – j n xj – xi ≠ i – j
![Page 271: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/271.jpg)
![Page 272: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/272.jpg)
Fuzzy constraint satisfaction problem
n fuzzy constraint satiscation problem (FCSP) is a five-tuple P = 〈 V, Cµ, W, T, U 〉 n V: variables n U: universes (domains) for the variables n Cµ: constraints as membership functions n W: weighting scheme n T: aggregation function
![Page 273: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/273.jpg)
![Page 274: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/274.jpg)
Dog Eat Dog: Modelling the criteria as fuzzy sets
n if the visual observation of the enemy is reliable, then avoid the enemy
n if the visual observation of the prey is reliable, then chase the prey
n if the olfactory observation of the pond is reliable, then go to the pond
n if the visual observation of the enemy is reliable, then stay in the centre of the play field
![Page 275: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/275.jpg)
![Page 276: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/276.jpg)
![Page 277: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/277.jpg)
![Page 278: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/278.jpg)
Dog Eat Dog: Weighting the criteria importances
n fuzzy criterion Ci has a weight wi ∈ [0, 1] n a greater value wi corresponds to a greater importance
n the weighted value from the implication wi → Ci n classical definition (A → B ⇔ ¬A ∨ B): min{ (1 − wi ), Ci } n Yager’s weighting scheme: the weighted membership value:
⎧ 1, if μ(x) = 0 and w = 0 μC
w(x) = ⎨ ⎩ (μC(x))w, otherwise
![Page 279: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/279.jpg)
Dog Eat Dog: Aggregating the criteria
n aggregator should have compensatory properties n the effect of a poorly satisfied criterion is not so
drastic n mean-based operators instead of conjunction
n ordered weighted averaging (OWA)
![Page 280: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/280.jpg)
Ordered weighted averaging (OWA)
n weight sequence W = (w0, w1,…,wn – 1)T n ∀wi ∈ [0, 1] and Σwi = 1
n F(a0, a1,…,an – 1) = Σwjbj n bj is the (j+1)th largest element of the sequence
A = 〈a0, a1,…,an – 1〉
n by setting the weight sequence we can get n conjunction: W = { 0, 0,…, 1} = min{A} n disjunction: W = { 1, 0,…, 0} = max{A} n average: W = {1/n, 1/n,…, 1/n}
n soft-and operator: wi = 2(i + 1) / (n(n + 1)) n example: n = 4, W = { 0.1, 0.2, 0.3, 0.4 }
![Page 281: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/281.jpg)
![Page 282: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/282.jpg)
![Page 283: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/283.jpg)
Outroduction
§1 Introduction §2 Random Numbers §3 Tournaments §4 Game Trees §5 Path Finding §6 Decision-Making §7 Modelling Uncertainty
![Page 284: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/284.jpg)
The intention, huh?
n to provide a glance into the world of computer games as seen from the perspective of a computer scientist
![Page 285: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/285.jpg)
Examinations
n examination dates 1. October 12 2009 2. November 16, 2009 3. December 14, 2009
n check the exact times and places at http://www.it.utu.fi/opetus/tentit/
n remember to enrol! https://ssl.utu.fi/nettiopsu/
![Page 286: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/286.jpg)
source: The New Yorker, Sep. 17, 2007
![Page 287: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/287.jpg)
Examinations (cont’d)
n questions n based on both lectures and the textbook n two questions, à 5 points n to pass the examination, at least 5 points (50%) are
required n grade: g = ⎡p − 5⎤ n questions are in English, but you can answer in
English or in Finnish
![Page 288: Algorithms for Computer Games - lecture slides 2009](https://reader033.vdocuments.mx/reader033/viewer/2022052617/544f5252af79595e6a8b8fde/html5/thumbnails/288.jpg)
Follow-up course: Multiplayer Computer Games
n focus: networking in computer games n credits: 5 cp (3 cu) n schedule:
n October 27 – November 26, 2009 n Tuesdays 10–12 a.m., and Thursdays 10–12 p.m.
n web page: http://www.iki.fi/smed/mcg