# Artificial Intelligence in Game Design

Document Sample

```					Artificial Intelligence in
Game Design
Lecture 2:
Intelligent Decision Making and
Decision Trees
Decision Making
• Based on internal and external information

“I am hungry”   “There is food nearby”

• Defines a current action (“eat food”)

• Changes world and internal state

“Food nearby is gone”    “I am not hungry”
“Intelligent Agent” Approach
• Reflex agent
No memory, just “if-then” rules           input           rules        action

• Memory-based agent
input           rules           action
Also based on current state

memory
• Goal-based agent
Chooses actions that best help meet
current goal
• Utility-based agent                                         Goal-based
Balances multiple weighted goals,
choosing actions that give best                             planning
overall state                                               Sims
Reflex Agents
• Example: “orc” reflex agent

if hitPoints < 5
then run away from player
if distance to player < 2 units
then attack player
if player visible
the run towards player
else
move in random direction
Reflex Agents
• Example: “orc” reflex agent

if hitPoints < 5                  Internal state
then run away from player
if distance to player < 2 units   External state
then attack player
if player visible
then run towards player
else
move in random direction
Reflex Agents
• Actions often hierarchical

if hitPoints < 5                  These will call complex
then run away from player      navigation subroutines
if distance to player < 2 units   to implement the action
then attack player
if player visible
then run towards player
else
move in random direction
Reflex Agents
• Must consider cost of gathering inputs
if hitPoints < 5
then run away from player        This requires complex
if distance to player < 2 units     computations
then attack player
if player visible
if player in same room or distance to player < 5 units
then run towards player
else
move in random direction
Apparent Intelligence
• Reflex agent not intelligent
• Can appear intelligent
– 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
the run towards player
happening or not!                                       else
move in random direction
Swarm Intelligence
• Reflex agents 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
…                                                    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”
Reflex Agents
• Possible problem:
–   Multiple rules may fire
–   Indicated actions may be contradictory
–   Action may depend on order of rules
–   Problem if rules added by multiple developers
(side effects)

if hitPoints < 5                  What if next to player
then run away from player      and have low hit
if distance to player < 2 units   points?
then attack player
Decision Trees
• Simple decision tool                     Hit points < 5?

– Easy for non-programmers                               no
yes
to understand
Obstacle between                Within one unit
– No ambiguity         myself and player?                of player?
– Very efficient        yes       no              yes          no

hide      run        attack          Path to
player
clear?
• Simple tree traversal
yes          no
– Node = question
– Branch to follow = answer                                        run
run towards
– Leaf = final action to take                   player          sideways
Randomness in Decision Trees
• Make decisions at some nodes based on
random number

Math.random() < 0.5

yes             no

defend       Math.random() < 0.2

yes            no

Swing sword             Swing sword
from left               from right
Randomness in Decision Trees
• Problem:
Generating different random action may not be plausible

Math.random() < 0.4

yes            no

Stand still                   Patrol

• Will both stand still and patrol for a few frames at a time
• Better if it decided to do one and keep doing it for a while
• Need states to implement this idea

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 1 posted: 4/19/2013 language: English pages: 14