ai evaluation david nowell cis 588 2/14/05 baldur’s gate

20
AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Upload: annice-martin

Post on 20-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

AI Evaluation

David Nowell

CIS 588

2/14/05

Baldur’s Gate

Page 2: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

How is AI used in the game?

Three types of NPC Characters:

Allies Non-Offensive Characters Enemies

Page 3: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Allies

    These start off with programmed responses.  If the player has them join the party, they are then under his control.  You can control their every action, or give them more general guidelines and allow them to decide how to achieve the goal, or give them no guidelines and let them decide what to do.  The actions of the NPCs is determined via customizable scripts, letting the player decide how he wants the characters to act.

Page 4: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Non-Offensive Characters

These are usually “information points.”  They are programmed to stay near a certain area and respond to the player with conversation, advice, or quests.  The only time AI is used by these characters is if something unexpected happens, such as a player attacking them, or a combat occurring near Guardsmen

Page 5: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate
Page 6: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Enemies

There are two different versions of these.  The first type is the “Wandering Monster.”  This creature is programmed to wander around a certain area of the map, and then goes into a combat mode when the player is seen near-by.  The second type is a planned encounter.  The character’s actions are scripted while encountering the player.  After that, the AI takes over for the actual combat.  The enemy AI is generally good, geared toward teamwork, such as formations & sneak attacks.

Page 7: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

What AI techniques are used?

Pathfinding Scripted Behavior

Page 8: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Pathfinding

All characters uses this.  You can click on a location on the map where you want to move to, and the character will find a route there, going around obstacles if necessary.  Similarly, characters will use this to find a route to attack an enemy, or to get into position for a ranged attack.

Page 9: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate
Page 10: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Scripted Behavior

This is the majority of the AI.  It is similar to SOAR, in that there are rules, and if they are met, then a condition will trigger.  This uses weights if multiple responses could be appropriate, but that's really just a shortcut for adding a random number condition to the IF statement. 

Example using 100% weights:

Page 11: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

// if I am poisoned then cure it // try potions first, they are fastest and always work // sometimes the spells fail IF     HitBy([ANYONE],POISON)     HasItem("POTN20",Myself) THEN     RESPONSE #100         UseItem("POTN20",Myself) END

IF     HitBy([ANYONE],POISON)     HaveSpell(INNATE_SLOW_POISON) THEN     RESPONSE #100         Spell(Myself,INNATE_SLOW_POISON) END

Page 12: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

IF     HitBy([ANYONE],POISON)     HaveSpell(CLERIC_NEUTRALIZE_POISON) THEN     RESPONSE #100         Spell(Myself,CLERIC_NEUTRALIZE_POISON) END

IF     HitBy([ANYONE],POISON)     HaveSpell(CLERIC_SLOW_POISON) THEN     RESPONSE #100         Spell(Myself,CLERIC_SLOW_POISON) END

IF     HitBy([ANYONE],POISON) THEN     RESPONSE #100         Shout(POISONED)         Continue() END

Page 13: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Tools used to implement the AI

Baldur's Gate comes with a AI scripting language & compiler available to players.  Each of the major character types have several sets of scripts that the player can choose as the default behavior for the NPC party members.  In addition, you can create your own custom scripts to get NPCs to act exactly as you would prefer.

Page 14: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate
Page 15: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Example Script Descriptions THIEF AGGRESSIVE:  The thief will attempt to hide in shadows when

an enemy is not in sight.  As soon as the thief is hidden, he will attempt to backstab the closest enemy. (THIEF1)

THIEF DEFENSIVE:  The thief will attack any enemies he notices who are attacking party members (including himself).  HE will not move far away from the party leader, so if he's pursuing an enemy he will turn back and return to the party if he has gone too far.  If the thief is reduced to 50% or lower hit points then he will run away and then attempt to hide in shadows and avoid combat. (THIEF2)

THIEF PASSIVE:  The thief will not move to engage enemies.  If he is attacked from a distance he will reciprocate with missile weapons.  If an enemy engages him in melee combat, then he will draw his melee weapon and attack. (THIEF3)

THIEF RANGED ATTACK:  The thief will attack any enemy when he sees them with the missle weapon he is most proficient with.  He will try to keep his distance from enemies, but if he's attacked in melee combat he will switch to a melee weapon. (THIEF4)

Page 16: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Thief 1 Code (Aggressive) IF

    HPPercentLT(Myself,50)     See(NearestEnemyOf(Myself)) THEN     RESPONSE #100         Help()         Continue() END

IF     Delay(10) THEN     RESPONSE #100         Hide() END

IF     See(NearestEnemyOf(Myself)) THEN     RESPONSE #100         AttackReevaluate(NearestEnemyOf(Myself),30) END

Page 17: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Thief 3 Code (Passive) IF

    HPPercentLT(Myself,50)     See(NearestEnemyOf(Myself)) THEN     RESPONSE #100         Help()         Continue() END

IF     Delay(10) THEN     RESPONSE #100         Hide() END

IF     See(NearestEnemyOf(Myself)) THEN     RESPONSE #100         AttackReevaluate(NearestEnemyOf(Myself),30) END

Page 18: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Strengths of the AI

 - Environment-Aware    - Will react differently based on conditions

such as:      Health     Items available      Terrain types  - Customizable    - Two otherwise similar AIs could have different scripts, making them seem unique to the player.  - Good pathfinding & moving in formations

Page 19: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Weaknesses of the AI

 - Predictable    - Under the same conditions, an AI will keep attempting the same actions

 - Doesn't learn    - If an attack is ineffective, the engine will alert you of this.  However, the AI does not use this information, but will continue attacking.

- Inflexible    - For every possible item / spell, need to spell it out in a script:      IF haveSpell(LightningBolt) THEN...    - If you have a character with multiple types of skills, makes things even harder.  Ie, a Fighter / Mage AI party member who has spells or weapons that do approximately equal damage.  To make the character use them intelligently requires intricate scripting

Page 20: AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate

Effectiveness in improving game play?

Effectiveness varies based on script & style.Default script has fairly stupid AI, does not add

to gameplayCustom scripts can greatly improve gameplay

- NPCs smart enough to do things like heal you w/o having to pause the game and command them makes the game much more enjoyable

Downside is having to understand the scripts makes player aware of limitations in the AI.- Can’t be truly surprised by behavior of the AI, as would be possible with a “black box”