Title: EmoBot: Incorporating Emotion into Quake 2 AI
1EmoBot Incorporating Emotion into Quake 2 AI
Artificial Intelligence in Game
DevelopmentEastern Washington University, Fall
2003
- Tye Hooley
- Bart Hunking
- Mike Henry
2Our Project
- The project had several goals we wanted to meet
- Modify the AI used by Quake 2s bots
- Incorporate a particular AI approach
- Make the Quake 2 AI more intelligent
(hopefully!) - Develop a tutorial based on this experience
- Demonstrate the modified Quake 2 game
3Project Decisions
- Many possible approaches to building AI into a
game - Decision will often depend on the type of game
and what algorithms or methods are most effective
for solving problems in that game - Quality of AI may sometimes need to be balanced
with game performance (e.g., speed) theres a
trade-off - Often, finite state machines are used as simple
solutions - One possibility for some types of games is to
give AI players emotions - We saw that bots in Quake 2 could be given
emotional states and perform actions specific to
their current states
4Quake 2 Artificial Emotion Engine
- Our decision create a simple artificial emotion
engine for Quake 2s bots - Why did we choose this?
- Relatively new approach to game AI
- Allows us to do some interesting experimentation
- Demonstrates uncertainty in reasoning via fuzzy
logic - Relevant to a game such as Quake 2
- We named our new bot AI EmoBot
- Some of the ideas for our engine were developed
from Ian Wilsons paper, The Artificial Emotion
Engine, Driving Emotional Behavior
5Overview of the Engine (1)
- Here are some of the guidelines we used in
creating the engine - The emotional state of EmoBot should depend on
sensory information available in Quake 2
variables - An emotional state (for the purposes of the
engine) has two components fear and aggression - EmoBot should exhibit some behavior as a set of
actions, based on its current emotion
6Overview of the Engine (2)
Fuzzy logic
Game variables
Fear
Emotion
Aggression
EmoBot action 1
Behavior
EmoBot action 2
7A Brief Overview of Fuzzy Logic (1)
- Traditional set theory
- An item belongs to a set completely or not at
all - Example
- Few 0, 1, 2, 3, Many 4, 5,
- The number 2 belongs 100 to Few and 0 to Many
- Fuzzy set theory
- An item belongs to a fuzzy set with some degree
of membership µ between 0 and 100 (i.e., in the
interval 0, 1) - A fuzzy set is defined by an associated
membership function in some domain
8A Brief Overview of Fuzzy Logic (2)
- Example
- 3 fuzzy sets cold, warm, hot in a temperature
domain - 45 has µ of .75 in cold, .25 in warm, and .00
in hot -
- Simple membership functions (as above) are
preferred
cold warm hot
40 45 60
temperature, F
9A Brief Overview of Fuzzy Logic (3)
- A fuzzy rule maps fuzzy sets from one or more
input domains to a fuzzy set in an output domain - A fuzzy rule set is a collection of these rules
- Example with two input domains
- input domain 1 temperature (cold, warm, hot)
- input domain 2 wind (light, moderate, strong)
- output domain time-outside (brief, long)
- IF temperature IS cold AND wind IS strong
- THEN time-outside IS brief
- IF temperature IS warm AND wind IS moderate
- THEN time-outside IS long
- etc.
10A Brief Overview of Fuzzy Logic (4)
- Given a set of input values, the domains, and a
fuzzy rule set, an output value may be found - Step 1 Rule evaluation
- For each rule, memberships of the input values in
the rules fuzzy input sets are found - These determine the support for the rules fuzzy
output set - Step 2 Defuzzification
- Support results are combined and defuzzified into
a single output value - Example (cont.)
- Input values temperature 45F, wind 10 mph
- ? Rule evaluation ? Defuzzification ?
- Output value time-outside 90 minutes
11Fuzzy Logic Process
Input domain 1
Input domain 2
Output domain
Input value 1
Input value 2
Rule evaluation
Fuzzy rule set
Defuzzification
Output value
12Quake 2 and Fuzzy Logic
- Fuzzy logic for determining fear and aggression
is implemented in Fril, which is an AI language
useful for fuzzy reasoning - Quake 2 was modified to make calls into the Fril
code through a C-Fril interface - Interface consists of a DLL and provides C calls
into it
Quake 2 C code (modified)
Fuzzy logic Fril code
C-Fril interface
13Division of C and Fril tasks
- Quake 2 C code Fuzzy logic Fril code
Quake 2 input values
Input domains
Aggr. output domain
Fear output domain
Behavior
Quake 2 AI actions
Rule evaluation
Fuzzy rule set
EmoBot emotion
Fear output value
Defuzzification
Emotion mapping
Aggression output value
14Quake 2 Fuzzy Domains (1)
- 6 variables accessible in the Quake 2 code were
used as input domains and each given 3 fuzzy
sets - bot health current health of the bot
- bad, fair, good
- player health current health of the player
- bad, fair, good
- bot damage amount of damage players weapon
can inflict - poor, average, great
- player damage amount of damage players
weapon can inflict - poor, average, great
- distance current distance from bot to player
- near, midrange, far
- angle angle between bots line-of-sight and
line from bot to player - small, medium, large
15Quake 2 Fuzzy Domains (2)
- There are also two output domains with 3 fuzzy
sets each - fear level of bots fear
- low, medium, high
- aggression level of bots aggression
- low, medium, high
- For simplicity, all input domains and output
domains use the same general model of membership
functions - All input values are scaled so that they lie in
0, 1
0 .2 .4 .6 .8 1
scaled value
16Quake 2 Fuzzy Rule Set (1)
- Fuzzy rules used to determine fear and
aggression - reasoning bot is not afraid when it has health
to spare - IF bot-health IS good
- THEN fear IS low-fear
- reasoning bots fear may increase if its
health relative to player is lacking - IF bot-health IS fair AND player-health IS bad
- THEN fear IS low-fear
- IF bot-health IS fair AND player-health IS fair
- THEN fear IS low-fear
- IF bot-health IS fair AND player-health IS good
- THEN fear IS medium-fear
- reasoning when bot is closer to death, fear
becomes significant - IF bot-health IS bad AND player-health IS bad
- THEN fear IS medium-fear
- IF bot-health IS bad AND player-health IS fair
- THEN fear IS high-fear
17Quake 2 Fuzzy Rule Set (2)
- Fuzzy rules (cont.)
- reasoning bot should be aggressive with a nice
weapon - IF bot-damage IS great
- THEN aggression IS high-aggression
- reasoning bots aggression varies with a so-so
weapon - IF bot-damage IS average AND player-damage IS
poor - THEN aggression IS high-aggression
- IF bot-damage IS average AND player-damage IS
average - THEN aggression IS high-aggression
- IF bot-damage IS average AND player-damage IS
great - THEN aggression IS medium-aggression
- reasoning bots aggression varies more with a
weak weapon - IF bot-damage IS poor AND player-damage IS poor
- THEN aggression IS medium-aggression
- IF bot-damage IS poor AND player-damage IS
average - THEN aggression IS medium-aggression
18Quake 2 Fuzzy Rule Set (3)
- Fuzzy rules (cont.)
- reasoning shorter proximity to player
increases aggression - IF distance IS near
- THEN aggression is high-aggression
- IF distance IS midrange
- THEN aggression is medium-aggression
- IF distance IS far
- THEN aggression is low-aggression
- reasoning longer time for bot to turn to
attack increases fear - IF angle IS small
- THEN fear is low-fear
- IF angle IS medium
- THEN fear is medium-fear
- IF angle IS large
- THEN fear is high-fear
19EmoBot Emotion Space
- After the Fril code evaluates all rules and
defuzzifies the outputs, two values are returned - fear, in 0, 1
- aggression, in 0, 1
- This can be viewed as a point in two-dimensional
fear-aggression space - Regions of this space can then be associated with
particular bot emotions - We decided to divide this space into 6 regions
- The result is 6 separate emotions for EmoBot
20Fear-Aggression Space
- Combination of 6 input values ? fuzzy logic ?
fear-aggression x-y pair ? emotional state of
EmoBot
21EmoBot Emotional Behaviors (1)
- Each emotional behavior is composed of one or
more Quake 2 AI atomic actions, which are
performed through functions provided in the code - Less aggressive behavior, low fear to high fear
- Cautious sniping attack
- Hold position (do nothing)
- Shoot
- Cautious Attack evasive attack
- Jump either left or right, chosen at random
- Shoot
- Afraid run away
- Turn 180 away from player
- Move forward
22EmoBot Emotional Behaviors (2)
- More aggressive behavior, low fear to high fear
- Psycho confident rushing of player
- Charge player
- Shoot
- Cautious advance careful rushing of player
- Face player
- Move forward
- Shoot
- Strafe left or right, chosen at random
- Panic chaotic motion
- Turn bot toward random direction
- Move forward
23End of Tutorial
- Specialized information provided after this slide
24Weapon Damage (1)
- Much of the damage variable was based upon
experience, although the basis was taken from the
game. This means that we retrieved the values
from the game and other references, then had to
tweak our findings to make it more suitable for
the EmoBots. Damage couldn't be based upon
per-shot basis due to the fact that the guns have
different rates of fire. So, damage/sec was
calculated producing Table 1.1. - We then used the calculated table as the basis
for determining the actual EmoBot damage
variables. These changes were based entirely
upon game-playing experience. Table 1.2 is the
final result of our tweaks. - To get the final value between 0 and 1, we
divided the weapon damage/sec by the largest
weapon's damage/sec (BFG 250).
25Weapon Damage (2)
- Table 1.1 Calculated Damage/sec
- Weapon Damage/sec
- -------------------------------------------------
--- - Blaster 40
- Shotgun 40
- Super Shotgun 120
- Machinegun 80
- Chaingun 120-240
- Grenade 41
- Grenade Launcher 120
- Rocket Launcher 96
- Hyperblaster 200
- Railgun 67
- BFG 166
- this is due to the lasers... they can do
"unlimited" damage if the bot is around the
projectile
26Weapon Damage (3)
- Table 1.2 Our derived table--taking in
consideration of player tactics - Weapon Damage/sec
- -------------------------------------------------
--- - Blaster 40
- Shotgun 60
- Super Shotgun 100
- Machinegun 80
- Chaingun 110
- Grenade 70
- Grenade Launcher 120
- Rocket Launcher 150
- Hyperblaster 175
- Railgun 140
- BFG 250
27Bot Special Attacks
- monster_berserk, 15 for spike attack,
- monster_gladiator, 20 for hit, 50 for railgun
- monster_gunner, same as gunner
- monster_infantry, 5 for hit, 3 for bullet
- monster_soldier_light, 2
- monster_soldier, 2
- monster_soldier_ss, 5
- monster_tank, 30 for blaster, 50 for rocket, 20
for bullet - monster_tank_commander, same as tank
- monster_medic, 2 for blaster
- monster_flipper, 5 for hit
- monster_chick, 10 for hit, 50 for rocket
- monster_parasite, 5 initial, 2 every iteration
after - monster_flyer, 5 for hits, 1 for each blaster
shot - monster_brain, 15 for hit
- monster_floater, 1 each blaster shot, 5 for hit
- monster_hover, 1 each blaster shot
- monster_mutant, 10 for hits
- monster_supertank, 50 for rockets, 6 per bullet
28Damage by Bot Type, Scaled
- monster_berserk 0.50
- monster_gladiator 0.36
- monster_gunner 0.36
- monster_infantry 0.30
- monster_soldier_light 0.16
- monster_soldier 0.18
- monster_soldier_ss 0.20
- monster_tank 0.40
- monster_tank_commander 0.48
- monster_medic 0.16
- monster_flipper 0.20
- monster_chick 0.38
- monster_parasite 0.60
- monster_flyer 0.24
- monster_brain 0.75
- monster_floater 0.25
- monster_hover 0.17
- monster_mutant 0.32
- monster_supertank 0.60