Gaming
 

AI

From Neverend

The server handles various layers of AI. Since most objects are really NPCs, the behavior of those objects is governed by the server.

NPC AI: The individuality of NPCs is determined by stats that govern personality, which affects what the NPC is likely to do. A social NPC will hang out at a bar. A strong NPC will choose a strength related job such as lumberjacking. An agile NPC will choose to be a hunter. The dialogue of each NPC is based on a dialogue system that is written by content creators when they are not "playing" as the NPCs. NPC AI treats the NPC as a group with one member.

RTS AI: Groups of NPCs will maintain a city. They will do so according to their current jobs. When a building is destroyed or damaged, they will attempt to repair it. If there are no carpenters or woodworkers around, they will train some peasants in the repair skill, and those peasants will repair the building. The time it takes to train and repair allows the illusion of time, rather than god-like instant repair abilities.

Each "unit" in the city will focus on training skills gradually, performing city maintenance, and going about a daily routine. The mentality of all the units in the city is to maintain the city.

City AI: The city itself has AI. Each part of the city is a building. Buildings may "need" repair, or "need" guarding , or "need" to be populated by NPCs. The city may also "need" more buildings, such as a city that only has 1 or 2 buildings but a population of 20. The type of architecture, models, and textures used in the city are based on its AI. The objects found in the city are based on AI (waterpump, bushes, statue, etc).

Weather AI: Weather, if it is implemented, will use AI that affects the world in subtle and dramatic ways. Rain will pour rain and have a "rain drops" texture on the land. Wind may ask the trees to blow, if framerate isn't an issue.

Ecology AI: Ecology AI is much like RTS AI, but for non-intelligent animals. Animals will seek food, attack other animals, have sex, roam, attack enemies, etc. Ecology treats animals and monsters as groups, who try to ensure their own survival by avoiding danger. As a group, they show grow group awareness, either attacking together, fleeing together, or eating together.

Monster and animal AI: This is the individual AI of an animal. While simple compared to an NPC, animals and monsters will react in different ways. For example, an injured animal will not be able to flee along with others, and will have to react differently to a nearby hunter, while the others have left. Animal AI treats the animal as a group with one member.

Contents

[edit] Monster AI

[edit] Monster Intelligence

Monster intelligence is a stat that acts as an intelligence level for the monster. Different AI types are assigned to different Intelligence ranges, with lower intelligence using lesser tactics, weaker skills, weaker abilities, weaker spells, less spell casting, less party tactics, and more reliance on direct combat without using skills to full ability. Medium intelligence uses AI scripts that provide a challenge to the opponent, with good use of abilities and spells, and party cooperation. High intelligence uses AI settings that ensure maximum efficiency with party and war tactics, class abilities, spells, healing, use of items, and exploiting class weaknesses in opponents.

  • Intelligence from 1-3 is very low, 4-7 is low, 8-12 is average, 13-16 is intelligent, and 17-20 is genius.
  • Different monsters have different default levels of intelligence, and all have a maximum of 20. Monsters that have only one AI setting will use the same AI regardless of intelligence.
  • Monsters with multiple AIs will use the specified AI for their intelligence.
  • Monsters that lack a specified AI for very low, low, intelligent or genius will use the next lower or higher AI setting, with a default of average AI.

Intelligence also effects spells and magic skill. Spells that lower monster intelligence can lower the power of monster spells and make powerful spells unuseable. Due to a lower AI setting or having no useable spells, the enemy will attack directly or run away.

[edit] Types

Centipede: Crawls towards target, going over short hills and rocks, around tall and large objects. Will attack when reaching target, use threat (rear back and hiss/bare fangs), and use upper body to select and attack a target. When a target is trying to escape, it can whip its upper body to the side or forward and try to attack. It can also use an ensnaring move that closes on the target with limbs and mandibles, and drains health and can add poison/paralysis. Ensnaring is interrupted when time expires, when attacked, or when taking damage.

Dragon1: Peaceful, does not attack unless provoked.
Dragon2: Exploratory, hunts food, does not attack unless provoked.
Dragon3: Lurking, finds prey and attacks.
Dragon4: Hiding, waits in favored terrain and runs and attacks when in range.
Dragon5: Intelligent, uses conversation and terrain to advantage. For adult dragons.
Dragon6: Very intelligent, uses conversation and terrain to advantage. For elder dragons.
Dragon7: Curious, will act naive and clueless, play with prey, and beg for food. For baby and young dragons.
Dragon8: Uses air attacks and attack patterns for diving, dodging, swooping, and encircling prey.
Dragon9: Enraged, uses breath, tail, claws, and mouth to attack.


[edit] Tactics

Enemies use battlefield tactics that are applied to small skirmishes and huge battlefield warfare. Enemies attack multiple targets by dividind forces and using class based tactics, threats, and level vs level challenge. High level monsters will intentionally challenge high level players, while low level monsters will attack low level players. This is shown visually as confidence. Cowardly goblins will be fearful of high level players, but insult and threaten low level players.

High level monsters will act superior to low level players, and ignore them unless provoked directly. High level monsters seek even matches with heroic players. They will show presence by walking dramatically with dramatic visual effects such as flowing cape, heavy footsteps, visible aura, charging energy, sharpening sword, snarling, staring, and breathing fire. They can issue RTS commands to rally troops and assist or gang up on powerful players. High level players are targeted more often and are at greater risk than low level players who are ignored.

Enemies use class based tactics such as tank, healer, ranger and rogue. Enemies assist each other in parties to be more efficient, including pulling, tactical retreat, rushing, attacking casters and healers, group healing, buffs, debuffs, status effects, poison, curses, AoE, DoT, class abilities, spells, and use of landscape including ranged attacks from a high distance and kiting with multiple ranged attacks.

Enemies have dramatic moves that give players extra time to attack:

  • an Orc chieftan laughing as he sends minions to attack.
  • a Raptor draws back and hisses at a party threateningly.
  • an Ogre screams and grunts threats before attacking.
  • a Goblin laughs, throws insults, or runs away.
  • a wolf or bear snarls.
  • undead groan and stumble.
  • Bandits make threats, laugh, insult, perform gestures.
  • A drake backs up and looks menacing.
  • Rats hiss, draw back, then strike.

[edit] Behavior

There are hundreds of AI behaviors. Most are disabled by default, with only a few active based on the type of monster. Monsters with a high intelligence score tend to have more AI behaviors than those with a low score, who have basic behaviors. Spells that descrease intelligence may disable some behaviors temporarily. Behaviors take into account strategy, surroundings, nearby plants, animals, monsters, NPCs, players, challenge, skill, weaknesses, strengths, etc.

-Retreat -Attack closest -Attack farthest -Attack Strongest -Attack weakest -Take cover -Healing magic -Offensive magic -Status magic -Necromancy -Summoning -Charming -Taming -Throwing attack -Move to high ground -Run towards camp -Run away from camp -Encircle -Run towards strongest ally -Run towards nearest ally -Run in circles near ally -Gang up on ally -Delta formation -Line formation -Phalanx -Circle formation -Encircle formation -Ranged attack -Target highest defense -Target highest magic -Target lowest defense -Target lowest magic -Target highest health -Target lowest health -Target random -Target caster -Target attacker -Target defender -Target most difficult -Target least difficult

[edit] Monster behavior

- Monsters will not stand idly by as you butcher their colleges; they will join in, attempt to run to get reinforcements if they are out numbered or prepare to cast a spell. - AI controlled monsters will, if left alone long enough, congregate together and create camps which in turn will cause bigger nastier monsters to spawn. If players can wipe out a camp it won't just pop back into existence but another camp may have been settled somewhere else. - Monsters and AI controlled NPC's will have their own attributes. Some will be fearful and some aggressive, some will be short sighted others will have great hearing. The player will have to learn what's what and tread very carefully. -AI controlled monsters will, if left alone long enough, congregate together and create camps which in turn will cause bigger nastier monsters to spawn. If players can wipe out a camp it won't just pop back into existence but another camp may have been settled somewhere else. -Mobs will find and kill human and gain exp and level, they will group together and hunt like we do to them. Only different is they are permadeath, certain dynamic event will trigger faster/slower mob spawn(not those already dead). The longer a mob stay alive, the stronger and more loot and wealth. Mob control zone and town. If they grow too strong they will band together(ie. 200 of them attack human cities), players has to fight together with town guard or take refuge in other town.

[edit] Adaptive AI

Adaptive can be activated or deactivated. It exists as an experiment, and the results of an adaptation can be logged and saved. Saved adaptations can be used as static AI behavior. Adaptive aI requires thorough testing and observation. For example, a mob that will kill off all the players in the wilderness, shack through city defenses, loot all the shops, and then quickly move on.

Mobs have their behavior dynamically modified using natural selection concept. Mobs who do better (=kill more players, live longer, etc) get their "genes" passed on to more newly born mobs of that type.

The behavior includes AI decisions such as:

- when to run away - whom to attack in a party* - whether to aggro** - when (during a battle) to use mob's special spells/effects - where (within the allowed area) to spawn and roam (or stand still); - whether to chase players, and how far***

Behavior does NOT include parameters that are obviously "the higher the better" such as monster's vision range, strength, etc.

Potential problems:

- mobs become too powerful; this will happen slowly, and can be easily remedied _if needed_ thru slow/long-term rebalancing such as offering more mob-type-specific dmg items, or reducing the mobs' spawn areas, or offering a quest to remove the mobs from the area, etc.

- too many factors make mobs' natural selection too slow to be of any interest (we dont' want to wait until real-life year 2100 to see the orc finally learning to hide behind a rock). This can be remedied by reducing the number of decisions the mob needs to make and/or helping the mob a little in making those decisions (e.g., rather than having mob make random choices about what attack/defense/job/class/race players to aggro, predefine say a few dozen of reasonable categories of players, and make the mob simply choose which categories it wants to aggro on).

  • presumably attacking the nuker or healer is best; the mob will learn to do that, but it's still limited by the Provokes of the fighters (at least in FFXI terminology)
  • based on some of the following:

- player's lvl/job/race/weapon/armor combination (alternatively, based on player's melee strength/defense, magic strength/defense, and other derived stats) - size and composition of a party (some monsters can see that there's a party, some can't); perhaps attacking a party without a tank is going to be fun for a strong melee mob - player's status/actions (someone is healing / low on HP => attack, someone is standing still or remains in a small area - maybe don't aggro as much cuz that guy is more likely camping, and so is ready for a fight).

This will obviously break the pull/camp technique. perhaps it should only be limited to higher-level and/or special types of mobs. i don't know, but i hope allowing some mobs to defeat this technique will force players to think of more interesting ways to hunt the mob. if this simply results in unbalancing the game, take this freedom away from the mobs.

[edit] Group spawning

Mobs grouping together and spawning buildings. This happens somewhat in CoH. Basically a group will spawn together, the bigger the group the more likely a boss will be in the group. The groups spawn at random locations doing random things. Some may be trying to steal a car. Some may be trying to mug an old lady. Some will be sitting around talking and yes you can listen to there conversations. Larger groups will spawn things like boxes or trashcans to sit on. This makes hunting interesting. As for genetic selection with mob AI, your basically suggesting they implement a genetic algorithm. While in theory this would be a good idea it generally takes many generations, in small cases as few as 1,000 in big cases as many as 10,000,000 or more, to produce results. The results also tend to be worse then if a programmer just made up the rules for the mob AI. Also you need a fairly large genetic pool where there is a broad sampling of traits. So basically 100 orcs would most likely not give great results. However 10,000 might give good results. Genetic algorithms are good at finding an above average solution to a problem in a average amount of time, but they are not good at finding the best solution (unless it gets lucky). Genetic algorithms are used for attempting to find a solution in a random search space. They are good at finding a solution that is good but not perfect. They are generally used on problems that have a non-linear computional cost, as the set gets bigger in a linear manner the cost for finding the solution grows in a faster then linear manner. So in the case with mob AI where there is only a few parameters and a few values for each it might not be the optimal algorithm for finding the solution.

[edit] Difficulty

One way would be to look at percentage of battles the mob wins/loses. But there's a problem with this approach. Mob's level should really determined not by the percentage of parties that can handle it, but by whether a good party can kill it with almost 100% certainty. The meaning of *good* may range from "not completely stupid" at level 1, to "perfectly timed, highly coordinated, well-balanced parties using advanced equipment and food" at level 60. And of course, this is hard to define other than by manual testing. If all we do is make mob level 25 when 85% of level 25 parties can kill it, we'll be erring one way or another. If the parties that go for this mob are already very good, then 15% death rate is unfair; exp loss from such deaths may be greater than average xp gain, resulting in noone wanting to fight this mob. If the parties fighting this mob are inexperienced, then 85% success rate is too high, since anyone who moves beyond the awkward uncoordinated fighting will find the mob too easy.

[edit] Terrain behavior

Monsters and NPCs have different behaviors for every terrain type. This allows for specific types of interaction if a monster or NPC happens to be located in a cave, town, beach, etc. When the monster or NPC is in a new terrain it continues its current actions but switches behaviors instantly so that it can properly react to the terrain. This is important with teleportation, transportation, slavery, or other effects that may bring a monster or NPC out of its habitat.

  • Beach: monster or NPC is aware of water and tries to stay on land or at waist length in water, without going too far in. The exception is aquatic monsters, which try to stay in water without going on land. Land monsters and NPCs that have no problem swimming may swim in water normally.
  • Ocean: monster or NPC tries to swim to nearest land, rock, island, raft, barge, or ship. Aquatic monsters stay in water at specified depth unless provoked.
  • Forest: monster or NPC is aware of trees and rocks and will go around them, use them for cover or ambush, or pick them up or destroy them if they are large or gargantuan monsters.
  • Cave: monster or NPC will try not to fly, and will not run in to walls, rocks or stalactites. Pathfinding is essential.
  • Town: monster or NPC will navigate between buildings unless it wants to damage or destroy buildings.
  • Indoors: monster or NPC will be aware of walls and not bump in to walls or furniture. Will break through obstructions or destroy obstacles to get to target. May try to destroy wall or door to get through.
  • Dungeon: monster or NPC will settle in room unless provoked. Will go towards exit if some other obligation exists.
  • Bridge: monster or NPC will attack on bridge but can move around and underneath bridge, or fly or jump off bridge if there are attackers below.
  • Mountain: monster or NPC will navigate paths on mountain, climb mountain, or fly over mountain. Cliffs will be navigated around.
  • Ledge: monster or NPC will try not to fall off edge unless the adjacent ground is no more than thrice the monster or NPC's height. Will avoid falling to death in chasms or on side of mountains.
  • Ocean floor: Will stay at ocean floor if aquatic. Will pursue if aggravated. Will swim towards surface if non-aquatic.
  • Ship: will stay on ship surface or go in to cabin area. Will try not to fall off ship, boat, barge, or raft. Aquatic creatures try to fall back over edge and in to water.
  • Land: aquatic creatures try to go towards nearest body of water.
  • Underground: will avoid flying or bumping in to walls.

[edit] Restrained behavior

Monsters and NPCs can be restrained by a number of methods. This causes the monster or NPC to have a struggling, sedated, tortured or sleeping animation. The monster or NPC should not be traveling while restrained, except within a designated area such as a jail cell.

  • Caged
  • Jailed
  • Restraints
  • Bound
  • Asleep
  • Psychic control
  • Psychic torture
  • Magic bonds
  • Magic torture
  • Torture device
  • Torture
  • Entrapped
  • Entrapped and tortured
  • Sealed (object conceals monster)
  • Frozen (ice object holds monster)
  • Magically contained (magic item or object holds monster)
  • Caved-in, an object contains the monster after a cave-in or collapse
  • Entombed, the monster is held within a tomb and is inactive until opened
  • Buried, the monster is held in a grave object
  • Entangled, the monster is held by ropes or vines
  • Psychic entangle
  • Magic entangle
  • Submerged, the monster is held underwater, lava, mud, swamp water
  • Object seal, the monster is an object and must be released by certain conditions
  • Item seal, the monster is an item and must be released by certain conditions
  • Room seal, the monster is within a room with no entrance or exit and remains inactive until an entrance is opened
  • Waiting, the monster is in a room but is inactive until a player is in the vicinity
  • Special bound
  • Special tortured
  • Special entrapped
  • Special contained

Special restraints are used in quests and dungeons for the typical monster that must be sealed or unsealed. A special item or object may be involved that keeps the monster in a restrained status until unsealed. When unsealed, the monster becomes active and the quest is available again. In a dungeon, a monster may need to be released to be defeated, or sealed to trigger an event.