CS 134 Video Game “AI”.

Slides:



Advertisements
Similar presentations
Chasing, Evading, Intercepting, Pattern Movements
Advertisements

Finite State Machines. Finite State Machines (FSMs) An abstract machine that can exist in one of several different and predefined states Defines a set.
Dave Pottinger,
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
Artificial Intelligence in Game Design Introduction to Learning.
CS 4730 Game AI CS 4730 – Computer Game Design Some slides courtesy Tiffany Barnes, NCSU.
RED DEAD REVOLVER Artificial Intelligence Critique By Mitchell C. Dodes CIS 588.
And Just Games etc.. EVOLUTION OF COMPUTER GAMES PongOdyssey Beginning of the use of microprocessors ATARI VCS system bit.
Intelligent Pac-Man Ghost AI
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
AI Post Mortem Inside Sims Medieval By David “Rez” Graham.
Artificial Intelligence in Game Design Problems and Goals.
Town Defenders Strategy Game prepared by: Osama N
Au’15 select topics By: Matt Boggus. List o’ stuff Game genres Party minigames Arena first person shooter 3D platformer/puzzler Horror Game technology.
Artificial Intelligence in Game Design Behavior Trees.
Review IMGD Engine Architecture Types Broadly, what are the two architecture types discussed for game engines? What are the differences?
CSE 380 – Computer Game Programming Artificial Intelligence Murloc, Blizzard Entertainment.
Machine Learning for an Artificial Intelligence Playing Tic-Tac-Toe Computer Systems Lab 2005 By Rachel Miller.
Motion Planning in Games Mark Overmars Utrecht University.
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
Right-click to Rename each sprite Name them: Player Monster Bullet Explosion.
Inside Abilities Daniel Kline and Lauren McHugh.
Jumping, Climbing, and Tactical Reasoning Section 2.5 Tom Schaible CSE 497 – AI & Game Programming.
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
Chasing, Evading, Intercepting, Pattern Movements
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn.
Computational theory techniques in interactive video games.
Artificial intelligence IN NPCs. Early Role Playing games Npcs in early role playing games were very limited in terms of being “Intelligent”. For instance,
Using Lists Games Programming in Scratch. Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list)
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
The Game Development Process: Artificial Intelligence.
How To Run a Golf Tournament. As many of you know, hosting a charity golf tournament is no easy task. Between creating the day’s agenda, tracking down.
Review IMGD Engine Architecture Types Broadly, what are the two architecture types discussed for game engines? What are the differences?
Bbm421 – Computer Games Technology
CS 134 Design Documents.
MORE Genre Specific Physics
Game Engine Architecture
Week 2 - Monday CS361.
Interacting Sprites Module 3: Investigation 1
FLOWCHARTS Part 1.
Game Engine Architecture
SANWU CaiBi QQ
Game Loops + Part II Reference:
CS 134 More Graphics.
Application of Artificial Intelligence and Graphics to Support a Three-Dimensional Game Chris Cummings.
Frame Update, Level Representation & Graphics
Movement in a full and dynamic environment using a limited influence map Paulo Lafeta Ferreira Artificial Intelligence for Games – CS 580 Professor: Steve.
Enemy and Friendly AIs Richard Gesick.
Dystopia game Amjd , Iyad , Haytham.
Disjoint Sets Chapter 8.
CSE 476/876 Optional Course Project
Artificial Intelligence in Game Design
Game Engine Architecture
Introduction to Events
Intelligent Agents Chapter 2.
Chapter 16 – Programming your App’s Memory
UNIT 3 CHAPTER 1 LESSON 4 Using Simple Commands.
Safe Path Planning for an Autonomous Agent in a Hostile Environment
CIS 488/588 Bruce R. Maxim UM-Dearborn
Shipwrecked Gameplay Characters Networking Turrets Spawning
Game Loop Update & Draw.
Three Special Structures – Case, Do While, and Do Until
Using Functions
Recursion Taken from notes by Dr. Neil Moore
Artificial Intelligence 12. Two Layer ANNs
Resources and interactions
CSC 221: Introduction to Programming Fall 2018
PACMAN OO Style.
Presentation transcript:

CS 134 Video Game “AI”

Today in Video Games

Any questions about the homework? Homework Questions Any questions about the homework?

Goal of Game AI Bioshock Infinite Pacman http://gameinternals.co m/post/2072558330/und erstanding-pac-man- ghost-behavior

Goal of Game AI Is Elizabeth really revolutionary? No! Very simple tricks were done. AI characters should act in predictable, human ways AI characters should make the same types of mistakes as a human

Goal of Game AI Goal is not to create AI as CS thinks about it. Goal is create AI as designers think about it! Programming is a last resort Things to avoid: Genetic Algorithms Neural Networks Decision Trees

Smart World Think about the behaviors you want What is data? What is defs? Put everything you can into defs in the world Where AI can walk Where AI should defend Special animations to play etc.

Smart World Good base building locations Best enemies to attack a location with etc. Yes, this data is all getting hardcoded. But that means it is easy to modify!

Smart World What information was put in for Elizabeth? Interaction points Events Specific things that can get unlocked

Smart World You can get a lot of mileage out of putting intelligence directly into the world Biggest limitation is that someone has to manually put all the behaviors into the game

Game Loop AI has two distinct parts: Decision making Decision execution Decision making does not need to happen all the time Decision execution must happen every frame

Game Loop Player player; Camera camera; Enemy[] enemies; // The game loop (inside main) while (!shouldExit) { // Message pump, deltaTime, etc. player.Update(deltaTime); camera.Update(deltaTime); for (Enemy enemy : enemies) { enemy.Update(deltaTime); } // Drawing The current game loop is calling “enemyUpdate” on every single enemy. Inside enemy update you will put AI logic.

Game Loop // inside class Enemy public void Update(float dt) { anim.Update(dt); // Simple logic, move toward player float deltaX; float deltaY; if( x < player.x ) { deltaX = ESPEED; } else { deltaX = -ESPEED; } if( y < player.y ) { deltaY = ESPEED; deltaY = -ESPEED; // Actually move! x += deltaX * dt; y += deltaY * dt; The current game loop is calling “Update” on every single enemy. Inside enemy update you will put AI logic.

Game Loop Replace the movement logic with smarter AI. // inside class Enemy public void Update(float dt) { anim.Update(dt); // Simple logic, move toward player float deltaX; float deltaY; if( x < player.x ) { deltaX = ESPEED; } else { deltaX = -ESPEED; } if( y < player.y ) { deltaY = ESPEED; deltaY = -ESPEED; // Actually move! x += deltaX * dt; y += deltaY * dt; Replace the movement logic with smarter AI.

Game Loop In your update function add logic like this: if (needANewDecision) { makeNewDecision(); } executeDecision();

Game Loop Why have this distinction? Planning a decision is often slow. Could take multiple frames! Executing the plan is quick and easy.

Game Loop Replace the movement logic with smarter AI. // inside class Enemy public void Update(float dt) { anim.Update(dt); // Move to target, choose new target // when needed If (x == targetX && y == targetY) { requestNewTarget(); } float deltaX; float deltaY; if( x < targetX ) { deltaX = min(ESPEED, targetX - e->x); } else { deltaX = -min(ESPEED, e->x - targetX); if( e->y < targetY ) { deltaY = min(ESPEED, targetY - e->y); deltaY = -min(ESPEED, e->y - targetY); // Actually move! x += deltaX * dt; y += deltaY * dt; Replace the movement logic with smarter AI. Note: if you are using pathfinding, you will need to have a full path instead of just a single target position.

Game Loop Any requests need to be handled outside the tick in your game loop. Think of this handling like another message pump! Handle as much as you have time for. Budget time based on desired framerate.

Game Loop Handle only as much AI requests as time is available. // Globals! Queue<AIRequest> aiRequests; // In gameloop long curTimeMs = System.nanotime(); while (!aiRequests.isEmpty() && System.nanotime() - curTimeNs < 5000000) { AIRequest last = aiRequests.remove(); handleAIRequest( last ); } Handle only as much AI requests as time is available. Potentially an AI request may not get handled for many frames!

Game Loop Questions?

Decision Making Remember, you just need to create a fun challenge Predictable, but not too predictable is a common goal Semi-randomness

Decision Making Semi-random behavior can cheaply add variety. Instead of just always making a single decision, you can randomly choose from a weighted list.

Decision Making Aggressive Thug 50% Charge 35% Combo 15% Retreat Opportunistic Thug 15% Charge 35% Combo 50% Retreat Ranged Thug 40% Charge 20% Combo 40% Retreat Timid Thug 5% Charge 5% Combo 90% Retreat

Decision Making Call Random.nextFloat() to get a random number For C++: rand() / (float)RAND_MAX will get you a float from 0 – 1. <.5 Charge <.85 Combo else Retreat Store the decision until it is done. Inside Enemy.Update(), switch on the decision and do the right behavior.

Decision Making Questions?