8. Bot decisions

The Omicron bot uses fuzzy logic to make decisions. The fuzzy logic is used as a decision library. All the possible decisions are efficiently stored in a set of fuzzy logic functions.

8.1 Fuzzy logic

Fuzzy logic is a superset of conventional (Boolean) logic. This logic was extended to handle the concept of partial truth, also using values between "completely true" and "completely false".  It was introduced by Dr. Lotfi Zadeh of UC/Berkeley in the 1960's as a means to model the uncertainty of natural language.

Fuzzy Subsets

Just as there is a strong relationship between Boolean logic and the concept of a subset, there is a similar strong relationship between fuzzy logic and fuzzy subset theory.

Let's assume there's a set S and to all it's elements there's one element of the set {0,1} attached. The subset U of the set S is defined as all the elements of S that have an '1' attached. The truth or falsity of the statement "x is in U" can be determined. The statement is true if there's a 1 attached to the element 'x' in S. Otherwise the statement is false.
 
Similarly for the fuzzy case there's a set S. But now a value from the interval [0, 1] is attached to every element of S. The subset U of the set S isn't strictly defined in this case. However it can be determined how much an element from the set S belongs to the fuzzy subset U. A value of zero attached to an element from S represents complete non membership of U. A value of one represents complete membership. The values between zero an one represent intermediate degrees of membership. The degree to which the statement "x is in U" is true can also be determined. The degree of truth of the statement is given by the attached value to the element x in the set S.

Fuzzy functions and relations

Often a value from the interval [0, 1] is attached to an element of the set S using a function, the membership function. Such a function is one-dimensional because it's based solely on one criterium. In practice functions based on two or even more criteria. Such a function gives a value from the interval [0, 1] to a combination of criteria and is often referred to as a "fuzzy relation". The criteria don't have to be elements from the same set they could just as well be elements from different sets. The criteria also don't have to be elements from sets. Variables of some kind could also be used as criteria.

Omicron bot and fuzzy logic

For the Omicron bot functions are used to give a value from the interval [0, 1] to specify how much the bot wants to have, do or use something. For instance a value is attached to how much the bot wants to retreat. The function gives the value based on the current situation and environment of the bot. The situation and environment are represented by a set of variables.
 

8.2 Decisions

The Omicron bot uses fuzzy logic to make several decisions. One of these is the decisions to switch between leafs of the AI tree. Fuzzy logic is also used to decide what is the best weapon during battles. The best nearby and long term goals are chosen with fuzzy logic as well.

AI Leafs

Although most of the switching between leafs of the AI tree is based on facts (for instance there is a visible enemy), there are situations the bot chooses between leafs using fuzzy logic. The Omicron bot is able to evaluate how much it wants to retreat or chase using fuzzy logic. The bot attaches a weight in the range [0, 1] to actions like retreat and chase. Such a weight depends on several things in the environment. For instance when the enemy is invulnerable the bot most likely wants to retreat. When a weight is higher than a certain threshold the bot will enter the appropriate AI leaf for the specific action. The Omicron bot uses functions to attach weights to certain actions. The function itself is based on situation sketches and experimental values.

Weapons

During battle the bot has to choose the best weapon to shoot with at the enemy. To choose the best weapon the bot evaluates all available weapons in Quake. For this evaluation each weapon gets a weight in the range [0, 1] depending on the current situation. This weight represents how much the bot wants to use the weapon. The bot will use the weapon with the highest weight. The weight of a weapon is calculated using a function which is partly based on situation sketches and experimental values. The weight also depends on the availability of the weapon. When the bot hasn't got the weapon or ammunition for it, the weapon will get the lowest possible weight. The weapon characteristics are also taken into account. Each weapon has it's own characteristics and will give the best results in certain situations. A weapon for instance has a range at which it's use is most effective.

Nearby goals

When there are items or certain structural systems nearby, the bot checks if they are useful to pick up, use or activate. From the possible nearby goals the bot first chooses the reachable ones. The bot evaluates the reachable items and structural systems and chooses the best one using fuzzy logic. To be able to do this the bot calculates a weight for every item or structural system and chooses that nearby goal with the highest weight. These fuzzy weights depend on the current environment and status of the bot. For instance when there is a reachable health box nearby, the weight will certainly depend on the bot's current health value.

Long term goals
 
Items the bot knows it can travel to, may become long term goals. When there are several possible long term goals, the bot chooses the best one. This is done with fuzzy logic. The bot calculates a weight for every possible long term goal and chooses the goal with the highest weight. The weights are calculated in much the same way as for the nearby goals, except, that the distance the bot must travel towards the goal is also taken into account. The Omicron bot uses the waypoint system to travel towards long term goals. From this system the bot can also retrieve the distance.