Artificial Intelligence in Game Design

Document Sample
Artificial Intelligence in Game Design Powered By Docstoc
					Artificial Intelligence in
     Game Design
    Problems and Goals
              AI vs. Gaming AI
• “Standard” Artificial Intelligence
     •   Expert Systems
     •   Probabilistic/Fuzzy Logic
     •   Robotics
     •   Machine Learning
  – Goal: Finding best solution to some problem
  – Characteristics:
     • Expensive and time consuming to develop
     • Large number of processing cycles to run
               AI vs. Gaming AI
Example: Chess (“Deep Blue”, IBM)
• Basic approach (MINMAX algorithm)
   – Build tree of outcomes of next n possible moves
   – Grade each according to some heuristic
   – Choose current move that guarantees best result
• Combined with heuristic knowledge
   – Databases of opening moves, endgames
• Result:
   – Played at world champion level (best solution)
   – Took several minutes per move (ok in chess)
• Not viable as commercial chess game!
           Goals of Gaming AI
• Challenging but beatable:
  – Intelligence level artificially limited
     • Example: number of moves lookahead in chess
  – AI not given all information
     • Example: “fog of war” in Civilization
  – Intelligence level can be set by user
     • Possibly learned (Madden)
• Problem is often making AI intelligent enough!
  – Players will find and take advantage of limitations
  – “Cheats” often used to compensate for bad AI
           Example of Gaming AI

                           Soldier NPC
Player coming              setting up ambush
from unknown
direction                  What to hide
        Example of Gaming AI
• Choose at random?
   – Does not appear intelligent
• Current location of player?
   – Should not know this (cheat!)
• Base on realistic criteria
   – Terrain around soldier
   – Past player actions, etc.

This is most difficult approach!
          Goals of Gaming AI
  – Must consume few processor cycles
     • Competing with graphics!
  – Must often act in real time
     • Football, racing, etc.

• Simple approaches usually best
  – If necessary, may need to tweak game to
    support AI
    Example of Simplification
• Pac-Man
  – Ghosts pursue players through maze
  – Simple algorithm: just move towards player
  – Problem: ghosts stuck in cul-de-sacs
Example of Simplification
              Believable NPCs
• Opponents that offer challenge
   – “Orc” characters should move realistically
   – “Boss” characters should appear as intelligent as
• Minions that require little micromanaging
   – Example: scouts, workers, etc. in Civilization
      • Frustrating if minions make too many mistakes
• Other characters interesting to interact with
   – Example: Sims
            Believable NPCs
Intelligent Action:
  – Good decision making
  – Realistic movement
     • Evasion/pursuit of player
     • Choosing paths through complex terrain
     • Cooperation among group
  – Memory of previous actions
    (and possibly to improve)
  – Achieving goals
            Believable NPCs
Believable as Characters:
  – Acts like human (or orc, dog, etc.)
  – Has appropriate emotional states
     • Based on character, current state
  – Does not always behave predictably
     • Crucial to replayablity
     • Cannot appear too random
  – Can interact with player
     • Verbal and non-verbal interaction
            Believable NPCs
• Major simplification from standard AI:
          NPCs restricted to limited domain

  – Example: “shopkeeper” NPC
  – Can interact intelligently with player only in
    domain of shop
     • Will not leave shop
     • Only understands items for sale in shop
     • Only actions are transactions related to items
                    Turing Test
• Turing test for AI:
   – Computer “intelligent” if you can’t tell difference
     between interacting with human and computer
     Turing Test for AI Gaming
• Does NPC act appropriately for its role in game?
  – Does it act “intelligently”?
  – Does it appear to have appropriate information?
    (neither too much or too little)
  – Does it behave with the “personality” that we would

             Apparent Intelligence
• NPCs can appear intelligent to player even if rules
   – Rules give reasonable behavior
   – Rules complex enough so player cannot easily predict

“Theory of mind”
We tend to ascribe motives/decision
making skills similar to our own to
                                                        if hitPoints < 5
                                                           then run away from player
other entities, whether this is actually                if distance to player < 2 units
                                                           then attack player
                                                        if player visible

happening or not!                                          the run towards player
                                                           move in random direction
                 Swarm Intelligence
• Simple NPCs in groups can appear to cooperate
   – Rules must depend on state of other NPCs
• Decision example:
  if no other player shooting, I shoot   NPCs appear to be covering
  if in open, run for cover and shout    one another and coordinating
  if in cover, reload and wait           attack!

• Orc motion example:
  if NPC blocking path to player
     then run sideways
  else run towards player
              Swarm Intelligence
• Give each NPC slightly different set of rules
   – Creates illusion of personalities
• Example: Pac-Man
  if distance to player < n          n is different for each ghost!
     then move towards player
  else wander at random

                Large n : appeared “aggressive”

                 Small n : appeared “mellow”
          Role of Traditional AI
• Good decision making          Decision Trees
• Realistic movement
                                Finite State Machines
  – Evasion/pursuit of player
  – Choosing paths through      Robotics
    complex terrain
  – Cooperation among           Swarm Intelligence
• Memory of previous            Simple Iterative
  actions                       Learning
• Achieving goals
                                Goal-based Planning
          Role of Traditional AI
• Acts like human                   Finite State
  (or orc, dog, etc.)
• Has appropriate emotional
  states                            Probabilistic State
  – Based on character, current     Machines
• Does not always behave            Fuzzy State
  predictably                       Machines

                  Key idea: all of these are simple and
                  fast algorithms (unlike much of AI)
Programming Assignments (in C++)
  – Finite State Machine for NPC (your choice)
  – Motion in simple game
• I will provide game engine for each
  – Graphics, interaction
  – Driver that runs your rules
• You will provide rules that my driver runs
  – Minimal programming
              Final Project
• Implementing AI-based algorithm in game
  – Your choice of algorithm, game
  – Can be part of a game (such as a single NPC)
  – Can be in language of your choice
  – Can be a group project

Shared By: