This document contains editing information for the Q3A bot.
The Q3A bot is an artificial player for the computer game Quake III Arena.

Author:

Mr Elusive

Last update:

2000-01-04

Copyright 2000 id Software, Inc.

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 its 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 and 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
criterion. In practice functions are 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.

Bot and fuzzy logic

The bot uses fuzzy relations to specify how much the bot wants to do, have or
use something. For instance a value is attached to how much the bot wants to have a certain
item. The 'fuzzy relation' is based on the current situation and environment of the bot. The
situation and environment are represented by a set of variables.

The fuzzy relations which the bot uses are stored using a tree-like structures. The leaves
of this tree store fuzzy values. A node in the tree can link to either a leaf or one of the
nodes on the next level of the tree. Linking to another node is based on one of the criteria
of the fuzzy relation.

The fuzzy relations are stored in plain text using a C-like syntax.
Here is an example of a fuzzy relation:

First of all every fuzzy relation (called a weight) has a name. Different fuzzy relations
are identified by their name.
C-like switch statements represent the nodes of the tree-like structure.
The switch statement selects one of the criteria of the fuzzy relation. The case keywords
divide the value range of the criterion into several chunks. A division of the value range
is made at the value that appears after the case keyword. The number of case keywords
determines the number of divisions. A case statement 'links' to a node or leaf on the next
level of the tree when the value of the criterion is below the value that appears after the
case keyword. A switch always has a 'default' statement. If the value of the criterion is
higher than the value that appears after last case statement then the default keyword links
to the next node or leaf in the tree. A leaf of the tree denoted by the keyword 'return'
stores a fuzzy value.
The criteria used in the fuzzy relations are the inventory item amounts extended with
several other variables. To select one of the criteria an index from the
inv.h file is used.

Evaluation of a fuzzy relation

A fuzzy relation could be evaluated as follows. Evaluate a criterion and go to
the next node or leaf depending on the value of the criterion. When a leaf is reached the
fuzzy value is 'returned'. However this is not the best way to evaluate the fuzzy relation.
Evaluating the fuzzy relation recursively with interpolation between criterion divisions
results in a continuous range of fuzzy values.

Fuzzy relation code pros and cons

pros:

structure is easy to understand

the fuzzy relation can be deduced from situations

the fuzzy relation can be created with logical reasoning

the bot can easily update and write the structure

structure can be used with bot interbreeding schemes

in combination with the recursive evaluation of the fuzzy relation with interpolation
between criterion divisions the structure is suitable to generalize from situations

cons:

pretty much every relation can be expressed but sometimes
the realization takes way to much code

Item weights

The bot uses the item weights to decide what item it wants most. Fuzzy relations
as described above are used for the item weights. Every bot character has it's own
item weights. The fuzzy relations are stored in the file fw_items.c.

Weapon weights

The bot uses the weapon weights to decide what weapon to use during combat. Fuzzy
relations as described above are used for the weapon weights. Every bot character has it's
own weapon weights. The fuzzy relations are stored in the file fw_weap.c.