IMGD 1001: Programming Practices; Artificial Intelligence.

Slides:



Advertisements
Similar presentations
Heuristic Search techniques
Advertisements

Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Debugging Mohammad Zikky, M.T. 2 Debugging Introduction (1 of 2)  Debugging is methodical process for removing mistakes in a program  So important,
Chapter Chapter 4. Think back to any very difficult quantitative problem that you had to solve in some science class How long did it take? How many times.
 Introduction to Programming History of programming.
Half life 2/ Counter Strike: Source bot Charlie Cross CIS
Artificial Intelligence for Games IMGD Introduction to Artificial Intelligence (AI) Many applications for AI –Computer vision, natural language.
Artificial Intelligence CGDD Artificial Intelligence Human-level intelligence - an unsolved problem AI “describes the intelligence embodied in any.
Chapter 3.5 Debugging Games
The Game Development Process Game Programming. Outline Teams and Processes Debugging Select Languages Misc (as time allows) –AI –Multiplayer.
Artificial Intelligence in Game Design Introduction to Learning.
CS 4730 Game AI CS 4730 – Computer Game Design Some slides courtesy Tiffany Barnes, NCSU.
Chapter 15 Design, Coding, and Testing. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Design Document The next step in the Software.
Requirements Specification
Shallow Blue Project 2 Due date: April 5 th. Introduction Second in series of three projects This project focuses on getting AI opponent Subsequent project.
The Game Development Process Game Programming. Outline Teams and Processes Select Languages Debugging Misc (as time allows) –AI –Multiplayer.
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
Applied Software Project Management Andrew Stellman & Jennifer Greene Applied Software Project Management Applied Software.
Programming Fundamentals (750113) Ch1. Problem Solving
The Software Product Life Cycle. Views of the Software Product Life Cycle  Management  Software engineering  Engineering design  Architectural design.
Principle of Functional Verification Chapter 1~3 Presenter : Fu-Ching Yang.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
Software Development Concepts ITEC Software Development Software Development refers to all that is involved between the conception of the desired.
Introduction to High-Level Language Programming
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Tracking The Problem  By Aaron Jackson. What’s a Problem?  A suspicious or unwanted behavior in a program  Not all problems are errors as some perceived.
Introduction GAM 376 Robin Burke Winter Outline Introductions Syllabus.
Survey of AI for games. AI vs. AI for games Traditional AI: – Made to handle unseen inputs, large state space – Too many options possible to compute an.
 CS 5380 Software Engineering Chapter 8 Testing.
Artificial Intelligence Techniques Artificial Stupidity?
1 Game AI Finite State Machine. Finite State Machine (FSM) is the most commonly used Game AI technology Finite State Machine (FSM) is the most commonly.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
SKULLS OF THE SHOGUn AI POST-MORTEM Borut Pfeifer Developer: Haunted Temple Studios Publisher: Microsoft Platforms: XBLA, Windows Phone, Windows 8 Release.
From Quality Control to Quality Assurance…and Beyond Alan Page Microsoft.
CHAPTER 10: CORE MECHANICS Definitions and Mechanisms.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Chapter 7 The Practices: dX. 2 Outline Iterative Development Iterative Development Planning Planning Organizing the Iterations into Management Phases.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Artificial Intelligence for Games Finite State Machines
1-1 Software Development Objectives: Discuss the goals of software development Identify various aspects of software quality Examine two development life.
AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate.
CS5103 Software Engineering Lecture 02 More on Software Process Models.
6.5 Implementing a State Machine Language. State Machine in game AI The most used software pattern Simple to program Easy to comprehend Easy to debug.
Artificial Intelligence in Games
Chapter 5.3 Artificial Intelligence: Agents, Architecture, and Techniques.
Dr Nick Mitchell (Room CM 224)
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
1 CO Games Development 1 Week 3 Game Agents 2 Gareth Bellaby.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
1 Game AI Finite State Machine. 2 Finite State Machine (FSM) is the Most Commonly used Game AI Technology Today Finite State Machine (FSM) is the Most.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
CSCE 552 Spring 2009 Inverse Kinematics and AI By Jijun Tang.
The Game Development Process: Artificial Intelligence.
Topic: Programming Languages and their Evolution + Intro to Scratch
Enemy and Friendly AIs Richard Gesick.
Artificial Intelligence: Agents, Architecture, and Techniques
Design and Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Finite State Machines in Games
Programming.
Tonga Institute of Higher Education IT 141: Information Systems
Applying Use Cases (Chapters 25,26)
Applying Use Cases (Chapters 25,26)
Tonga Institute of Higher Education IT 141: Information Systems
IMGD 1001: Programming Practices; Artificial Intelligence
Introduction to Software Testing
Presentation transcript:

IMGD 1001: Programming Practices; Artificial Intelligence

IMGD Outline  Common Practices  Artificial Intelligence

IMGD Common Practices: Version Control  Database containing files and past history of them  Central location for all code  Allows team to work on related files without overwriting each other’s work  History preserved to track down errors  Branching and merging for platform specific parts Based on Chapter 3.1, Introduction to Game Development

IMGD Common Practices: Quality (1 of 3)  Code reviews – walk through code by other programmer(s) Formal or informal "Two pairs of eyes are better than one." Value is that the programmer is aware that others will read  Asserts Force program to crash to help debugging  Ex: Check condition is true at top of code, say pointer not NULL before continuing Removed during release Based on Chapter 3.1, Introduction to Game Development

IMGD Common Practices: Quality (2 of 3)  Unit tests Low level test of part of game  See if physics computations correct Tough to wait until very end and see if there's a bug Often automated, computer runs through combinations Verify before assembling  Acceptance tests Verify high-level functionality working correctly  See if levels load correctly  Note, above are programming tests (i.e. code, technical) Still turned over to testers that track bugs, do gameplay testing Based on Chapter 3.1, Introduction to Game Development

IMGD Common Practices: Quality (3 of 3)  Bug database Document & track bugs Can be from programmers, publishers, customers Classify by severity and priority Keeps bugs from falling through cracks Helps see how game is progressing Based on Chapter 3.1, Introduction to Game Development

IMGD Common Practices: Pair (or "Peer") Programming  Two programmers at one workstation  One codes and tests, other thinks Switch after fixed time  Results Higher-quality code  More bugs found as they happen More enjoyable, higher morale Team cohesion Collective ownership

IMGD Outline  Common Practices(done)  Artificial Intelligence(next)

IMGD Group Exercise  Consider game where hero is in a pyramid full of mummies. Mummy wanders around maze When hero gets close, can “sense” and moves quicker When mummy sees hero and rushes to attack If mummy wounded, it flees  What “states” can you see? What are the transitions? Can you suggest appropriate code?

IMGD Introduction to AI  Opponents that are challenging, or allies that are helpful Unit that is credited with acting on own  Human-level intelligence too hard But under narrow circumstances can do pretty well Ex: chess and Deep Blue  Artificial Intelligence Around in CS for some time Based on Chapter 5.3, Introduction to Game Development

IMGD AI for CS different than AI for Games  Must be smart, but purposely flawed Lose in a fun, challenging way  No unintended weaknesses No "golden path" to defeat Must not look dumb  Must perform in real time (CPU)  Configurable by designers Not hard coded by programmer  "Amount" and type of AI for game can vary RTS needs global strategy, FPS needs modeling of individual units at "footstep" level RTS most demanding: 3 full-time AI programmers Puzzle, street fighting: 1 part-time AI programmer Based on Chapter 5.3, Introduction to Game Development

IMGD AI for Games: Mini Outline  Introduction(done)  Agents(next)  Finite State Machines

IMGD Game Agents (1 of 3)  Most AI focuses around game agent Think of agent as NPC, enemy, ally or neutral  Loops through: sense-think-act cycle Acting is event specific, so talk about sense+think Based on Chapter 5.3, Introduction to Game Development

IMGD Game Agents (2 of 3)  Sensing Gather current world state: barriers, opponents, objects Need limitations: avoid "cheat" of looking at game data Typically, same constraints as player (vision, hearing range)  Often done simply by distance direction (not computed as per actual vision) Model communication (data to other agents) and reaction times (can build in delay)

IMGD Game Agents (3 of 3)  Thinking Evaluate information and make a decision As simple or elaborate as required Two ways:  Pre-coded expert knowledge, typically hand- crafted if-then rules + randomness to make unpredictable  Search algorithm for best (optimal) solution Based on Chapter 5.3, Introduction to Game Development

IMGD Game Agents: Thinking (1 of 3)  Expert Knowledge Finite state machines, decision trees, … (FSM most popular, details next) Appealing since simple, natural, embodies common sense  Ex: if you see enemy weaker than you, attack. If you see enemy stronger, then flee! Often quite adequate for many AI tasks Trouble is, often does not scale  Complex situations have many factors  Add more rules  Becomes brittle Based on Chapter 5.3, Introduction to Game Development

IMGD Game Agents: Thinking (2 of 3)  Search Look ahead and see what move to do next Ex: piece on game board, pathfinding (ch 5.4)  Machine learning Evaluate past actions, use for future Techniques show promise, but typically too slow Need to learn and remember Based on Chapter 5.3, Introduction to Game Development

IMGD Game Agents: Thinking (3 of 3)  Making agents stupid Many cases, easy to make agents dominate  Ex: bot always gets head-shot Dumb down by giving "human" conditions, longer reaction times, make unnecessarily vulnerable  Agent cheating Ideally, don't have unfair advantage (such as more attributes or more knowledge) But sometimes might, to make a challenge  Remember, that's the goal, AI lose in challenging way Best to let player know how agent is doing Based on Chapter 5.3, Introduction to Game Development

IMGD AI for Games: Mini Outline  Introduction(done)  Agents(done)  Finite State Machines(next)

IMGD Finite State Machines (1 of 2)  Abstract model of computation  Formally: Set of states A starting state An input vocabulary A transition function that maps inputs and the current state to a next state Based on Chapter 5.3, Introduction to Game Development

IMGD Finite State Machines (2 of 2)  Most common game AI software pattern Natural correspondence between states and behaviors Easy to understand Easy to diagram Easy to program Easy to debug Completely general to any problem  Problems Explosion of states Often created with ad-hoc structure Based on Chapter 5.3, Introduction to Game Development

IMGD Finite-State Machines: Approaches  Three approaches Hardcoded (switch statement) Scripted Hybrid Approach Based on Chapter 5.3, Introduction to Game Development

IMGD Finite-State Machine: Hardcoded FSM void RunLogic( int * state ) { switch( state ) { case 0: //Wander Wander(); if( SeeEnemy() ) { *state = 1; } break; case 1: //Attack Attack(); if( LowOnHealth() ) { *state = 2; } if( NoEnemy() ) { *state = 0; } break; case 2: //Flee Flee(); if( NoEnemy() ) { *state = 0; } break; } Based on Chapter 5.3, Introduction to Game Development

IMGD Finite-State Machine: Problems with Switch FSM 1. Code is ad hoc Language doesn't enforce structure 2. Transitions result from polling Inefficient – event-driven sometimes better 3. Can't determine 1 st time state is entered 4. Can't be edited or specified by game designers or players Based on Chapter 5.3, Introduction to Game Development

IMGD Finite-State Machine: Scripted with alternative language AgentFSM { State( STATE_Wander ) OnUpdate Execute( Wander ) if( SeeEnemy ) SetState( STATE_Attack ) OnEvent( AttackedByEnemy ) SetState( Attack ) State( STATE_Attack ) OnEnter Execute( PrepareWeapon ) OnUpdate Execute( Attack ) if( LowOnHealth ) SetState( STATE_Flee ) if( NoEnemy ) SetState( STATE_Wander ) OnExit Execute( StoreWeapon ) State( STATE_Flee ) OnUpdate Execute( Flee ) if( NoEnemy ) SetState( STATE_Wander ) } Based on Chapter 5.3, Introduction to Game Development

IMGD Finite-State Machine: Scripting Advantages 1. Structure enforced 2. Events can be triggered, as well as polling 3. OnEnter and OnExit concept exists 4. Can be authored by game designers Easier learning curve than straight C/C++

IMGD Finite-State Machine: Scripting Disadvantages  Not trivial to implement  Several months of development Custom compiler  With good compile-time error feedback Bytecode interpreter  With good debugging hooks and support  Scripting languages often disliked by users Can never approach polish and robustness of commercial compilers/debuggers Though, some are getting close! Based on Chapter 5.3, Introduction to Game Development

IMGD Finite-State Machine: Hybrid Approach  Use a class and C-style macros to approximate a scripting language  Allows FSM to be written completely in C++ leveraging existing compiler/debugger  Capture important features/extensions OnEnter, OnExit Timers Handle events Consistent regulated structure Ability to log history Modular, flexible, stack-based Multiple FSMs, Concurrent FSMs  Can't be edited by designers or players  Kent says: "Hybrid approaches are evil!" Based on Chapter 5.3, Introduction to Game Development