Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
the gamedesigninitiative at cornell university Lecture 15: Artificial Intelligence Assignment 9 due tonight Submit through CMS 2 Artificial Intelligence the gamedesigninitiative at cornell university Second Prototype Due Thursday, October 23rd In-class playtesting 3 Artificial Intelligence the gamedesigninitiative at cornell university Logging release later today Will send out an email Needed for first release (Nov. 4th) 4 Artificial Intelligence the gamedesigninitiative at cornell university Scripts Planning Pathfinding 5 Artificial Intelligence the gamedesigninitiative at cornell university Scripts 1. IF <condition is true> THEN <perform action> 2. IF <condition is true> THEN <perform action> 3. IF <condition is true> THEN <perform action> 6 Artificial Intelligence the gamedesigninitiative at cornell university First boss in Final Fantasy VII 7 Artificial Intelligence the gamedesigninitiative at cornell university First boss in Final Fantasy VII If (Count == 0 OR Count == 2) Then SelectedTarget = random opponent Use Search Scope on SelectedTarget Count = Count + 1 If (Count == 1 OR Count == 3) Then With probability 2/3: If Self HP < (Self Max HP / 2) Then Use Scorpion Tail on SelectedTarget Else Use Rifle on SelectedTarget With 1/3 Chance: Use Scorpion Tail on SelectedTarget Count = Count + 1 8 Artificial Intelligence the gamedesigninitiative at cornell university Example: Tic Tac Toe 1. If I can win, win 2. If opponent can win, prevent it 3. If center is available, take it 4. If corner is available, take it 9 Artificial Intelligence the gamedesigninitiative at cornell university Advantages/Disadvantages Easy to implement Can express complex behaviors “Smart” behavior can be very complex Not so scalable No natural way to vary difficulty 10 Artificial Intelligence the gamedesigninitiative at cornell university Adversarial Search Now I move Opponent moves I11move Artificial Intelligence the gamedesigninitiative at cornell university Importance of search depth in Chess Novice: ~4 Master: ~8 Grandmaster: ~12 Deep Blue: 6 – 40 12 Artificial Intelligence the gamedesigninitiative at cornell university Advantages/Disadvantages Potentially much smarter Natural way to vary difficulty State-space explosion Game must have certain properties Unclear what to do if you can’t “see” the end 13 Artificial Intelligence the gamedesigninitiative at cornell university Heuristics: Chess Pawn: 1 point Knight & Bishop: 3 points Rook: 5 points Queen: 11 points 14 Artificial Intelligence the gamedesigninitiative at cornell university Heuristic Planning Now I move Opponent moves 15 Artificial Intelligence the gamedesigninitiative at cornell university Heuristic Planning Now I move Opponent moves 16 11 10 5 14 Artificial Intelligence 2 20 3 16 the gamedesigninitiative at cornell university Heuristic Planning Now I move Opponent moves 17 5 11 3 2 10 5 14 Artificial Intelligence 2 20 3 16 the gamedesigninitiative at cornell university Heuristic Planning Now 5 I move Opponent moves 18 5 11 3 2 10 5 14 Artificial Intelligence 2 20 3 16 the gamedesigninitiative at cornell university Minimax MAX 5 MIN 5 11 19 3 2 10 5 14 Artificial Intelligence 2 20 3 16 the gamedesigninitiative at cornell university Advantages/Disadvantages Scalable Can be rational without “seeing” the endgame Strength depends a lot on the heuristic Still only works for some games 20 Artificial Intelligence the gamedesigninitiative at cornell university 21 Artificial Intelligence the gamedesigninitiative at cornell university Simultaneous Actions 1 3 22 1 3 Artificial Intelligence 1 3 the gamedesigninitiative at cornell university 23 Artificial Intelligence the gamedesigninitiative at cornell university right left right left 24 Artificial Intelligence the gamedesigninitiative at cornell university right left right left 25 Artificial Intelligence the gamedesigninitiative at cornell university right left 26 right left 1 -1 -1 1 Artificial Intelligence the gamedesigninitiative at cornell university right left 27 right left 1 -1 -1 1 Artificial Intelligence the gamedesigninitiative at cornell university right left 28 right left 1 -1 -1 1 Artificial Intelligence the gamedesigninitiative at cornell university What Is an Optimal Policy? Agent Policy 29 Artificial Intelligence 2 3 right 1 3 left the gamedesigninitiative at cornell university What Is an Optimal Policy? 0 30 1 1 3 2 3 -1 3 1 3 Artificial Intelligence the gamedesigninitiative at cornell university What Is an Optimal Policy? Agent Policy 2 3 1 3 31 Opponent Response 0 1 -1 3 Expected Reward Artificial Intelligence the gamedesigninitiative at cornell university What Is an Optimal Policy? 32 Artificial Intelligence the gamedesigninitiative at cornell university What Is an Optimal Policy? 1 2 0 1 2 33 Artificial Intelligence the gamedesigninitiative at cornell university 1 2 1 2 1 2 1 2 Agent’s Expected Reward = 0 34 Artificial Intelligence the gamedesigninitiative at cornell university Expected Reward 𝑇 𝑣 = 𝜋𝑜 𝑹𝜋𝑎 35 Artificial Intelligence the gamedesigninitiative at cornell university Calculating Reward max 𝑣 such that 𝑣,𝜋 𝜋𝑖 = 1 𝑖 𝜋≥𝟎 𝑣 ≤𝑹𝜋 36 Artificial Intelligence the gamedesigninitiative at cornell university 37 Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding A 38 B Artificial Intelligence the gamedesigninitiative at cornell university Make a grid! A 39 B Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: Depth-First A 40 B Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: Breadth-First 28 24 24 14 20 10 24 14 A 20 24 41 10 14 10 10 14 28 24 20 24 38 34 30 34 X X X X B X 54 58 34 44 54 38 48 54 X Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: Breadth-First 28 24 24 14 20 10 24 14 A 20 24 42 10 14 10 10 14 28 24 20 24 38 34 30 34 X X X X B X 54 58 34 44 54 38 48 54 X Artificial Intelligence the gamedesigninitiative at cornell university Breadth-First is Slow! A B Idea: use heuristics 43 Artificial Intelligence the gamedesigninitiative at cornell university A* Algorithm Score f = g + h g: distance on best path h: naïve distance to goal B A Manhattan distance = 30+20 = 50 44 Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: A* Algorithm f: 74 f: 60 f: 54 g:14 f: 60 h:60 g:10 h:50 g:14 f: 40 h:40 A 45 g:10 f: 74 h:50 g:14 B h:30 f: 60 g:10 f: 54 h:60 g:10 h:50 g:14 h:40 Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: A* Algorithm f: 74 f: 60 f: 54 g = 20 g = 24 f=60 f=74 g:14 h:60 g:10 h:50 g:14 h:40 f: 60 f: 40 X A g:10 f: 74 h:50 f: 60 g:10 f: 54 B h:30 g = 20 g = 24 f=60 f=74 g:14 h:60 g:10 h:50 g:14 h:40 46 X X Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: A* Algorithm f: 74 f: 60 f: 54 g:14 f: 60 h:60 g:10 h:50 g:14 f: 40 h:40 X A g:10 f: 74 h:50 f: 60 g:10 f: 54 h:30 g = 24 f=74 g:14 h:60 g:10 h:50 g:14 h:40 f: 88 B X f: 74 X g:28 47 h:60 g:24 h:50 Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: A* Algorithm f: 94 f: 80 88 f: 74 h:70 g:20 g:28 f: 60 h:60 g:24 f: 54 h:50 f: 94 g:24 f: 74 g:24 f: 80 h:70 g:14 f: 60 h:60 g:10 h:50 g:14 f: 40 h:40 A 48 g:20 f: 94 h:60 g:10 f: 74 h:50 g:24 B h:30 f: 60 g:10 f: 54 h:70 g:14 f: 94 h:60 g:10 f: 80 88 h:50 g:14 f: 74 h:40 g:24 h:70 g:20 g:28 h:60 g:24 h:50 Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: A* Algorithm f: 94 f: 80 88 f: 74 h:70 g:20 g:28 f: 60 h:60 g:24 f: 54 h:50 f: 94 g:24 f: 74 g:24 f: 80 h:70 g:14 f: 60 h:60 g:10 h:50 g:14 f: 40 h:40 In case of tie, use most recently added A g:20 f: 94 h:60 g:10 f: 74 h:50 g:24 h:70 g:14 f: 94 g:24 h:30 f: 60 g:10 f: 54 h:60 g:10 f: 80 88 h:50 g:14 f: 74 h:40 h:70 g:20 g:28 h:60 g:24 f:108 f: 94 g:38 49 B h:70 g:34 f: 74 f: 68 h:20 g:58 f: 74 h:10 f: 74 g:54 f: 74 h:50 g:34 f: 88 h:40 g:44 f: 88 h:30 g:54 f: 88 h:20 h:60 g:38 h:50 g:48 h:40 g:58 h:30 Artificial Intelligence the gamedesigninitiative at cornell university Pathfinding: A* Algorithm f: 94 f: 80 88 f: 74 h:70 g:20 g:28 f: 60 h:60 g:24 f: 54 h:50 f: 94 g:24 f: 74 g:24 f: 80 h:70 g:14 f: 60 h:60 g:10 h:50 g:14 f: 40 h:40 A g:20 f: 94 h:60 g:10 f: 74 h:50 g:24 h:70 g:14 f: 94 g:24 h:30 f: 60 g:10 f: 54 h:60 g:10 f: 80 88 h:50 g:14 f: 74 h:40 h:70 g:20 g:28 h:60 g:24 f:108 f: 94 g:38 50 B h:70 g:34 f: 74 f: 68 h:20 g:58 f: 74 h:10 f: 74 g:54 f: 74 h:50 g:34 f: 88 h:40 g:44 f: 88 h:30 g:54 f: 88 h:20 h:60 g:38 h:50 g:48 h:40 g:58 h:30 Artificial Intelligence the gamedesigninitiative at cornell university A* Mario 51 Artificial Intelligence the gamedesigninitiative at cornell university Group Activity: AI++ IF your game has no AI That’s How We Roll Box Thermo THEN write a script that solves a level of your game IF your game has minimal AI Sleep Walker Pyrokid Epic’s Epic Epic THEN improve the AI script IF your game has heavy AI Zombify Nameless THEN discuss how you would add planning, heuristics, or intelligent randomness 52 Artificial Intelligence the gamedesigninitiative at cornell university