INTRODUCTION TO GAME AI

Similar documents
CS 387/680: GAME AI DECISION MAKING. 4/19/2016 Instructor: Santiago Ontañón

Chapter 1:Object Interaction with Blueprints. Creating a project and the first level

Pangolin: A Look at the Conceptual Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

Gaming Development. Resources

Introduction to Game Design. Truong Tuan Anh CSE-HCMUT

Beginning 3D Game Development with Unity:

The purpose of this document is to outline the structure and tools that come with FPS Control.

Program a Game Engine from Scratch. Chapter 1 - Introduction

CS 480: GAME AI DECISION MAKING AND SCRIPTING

CS 354R: Computer Game Technology

Unity Certified Programmer

Unity Game Development Essentials

CS 354R: Computer Game Technology

Sensible Chuckle SuperTuxKart Concrete Architecture Report

Unity 3.x. Game Development Essentials. Game development with C# and Javascript PUBLISHING

CS 387/680: GAME AI AI FOR FIRST-PERSON SHOOTERS

CS 480: GAME AI TACTIC AND STRATEGY. 5/15/2012 Santiago Ontañón

BMOSLFGEMW: A Spectrum of Game Engine Architectures

Pangolin: Concrete Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

the gamedesigninitiative at cornell university Lecture 10 Game Architecture

Artificial Intelligence for Games. Santa Clara University, 2012

Emergent s Gamebryo. Casey Brandt. Technical Account Manager Emergent Game Technologies. Game Tech 2009

CS 680: GAME AI INTRODUCTION TO GAME AI. 1/9/2012 Santiago Ontañón

The 8 th International Scientific Conference elearning and software for Education Bucharest, April 26-27, / X

CS 387/680: GAME AI DECISION MAKING

publi l c i c c l c a l s a s s s Ga G m a e1 e1 : M i M c i r c os o o s f o t. t Xn X a. a Fram a ew o k.ga G m a e m { G ap a hic i s c D s ev

Experiment 02 Interaction Objects

Instructions for using Object Collection and Trigger mechanics in Unity

AI in Computer Games. AI in Computer Games. Goals. Game A(I?) History Game categories

IMGD 1001: Programming Practices; Artificial Intelligence

TATAKAI TACTICAL BATTLE FX FOR UNITY & UNITY PRO OFFICIAL DOCUMENTATION. latest update: 4/12/2013

Who am I? AI in Computer Games. Goals. AI in Computer Games. History Game A(I?)

the gamedesigninitiative at cornell university Lecture 4 Game Components

IMGD 1001: Programming Practices; Artificial Intelligence

NOVA. Game Pitch SUMMARY GAMEPLAY LOOK & FEEL. Story Abstract. Appearance. Alex Tripp CIS 587 Fall 2014

IMGD Technical Game Development I: Introduction. by Robert W. Lindeman

Overview. The Game Idea

Game Architecture. Rabin is a good overview of everything to do with Games A lot of these slides come from the 1 st edition CS

CS 387/680: GAME AI TACTIC AND STRATEGY

IMGD Technical Game Development I: Introduction

Game Programming Paradigms. Michael Chung

Magic Leap Soundfield Audio Plugin user guide for Unity

CS 480: GAME AI INTRODUCTION TO GAME AI. 4/3/2012 Santiago Ontañón

Game Tools MARY BETH KERY - ADVANCED USER INTERFACES SPRING 2017

IMGD Technical Game Development I: Introduction. by Robert W. Lindeman

CS Game Programming, Fall 2014

Concrete Architecture of SuperTuxKart

Crowd-steering behaviors Using the Fame Crowd Simulation API to manage crowds Exploring ANT-Op to create more goal-directed crowds

2D Platform. Table of Contents

Attack of Township. Moniruzzaman, Md. Daffodil International University Institutional Repository Daffodil International University

D E S I G N D O C U M E N T

Engineering at a Games Company: What do we do?

Warmup Due: Feb. 6, 2018

Game Design Project 2, Part 3 Group #3 By: POLYHEDONISTS Brent Allard, Taylor Carter, Andrew Greco, Alex Nemeroff, Jessica Nguy

G54GAM - Games. So.ware architecture of a game

COMPASS NAVIGATOR PRO QUICK START GUIDE

Adding in 3D Models and Animations

Federico Forti, Erdi Izgi, Varalika Rathore, Francesco Forti

In this project you ll learn how to create a times table quiz, in which you have to get as many answers correct as you can in 30 seconds.

Killzone Shadow Fall: Threading the Entity Update on PS4. Jorrit Rouwé Lead Game Tech, Guerrilla Games

Game Artificial Intelligence ( CS 4731/7632 )

DM842 Computer Game Programming

INTRODUCTION TO GAME AI

A Character Decision-Making System for FINAL FANTASY XV by Combining Behavior Trees and State Machines

Towards a Reference Architecture for 3D First Person Shooter Games

the gamedesigninitiative at cornell university Lecture 14 Data-Driven Design

Integrating PhysX and OpenHaptics: Efficient Force Feedback Generation Using Physics Engine and Haptic Devices

INTRODUCTION TO GAME AI

Beginning ios 3D Unreal

CS 380: ARTIFICIAL INTELLIGENCE

Learning XNA 4.0. Aaron Reed O'REILLY8. Cambridge. Beijing. Sebastopoi. Tokyo. Farnham Koln

Creating Dynamic Soundscapes Using an Artificial Sound Designer

Z-Town Design Document

Key Abstractions in Game Maker

CISC 1600, Lab 2.2: More games in Scratch

Space Invadersesque 2D shooter

VACUUM MARAUDERS V1.0

MODELING AGENTS FOR REAL ENVIRONMENT

Tac Due: Sep. 26, 2012

CRYPTOSHOOTER MULTI AGENT BASED SECRET COMMUNICATION IN AUGMENTED VIRTUALITY

CSE 125 Boot Camp. Or: How I Learned to Stop Worrying and Love The Lab

Whiskey2D A 2D Game Creator

An Overview of the Mimesis Architecture: Integrating Intelligent Narrative Control into an Existing Gaming Environment

SIMGRAPH - A FLIGHT SIMULATION DATA VISUALIZATION WORKSTATION. Joseph A. Kaplan NASA Langley Research Center Hampton, Virginia

CS 680: GAME AI WEEK 4: DECISION MAKING IN RTS GAMES

An Approach to Maze Generation AI, and Pathfinding in a Simple Horror Game

Game Design Document. RELEASE December 18, Austin Krauss

Virtual Reality RPG Spoken Dialog System

vstasker 6 A COMPLETE MULTI-PURPOSE SOFTWARE TO SPEED UP YOUR SIMULATION PROJECT, FROM DESIGN TIME TO DEPLOYMENT REAL-TIME SIMULATION TOOLKIT FEATURES

By Chris Burton. User Manual v1.60.5

Lecture 1: Introduction and Preliminaries

12 Final Projects. Steve Marschner CS5625 Spring 2016

AR 2 kanoid: Augmented Reality ARkanoid

the gamedesigninitiative at cornell university Lecture 20 Optimizing Behavior

Oculus Rift Getting Started Guide

Introduction. Video Game Design and Development Spring part of slides courtesy of Andy Nealen. Game Development - Spring

Module 4 Build a Game

Saphira Robot Control Architecture

Artificial Intelligence

Computer Games 2011 Engineering

Transcription:

CS 387: GAME AI INTRODUCTION TO GAME AI 3/31/2016 Instructor: Santiago Ontañón santi@cs.drexel.edu Class website: https://www.cs.drexel.edu/~santi/teaching/2016/cs387/intro.html

Outline Game Engines Perception and Action

Outline Game Engines Perception and Action

Game Engine Architecture Composed of a set of layers, each one of them providing higher and higher-level functionality (not unlike a regular OS) Can be very simple of very complex In addition to the run-time (the code that runs when the game is being played), game engines typically include content authoring tools (level editors, script editors, etc.)

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine (e.g., Unity) Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

SDKs Typically used: Data Structures: STL, Boost, Loki Graphics: OpenGL, DirectX Animation: Havoc, Edge, Granny, Euphoria Sound: OpenAL Physics: ODE, Havoc, PhysX (add your favorite library here)

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

Platform Independence Layer Layer that offers the functionality of all the libraries below in a platform independent way. For example: If coding a game for 2 platforms, where one only allows Physx, and the other only ODE, this layer would define an API that the game engine can use, independently of the physics library underneath There are many existing platform independence layers available for graphics, sound, etc. A popular C++ one is SDL (Simple Directmedia Layer) with abstractions for: Graphics, sound, keyboard, mouse, network, threading, etc.

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

Utility Layer Set of basic functionalities, not provided by any of the linked SDKs, and that are required by the game engine. Typically: Memory management: standard memory allocation might not be fast enough for a game engine, custom memory allocation routines are typical. Math: basic set of functions for geometry, trigonometry, quaternion, matrix, equation solving, numerical integration, etc. as needed by the game engine. Data structures: trees, graphs, etc. (anything not supported by STL, Boost, etc. that the engine needs) Algorithms: search, sort, etc. Random number generation (if standard does not satisfy needs) File parsers (XML, etc.) Configuration

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

Resource Management (Assets) All games require assets (bitmaps, 3D models, maps, sounds, etc.) The game engine should provide functionality to load/save/ create/query assets such as: 3D models: Meshes Textures/Materials Skeletons Animations 2D models: Bitmaps Skeletons Animations Fonts Maps Sound files Collision resources (collision shapes)

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Scripting Artificial Intelligence Online Multiplayer Rendering Engine Animation Engine Gameplay Foundations (Game State, Game Flow) Physics Audio Subsystem Collisions Profiling & Debugging

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Rendering Engine Graphical Artificial Scripting rendering of the game. It can be very complex, and also subdivided Intelligence in a collection of layers: Low-level renderer: materials, lighting, camera, text, primitives, viewports, Gameplay etc. Foundations (Game State, Game Flow) Scene drawing: culling, Level-of-detail (LOD), scene subdivision Visual effects: particle systems, shaders, post effects, Animation etc. Physics Engine Front end: HUD, GUI, menus, etc. Online Multiplayer Audio Subsystem Collisions Profiling & Debugging

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Scripting Artificial Intelligence Online Multiplayer Rendering Engine Animation Engine Gameplay It is in charge Foundations of playing skeletal (Game animations, State, Game interacting Flow) with the physics of the game engine. Might also trigger sound effects Audio (requests Physics sent through gameplay Subsystem foundations). Collisions Profiling & Debugging

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Run physics simulations taking Scripting collisions and animations into account. Forces, constraints, etc. Rendering Engine Animation Engine Detecting collisions points, surfaces and directions between complex objects using the functionalities of the lower layers. Play sounds: depending on distances, walls, relative velocities, etc. Artificial Online (volumes, panning, Intelligence Doppler effects). Multiplayer Fading in/out music, dynamic music, Gameplay etc. Foundations (Game State, Game Flow) Physics Collisions Audio Subsystem Profiling & Debugging

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Scripting Artificial Intelligence Online Multiplayer Gameplay Foundations (Game State, Game Flow) Some Rendering game engines allow the attachment Engine of scripts to each asset (models, animations, maps, Animation etc.) in a Physics high-level language (e.g. Engine Lua). Audio Subsystem The game engine needs an interpreter/ compiler that runs those scripts. Collisions Profiling & Debugging

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Scripting Artificial Intelligence Online Multiplayer Rendering Engine Animation Focus of this class Engine Gameplay Foundations (Game State, Game Flow) Game state replication, and policy for coherent state maintenance. Audio Physics Match-making, messaging Subsystem (not message rendering, just message sending/reception), etc. Profiling & Collisions Debugging

Game Engine Functionalities Most complex layer of the game engine, composed of multiple sub-systems Scripting Artificial Intelligence Online Multiplayer Rendering Engine Gameplay Foundations (Game State, Game Flow) Animation Core of the game engine, Physics Engine location of the Game Loop, also maintains the game state. Audio Subsystem Location of the game flow FSM (transition from menus to game, to game over, etc.) Collisions Profiling & Debugging

Game Engine Architecture Game Specific Game Engine Functionalities Game Engine Resource Management Utility Layer Platform Independence Layer SDKs OS DRIVERS HARDWARE Dependencies

AI Interface with the Game Engine Scripting Artificial Intelligence Online Multiplayer Rendering Engine Animation Engine Gameplay Foundations (Game State, Game Flow) Physics Audio Subsystem Collisions Profiling & Debugging

AI Interface with the Game Engine Collision AI Input Gameplay Foundations (Game State, Game Flow) Game State

AI Interface with the Game Engine Collision AI Collision data (what touches what, or is in the line of fire of what) Input AI actions (might or not be the same as the human player s) Gameplay Foundations Game State (Game State, Information Game Flow) Game State

AI Interface with the Game Engine Strategy Collision Decision Making AI World Interface (perception) Movement Input Gameplay Foundations (Game State, Game Flow) Game State

Example: RPG Game Consider Morrowind (Elder Scrolls III)

Example: RPG Game AI Strategy Decision Making: Scripts Movement: A* + Animation Perception: Navigation mesh Quests status Interaction events (hits, etc.) Collision + Line of sight Input Game State

Example: RPG Game AI Strategy Decision Making: Scripts Movement: A* + Animation Perception: Navigation mesh Quests status Interaction events (hits, etc.) Collision + Line of sight In some games (e.g. Spore) animation is so complex, that it is considered part of the Game AI (we will not cover animation techniques Input in this course) Game State

Example: RPG Game AI Strategy Decision Making: Scripts Movement: A* + Animation Perception: Navigation mesh Quests status Interaction events (hits, etc.) Collision + Line of sight For the triggers and conditions used in the scripts (basically, we need all the information needed to Input test the conditions in the scripts, or an interface to do so) Game State

Example: RPG Game AI Strategy Decision Making: Scripts Movement: A* + Animation Perception: Navigation mesh Quests status Interaction events (hits, etc.) Collision + Line of sight Basically for A*, although some scripts might check for things like if there is path between A and B then Input Game State

Outline Game Engines Perception and Action

Perception and Action The interface between the game engine and the AI is key As you already know (from the previous AI class): Most AI algorithms are very brittle Information needs to be represented in exactly the right way A non appropriate representation might make the AI code very complex AI algorithms are eager consumers of information: an efficient way to get information from the game engine is required

Running Example Imagine we are writing the AI of a unit in StarCraft: We want the unit to attack any opponent units that get in attack range: attack_range

Running Example (2) Imagine we are writing the AI of a unit in StarCraft: We want the unit to attack any opponent units that get in attack range: Class Marine { public: bool update(gamestate *gs); void render(graphicscontext *g); protected: }; attack_range

Two Approaches to Perception Polling Message passing

Polling Simplest idea: No special perception layer Whenever the AI wants some piece of information, it just asks the Game State / Collision / Line of Sight modules about it Benefits: Easy Problems: Inefficient The same information might be asked for multiple times Most of the time the player does not collide with enemies, why check it at every frame? Hard to debug

Running Example Marine AI using polling : bool Marine::update(GameState *gs) { GameObject *o = gs->enemyinradius(this, myposition, attack_range); if (o!=0) attack(o); } o bool GameState::enemyInRadius (GameObject *o, Pos p, float radius) { for(gameobject *o2:gameobjects) { if (o2->isenemy(o) && o2->distance(p)<=radius) return o; } return 0; } attack_range

Polling Station Rather than asking the game engine directly: Create a perception module with an API to access the game engine All AIs ask this perception module (the polling station) Polling station can improve efficiency by caching queries Easier to debug (polling station can be used as the one stop place to set break-points or logging instructions) Having an API in between the AI and the Game Engine, allows game engine developers to work independently than the AI developers

Message Passing Event-based approach Wait for an event message to arrive rather than constantly checking for conditions to be true at each cycle (e.g. check if the player is in line of sight): When something relevant happens (e.g. player is in line of sight), a message is sent to all the AIs that care about this condition. Centralized event manager

Event Manager AI1 Checking Engine Registry of Event Listeners AI2 AIn Event queue

Event Manager AIs register for certain events, like collisions with certain objects, etc. AI1 Checking Engine Registry of Event Listeners AI2 AIn Event queue

Event Manager A single checking engine checks for the events for which any AI is registered AI1 Checking Engine Registry of Event Listeners AI2 AIn Event queue

Event Manager Certain events, do not need to be checked for, since the originating entity sends the directly (e.g. state changes in another AI) AI1 Checking Engine Registry of Event Listeners AI2 AIn Event queue

Running Example Marine AI using simple events : bool Marine::update(GameState *gs) { Pos oldposition = myposition; if (cycle==0) gs->registerforevent(this, ENEMY_IN_RANGE); //... } if (oldposition!= myposition) gs->signalevent(position_change, this); bool Marine::event(Event *e) { if (e->type = ENEMY_IN_RANGE) attack(e->o); } attack_range

Running Example Marine AI using simple events : bool Marine::update(GameState *gs) { Pos oldposition = myposition; if (cycle==0) gs->registerforevent(this, ENEMY_IN_RANGE); } //... if (oldposition!= myposition) gs->signalevent(position_change, this); Notice that no CPU is wasted in checking whether any object that is not moving is in range or not. In this example, only when an object moves, the event manager performs the checks (triggered by the signalevent call). bool Marine::event(Event *e) { if (e->type = ENEMY_IN_RANGE) attack(e->o); } attack_range You will have to define some Event class, and come up with a list of events that make sense in your particular game.

Polling vs Message Passing Polling is simpler, better for simple games (where message passing is overkill) Message passing can be more efficient but it is more complex to deploy Best choice depends on the game type, but it is always worth spending effort into determining how the AI is going to get information from the game.

Sensing

Sensing Polling Stations and Event Managers address the problem getting information from the game engine But not all characters in the game should have access to all information: If a character in a room wants to know if another one across the map made a noise, it should not be able to get that information Recent realistic games need a sensing model Sensing models are typically implemented over event managers, rather than polling stations.

Easiest Approach: Fake it! The AI has access to everything that happens in the game, but it is programmed to act as if it didn t know. Example: Warcraft II

Simple Sensing Model Characters can only see/hear what happens in the room Event Manager 1 Event Manager 2 Event Manager 3 Event Manager 4

Simple Sensing Model Characters can only see/hear what happens in the room Event Manager 1 Event Manager 2 Event Manager 3 When a character moves from a room to another, it unregisters from an event manager, and registers in another one Event Manager 4

Realistic Sensing Models Sight: Sight cones (60 degrees is standard) Line of sight Distance (although it is not realistic, it s very typical in games) Brightness/differentiation (used in games like Splinter Cell) Touch Hearing Distance (reduce volume and use audible threshold) Smell Not common, but some games use it (e.g. Alien vs Predator)

Alien vs Predator

Event Manager + Sensing (simple) When characters register, they send their position and sensing capabilities to the registry AI1 Checking Engine Registry of Event Listeners AI2 Event queue Sensing Model AIn

Event Manager + Sensing (simple) AI1 Registry Each sense has defined: Checking of - Attenuation factor (for distance) Engine Event - Maximum range Listeners - Transmission speed - Restrictions (line-of-sight?) Sensing Model AI2 AIn Event queue

Event Manager + Sensing (complex) Checking Engine Registry of Event Listeners AI1 AI2 Event queue Sensing Model AIn Sensing Transmission Graph

Event Manager + Sensing (complex) Checking Engine Registry of Event Listeners AI1 AI2 Graph can be precomputed if map is static Divide game map in a finite set of regions. Sensing Define if different events (visual, sounds, Model etc.) can transfer from region to region, and at which speed Event and attenuation. queue Can model one-way glass, mirrors, sound travelling through pipes, etc. Sensing Transmission Graph AIn

Show Off the AI Features!

Summary AI interfaces with a game engine. Basic AI components: Perception Movement Decision Making Strategy Perception is the foundation over which your AI will be built. Pay attention to it!

Example of Perception in Action Example from the game engine used in project 5

Next Week Movement Steering Behaviors (for project 1)