Developing By Me

Project Development and Design

Neural Networks for a Single Mob

Neural Networking [NN] is something new to the gaming world. This is because the programming behind it can be complicated and hard to implement. The best way to explain how it works is that each attribute or statistic is used to create something unique by summing up all of the attributes into a single set of logic. Some of the concepts behind Neural Networking may sound like Genetic Algorithms however there is a difference. Neural Networks determine what an object will do while Genetic Algorithms defines what the object is.

There are a few good examples of how a NN can be created. First the mob can have dynamic logic, second the mobs could be a single unit acting both independently and collectively, finally the mob could change tactics to best fit the situation. Each has a different way of being implemented and different uses within a gaming environment.

Dynamic Logic is a method of determining what the mob needs to do in order to achieve a goal. This changes on every turn since the fight will change every few seconds the logic needs to adapt in order to keep up. Static AI’s tend to work in one of two ways they will either produce the decisions by a random system which can be loaded in the favor of some choices or they could be a pattern mob. The pattern is a predefined schedule that the mob will follow regardless of what is happening in the fight.

Table 1
Normal Attack 50%
Defend 30%
Special Attack 20%

The first example of the random AI is best explained in Table 1 above. This table defines that the mob will attack most of the time with the occasional special attack and will try to defend itself on a regular basis. This form is very common in games since it is easy to setup using a random number generator from 00 to 99. These tables could contain as few as two items or as many as 100 unique objects. Some developers even go as far as using a range from 000 to 999 expanding the potential variations. However, the average is around 5-10 different choices where 90% are a form of attack.

Table 2
1 Attack
2 Defend
3 Special Attack
4 Rest

Table 2 contrasts this since it is defined by a specific pattern. The NPC will start at 1 and cycles through until 4 is reached then start over with 1. In a typical game this is a boss fight. They will follow a specific pattern. Depending on other factors like recharge times or energy levels the order may appear to change but not enough to be unpredictable. For example let’s say the Attack can be done once every 15 seconds, the defence is once every 10 seconds and the special attack is once every minute. The mob will appear to attack and defend constantly and toss a special attack on occasion and when nothing is ready it will wait for one to be ready. This means that the mob will attack 4 times defend 6 times and launch a special attack once every minute. The order may change slightly but it will be consistent and predictable.

The goal of a NN is to break this up by changing the logic from the pattern or random based logic. How can it be done? There are a few ways first the mob needs more to choose from then three or four actions. Table 3 is an example of what a NN mob might have for options.

Table 3
1 Attack 2 Area Effect – Fire
3 Area Effect – Water 4 Large Fire Attack
5 Large Water Attack 6 Heal
7 Large Normal Attack 8 Death Blow
9 Defend 10 Rest

In table three the NPC has a total of 10 choices. But the choices of attacks are not the only thing it will look at. Since this mob is a Boss mob it will most likely have more than one player attacking it at any given time. That means the mob needs to account for the most effective attack to destroy the player team as fast as possible. So the mob has the choice to attack a single target, a group of targets or defend itself. This is similar to the other tables with one exception. This mob is a NN mob so it will use more logic.

To fight the boss mob the players have two choices fight close or from a distance. This is the first thing the NN will look at. If all of the players are clustered together either around the boss or in a corner then it will try to use the Area of Effect [AOE] attacks. That is because not just one opponent will be affected and every player will be weaker. However if they are all spread out and the AOE will be ineffective then it will stick to single target attacks with the hope of destroying the party one at a time. Every party member that falls will weaken the group. This choice happens constantly since players tend to move around based on their own objectives. The NPC will adjust its strategy based on where they are when the next attack is ready.

Next the NN boss will look at the party structure this only happens once during the fight unless someone joins the fight that is not in the list. In this event it will recalculate the party. The party ranking can be semi static this means every mob will act differently. Table 4 displays two different NN bosses and their strategies.

Table 4
Order Boss 1 Boss 2
1 Tank Healer
2 Melee Damage [MD] Melee Damage
3 Ranged Damage [RD] Tank
4 Healer Ranged Damage

As the table displays the two bosses will react differently. Boss 1 is more likely to use large heavy hitting attacks to destroy the Tank quickly then over power the rest of the party. On the other hand Boss 2 will try to overwhelm the support staff starting with the healer and any other ranged combatants leaving the tank for last. The two different strategies will determine the order the boss will try to fight the party however even a NN mob can be distracted by special attacks from players. Example, Boss 1 may take a swipe at the Healer if he heals the tank to full constantly while Boss 2 may try to disable the Tank so it can go after the healer. These two different methods of logic can change from attack to attack. Because of this the mob is less predictable. Some games use a form of threat generation to keep a mob in place however that logic is still a static concept not truly dynamic as a NN should be.

The third thing the mob can look at which uses all of the previous logic is what is effective on what players. Table 5 displays some basic information on the players. But in short the Boss will use this to its advantage when choosing both attacks and targets.

Table 5
Statistic Tank Healer RD MD1 Boss
Attack Type Physical Energy Piercing Fire Fire/Water
Defense Type Fire Water Physical Piercing Physical
Health 1000 300 400 600 50000
Defense Rating 100 5 30 50 1000

As displayed in the upper table every player and the boss has different basic stats. When the boss is fighting a player it will use its most effective attacks. It will not use a fire attack on the tank it will stick to other forms of attack even if fire is its most powerful attack. The only exception is if the fire attack less the Tanks resistance still does more damage than its other attacks. However this could change during the fight.

Let’s say that the tank is resistant to fire as shown but the healer casts an extra resist fire spell. Before the new spell is cast the fire attack may be doing 50 damage and the water is doing 40 and the physical is doing 45. After the attack the fire damage drops to 43. At this point the physical is the most effective and the boss will try to maintain that attack type using the others as support in between physical attacks but it will avoid the water attack if possible. But what if the fire damage dropped to 39 just under the water attack? That means the tactic would change again and it would only use a fire attack if it is attacking any player except the tank. But what if the whole party is highly resistant to the fire attacks? If this case the Boss will never use its fire attack and maintain a constant physical and water bombardment.

By expanding the options the boss has and providing a dynamic way of resolving attacks. A single mob can become far more effective and unpredictable. That is because that same party on the next round may use a different tactic but because the Mob has a NN AI it will change its tactics with every fight because the situation will change. A NN is not easy to implement but it gives the players a more realistic feel as if they were fighting a human instead of a preprogrammed machine with limited reasoning skills. If the developer chooses the AI could have more possible factors that determine what it will or can do but that will be covered later.

Related pages

  1. Finite State Machines
  2. Genetic Algorithms
  3. Neural Networks for Groups
powered by Related Pages WP plugin

4 Responses to “Neural Networks for a Single Mob”

%d bloggers like this: