1 ai and game programming cis 487/587 bruce r. maxim um-dearborn
TRANSCRIPT
![Page 1: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/1.jpg)
1
AI and Game Programming
CIS 487/587
Bruce R. Maxim
UM-Dearborn
![Page 2: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/2.jpg)
2
Selected AI Techniques
• Deterministic algorithms
• Heuristic programming
• Patterns and scripts
• Finite state machines
• Production systems
• Genetic algorithms
• Neural networks
![Page 3: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/3.jpg)
3
Deterministic Algorithms
• Each clock tickasteroid_x += asteroid_x_velocity
asteroid_y += asteroid_y_velocity
• Asteroids follow their course until– off screen– collision occurs– blown up
![Page 4: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/4.jpg)
4
Random Motion
fly_x = rand() % 80fly_y= rand() % 80while(~done()){
fly_count = 0fly_x_velocity = -8 + rand() % 16fly_y_velocity = -8 + rand() % 16while (++fly_count < 10){
fly_x += fly_x_velocityfly_y += fly_y_velocity
}
![Page 5: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/5.jpg)
5
Tracking and Pursuit
if (player_x > monster_x)monster_x++
if (player_x < monster_x)monster_x--
if (player_y > monster_y)monster_y++
if (player_y < monster_y)monster_y--
![Page 6: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/6.jpg)
6
Tracking and Evasion
if (player_x < monster_x)monster_x++
if (player_x > monster_x)monster_x--
if (player_y < monster_y)monster_y++
if (player_y > monster_y)monster_y--
![Page 7: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/7.jpg)
7
Patterns and Scripts
• Get keys out of pocket
• Put key in door
• Open door
• Get in car
• Close door
• Put key in ignition
• Turn key to start car
![Page 8: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/8.jpg)
8
Behavioral State Systems
• Finite state machines– give them enough states to be interesting (each
represents different goals or motives)– lots of inputs (environment attributes and other
object states)• Some states may need substates or multi-part
actions (e.g. move toward opponent and attack 20% of the time)
• Personality of characters and spheres of influence may also be factored in as probabilistic input values to state entry or transitions
![Page 9: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/9.jpg)
9
Memory and Learning
• Memory is really just a decision to record a few details– record changes to frames– recording the last few moves
• Learning is self-improvement– neural networks– genetic algorithms– numerical approaches (e.g. Samuels & checkers)– structural approaches
![Page 10: 1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn](https://reader035.vdocuments.us/reader035/viewer/2022072006/56649f495503460f94c6a80c/html5/thumbnails/10.jpg)
10
Deciding Between AI Techniques
• Use deterministic techniques for simple behavior (e.g. rocks or missiles)
• Add randomness and patterns for smart elements (e.g. birds or spaceships)
• Use finite state machines for important game characters
• For computer controlled opponents use everything (including memory and learning)