Fuzzy Logic for Games

1. Introduction

Since the evident of Fuzzy logic, it has been applied to several applications such as feature detection, control theory, classification, and clustering. Fuzzy logic provides approximation methods for dealing for dealing with information that is approximate. Such information does not have well-defined boundaries. Humans can effectively deal with the information with imprecision and vague boundaries.

Traditionally, such approximate information is dealt with precision, which can be computationally expensive. Fuzzy logic provides mathematical tools for dealing with imprecise information in the manner similar to humans.

While defining AI for computer games it could be better if the linguistic terms are define in a fashion similar to humans. Expert knowledge can be easily transformed in to a machine understandable language [1]. For example, consider a speed of a vehicle, it can be slow, medium, or fast. Suppose if the range or universe of discourse of the vehicle is between 0 to 120 mph, then sets for the speed of vehicle can be define using sets such as:

Slow = {0, 1, 2, …, 40}
Medium = {41, 42, …, 80}
Fast = {81, 82, …, 120}

One way of graphically displaying these crisp sets is by considering membership of an element as 1 if an element belongs to a set and 0 otherwise. Figure 1 shows the representation of these crisp sets.

Crisp Set

Figure 1. Example of classical Set

It is obvious that speed of 90 or above can be considered as fast, and speed lower than 30 is slow. According to sets in figure 1, if we consider the borders someone driving at speed of 80 will be considered as driving with medium speed, and 81 will be considered driving fast. Moreover, different experts might now even agree with this numbers. It will be even difficulty to define rules with the hard boundaries. Fuzzy sets allow different elements with varying degree of membership, and fuzzy rules can be defined using these sets for decision making. Fuzzy system allows the translation of vague terms such as distance, and speed into in to system inputs and outputs [2].
In rest of the paper, we present an overview of fuzzy system demonstrating its application to game AI.

2. Fuzzy Sets

In classical set theory, an object is an element of a set or it is not. Fuzzy sets allow every object to be an element of a set, but with varying degree of membership. Consider a fuzzy set Speed in figure 2, speed of 81 can belong to both the sets Medium and Fast, but it belongs to the set Medium with membership 0.3 and Fast with membership 0.7. Speed of 81 is considered more to be fast then it can be considered medium. While speed of 5 will have definite membership value 1 in set Slow, and membership value 0 in Medium and Fast, meaning speed of 5 is definitely slow, and cannot be considered either Medium or Fast.

Fuzzy Set

Figure 2. Example of Fuzzy Set

Let U be a classical universal set, called universe of discourse. A fuzzy set A is described by a membership function μA(x) mapping every element of U to the unit interval [0 1].

A = {(x, μA(x)) | x ∈ U, μA(x) ∈ [0, 1]}

Core of the fuzzy sets are the membership function. Membership functions can be defined in multiple manners. Various types of membership functions are triangular, trapezoid, and s-curve.

Again consider sets representing seed of a vehicle. Figure 2 graphically represents fuzzy sets Slow, Medium, and Fast represented by left shoulder, trapezoid, and right shoulder membership functions respectively.

3. Fuzzy Linguistic Variable

A fuzzy linguistic variable is a collection of fuzzy set which represents a similar concept. For example, fuzzy sets Slow, Medium, and Fast represents linguistic variable Speed.

 Speed = {Slow, Medium, Fast}

This is more intuitive representation for a human. The information, such as speed of vehicle is slow, is efficiently encoded in digital form. Consider a fuzzy linguistic variable Distance with universe range from 0 to 500 which signifies distance from a target. Distance encapsulates fuzzy sets Far, Medium, Close. Figure 4 shows the membership function of fuzzy sets in the linguistic variable Distance.

Fuzzy Set Distance

Figure 4. Fuzzy Linguistic Variable Distance

It would be easy for a knowledge engineer to specify distance with fuzzy sets, such as Distance is Close, compared to specifying distance in units, such as Distance is 10 KM. It would be even easier to specify rules using such data structures.

4. Fuzzy Rules

Fuzzy rules are set of if-then rules with antecedents and consequents as fuzzy sets in fuzzy linguistic variable.
IF antecedent THEN consequent

Consider a scene where we need to control the speed of a boat trying to reach the target location. Above mentioned linguistic variables, Speed and Distance, can be used to define rules which will control the speed of a boat. Such rules can be defined as following:

Rule 1: IF Distance is Near THEN Speed Slow
Rule 2: IF Distance is Medium THEN Speed Medium
Rule 3: IF Distance is Far THEN Speed Fast

In the same manner rules with multiple antecedents and multiple consequent can be defined. We can determine the speed that needs to be set given the distance of the boat from the target.

5. Fuzzy Rule Inference

Fuzzy rule inference is a three step process:

  1. Fuzzification: determining the membership value of the crisp input in the different fuzzy sets of linguistic variable
  2. Fuzzy rules: apply fuzzy rules to the fuzzified input in order to determine the fuzzy output.
  3. Defuzzification: usually fuzzy output is converted back to a crisp value, especially for game, to be used in the application

Consider the example of controlling the speed of a boat. Suppose that current distance of boat is about 25 miles from target. Figure 4 shows the fuzzification of the input (25). Values 25 belong to Near and Medium fuzzy set with membership 0.8 and 0.2 respectively. Although not shown in the figure 5, values 25 also belong to fuzzy set Far, but with membership value 0.

Next step is to apply all the fuzzy rules. For each rule determine the confident in the consequent of the rule based on antecedent of the rules. In our example there is only one antecedent, therefore the confidence if the membership value of the input. For rule 1 with antecedent Near confidence for the input will 0.8 for Speed Slow. Similarly, for rule 2 confidences in Medium is 0.2, and 0.0 for Far in rule 3.

Fuzzy Rules Inference Example

Figure 4. Fuzzy rule inference


Figure 5. Defuzzification

Based on the level of confidence each consequent is clipped and then combined in to a single fuzzy set as shown in figure 5. Finally, the output fuzzy set is defuzzified for getting the crisp value. A standard method for defuzzification is to calculate the center of gravity of the output fuzzy set. As shown in figure 5, this would yield the speed of a boat which is approximately 20 mph.

Even if there is more than one antecedent we still follow the same process, except after fuzzification in order to determine the level of confidence we take into consideration the operator between the antecedents. If there is an AND operator between the antecedents then minimum of the membership value is taken as level of confidence, or if there it is an OR operator then maximum of all the membership value if taken as level of confidence.

Other examples of the fuzzy logic usage in games can be found in [1] and [3].

7. Conclusion

Fuzzy Logic provides a flexible and powerful tool for handling and processing approximate information. Fuzzy system model reduces the time and effort of game programmers require for configuring crisp values. Also, the number of rules needed in a game for decision making can be significantly reduced using a fuzzy system.

Future work should include incorporating fuzzy rules with an expert system. Expert systems are widely used in industries for simplifying complex decision making processes. A fuzzy expert system can give more power of expression to experts and can handle different form of inputs from different experts.

8. References

[1] M. Buckland. Programming game AI by example, Wordware Publishing, Inc., 2005, pp. 415-456
[2] Adnan Shaout , Brady King , Luke Reisner . Real-Time Game Design of Pac-Man Using Fuzzy Logic. The International Arab Journal of Information Technology (IAJIT), 2005.
[3] Ian Millington, and John Funge. Artificial Intelligence for Games, Second Edition. Elsevier Inc . pp. 371-395 2009.

Note: Extracted from CS 487 Fall 2011 class presentation report. 

Neural Network for Exploration Map of Illinois Coal Deposit

Finding and developing the new source of minerals with precise characteristics such as location, depth, quality, thickness, shape, etc. is required by National Institute for Occupational Safety and Health (NIOSH) to establish a new site for mining operation. Exploration is one of the risky and costly investments for the companies. Driving bore hole and running expensive test with a blind guess is one of the concerns for the all companies. In this paper, a new method for choosing a scientific map for exploration rather than an arbitrary map was introduced. The aim of this project is to demonstrate the effectiveness of SOM application in visual exploration of physical geography data The Self-Organizing Map (SOM), as one of the most applicable models of neural network, is selected for the simulation. SOM provides a data visualization technique which helps to understand high dimensional data by reducing the dimensions of data to a map. The algorithm is based on unsupervised learning. In the present project, Java programming codes is used to simulate the SOM algorithm. For the case study Illinois state geology coal map distribution were considered.

Read: ECE-572_Paper_080311

Fuzzy Social Networks

“In social science, the structural approach that is based on the study of interaction among social actors is called social network analysis” (Freeman, 2004). Social network analysts study the structure formed by the nodes (people or group) connected by the links (relationships or flow). Traditionally, researchers in this field study such structures constructed by the society of humans, or animals such as ants, bees, or apes.  They discover various patterns and examine their effects on those societies (Krebs, 2000). Social network analysis caters its contribution in economics, biology, chemistry, social psychology, information science, geography, and sociolinguistics. More recently due to growth of the Internet, social network analysis is spanning its roots in the study of the World Wide Web (WWW), email communications, computer networks, online marketing, and spread of viruses. (read more)

Video Game Genres

Video games can be categorized in to different genres. It is very common that a single game be categorized into one or more genres; also, several genres overlap each other. Video games has substantially evolved in time and so have their genres. This articles lists several prevalent genres are listed here.


Adventure games include saga, quest, story, and hero. They can be a text-based or with extensive graphics. Other elements of these games include puzzle solving and interaction with others.


These are superset of fast paced real-time games often involve combat and other forms of movement. The sub-genres of the action games are platform, fighting, and shooter games.


A platform game consist of main character running, jumping, climbing, etc. on a platform or obstacles. Platform games sometimes include elements from other game genres such as fighting and shooting. Popular platform games includes Super Mario Bors., Sonic the Hedgehog, Wonderboy, and Donkey Kong.


Fighting games involved one to one combat between two characters. One of the characters can be a computer players. Games like Sega’s Heavyweight Boxing, and Street Fighter II can be characterized as fighting games. Games usually involve fighting with martial arts, swordplay, and boxing.


One of the most popular genre, Shooter games, involves fighting with weapons such as guns and missiles. Shooter games can be dived into two sub-genres: First-person Shooter (FPS), and Third-Person Shooter (TPS or 3PS).

First-person Shooter

You play a character in first-person shooter games. Players emphasize on shooting and aiming accurately. Players are usually behind the eye of the main character giving the players a feeling of ‘being there’ in the moment of the game. These are usually fast-paced game, with high thrill and difficulty levels. There is a long list of games in this genre: Team Forstress, Helo, Killzone, Metroid, Unreal Tournament, Call of Duty, Half-life, and (my personal favorite) Counter-Strike.

Third-Person Shooter

Players shoot and combat from a camera perspective. This gives players a better view of the world, since player is seen at a distance in the screen.


Action-adventure games combine elements of action and adventure games. There is some long term goals involved in an adventure games, with obstacles on the path which involve elements of action games.

Real time Strategy (RTS)

RTS games are continuous play games which requires players to collect resources and control things. Usually, the players are god-like and control theirs units and compete with opponents for land and resources. Games in RTS genre include Age of Empires, Sid Meier’s Civilizations, and Caesar.


Players play in turns. Examples of turn based games are Chess and Checkers. Several RTS games are also turn-based.

Role-Playing Games (RPG)

In role playing games, players plays roles of various characters in a virtual world. Players explores more than one areas of the environment advancing in the game play. A classic role playing game is Dungeons and Dragons.

Massively Multi-player Online(MMO)

As the name suggest this is a genre of games which involve thousands of players simultaneously playing an online game.


These games focus on precession, and sneaky action to goals. These games can be coupled with FPS, Role Playing, and other genres of games. Contrary to these genres, stealth games requires more focused actions and accuracy in achieving goals. Hitman series are one of the most popular stealth genre games.

Survival Horror

These are action games with horror elements. Logic similar to horror movies in applies in games.


Simulating a system such as physical systems, physics, economics simulation, military, vehicular simulator, goad games, government policies, politics, sports and racing. These games are designed to make simulation as close to real world as possible.


These are the classic racing games involves variety of vehicles such as cars, plan, go-carts, etc.

Rhythm or Music Games

Players are requires to move or synchronize their action with a rhythm or music. Goal of such games in to make players move or exercise.

Serious Games

These type of games are designed for serious purpose such as training, education health or simulation of a real world occurrence.

Classic or Traditional Games

Various traditional games such as card games, board game or gambling games are included in this genre.


Various puzzle games, include crossword, Tetris, and Soduku, involves .logic and strategy in playing.

Casual Games

Games in this genre is targated at mas audiences, are are easy to learn. Games usually have short burst of time doesn’t require large commitment. These games are often associated with mobile device.


These games are designed specifically for educating children or adults, with fun involved in learnings.

Fuzzy Hedges

When talking in natural language, it is usual to emphasis or weaken the impact the sentence with words such as, very, little, etc. For example, John is very tall. The similar concept is usual for fuzzy sets, called fuzzy hedges, is applied on membership function of a fuzzy set.

Most commonly used fuzzy hedges are:








Fuzzy Computation

The core of the fuzzy logic is the computational backbone of the fuzzy arithmetic. Power of the fuzzy logic is due to the strong principles governing the computation of the fuzzy sets. In this note we present fundamental computational rules of fuzzy logic.

Fuzzy Set

Given a universal set X, a fuzzy set A is described by a membership function mapping for every element of X to the unit interval [0 1]:

In general, a fuzzy set is expressed as a pair {x, µA}, where x is an element of universal set X and µA is its degree of membership in set A.

Other convenient notation of fuzzy set is

Basic Definitions of Fuzzy Set

Fuzzy Relation

An n-ary fuzzy relation  consist of set of ordered pairs of elements (x1, x2,…, xn) of the universal product set (X1 × X2 ×…×Xn) with its degree of membership  µR(x1, x2,…, xn).


The height of fuzzy set A is the supremum (maximum) of the membership function µA

For a fuzzy relation R,

Normal Fuzzy Set

If hgt(A) = 1, then fuzzy set A is normal;

Sub Normal Fuzzy Set

if hgt(A) < 1, then fuzzy set A is subnormal.


Normalization if process of converting a subnormal fuzzy set in to a normal fuzzy set.


The core of a fuzzy set A is the crisp set of all the elements with membership degree equal to 1.

For fuzzy relation R,


The support of a fuzzy set A is the crisp set of all the elements with membership degree greater than zero.

For fuzzy relation R,


The alpha cut of a fuzzy set A is the crisp set of all the elements with membership degree greater than or equal to a threshold .


is the strong α-cut of fuzzy set A. Similarly, α-cuts for a fuzzy relation R can be defined.

Figure 1. Height, core, support, and α-cut

work in progress.

Social Networks

“In social science, the structural approach that is based on the study of interaction among social actors is called social network analysis” (Freeman, 2004). Social network analysts study the structure formed by the nodes (people or group) connected by the links (relationships or flow). Traditionally, researchers in this field study such structures constructed by the society of humans, or animals such as ants, bees, or apes.  They discover various patterns and examine their effects on those societies (Krebs, 2000). Social network analysis caters its contribution in economics, biology, chemistry, social psychology, information science, geography, and sociolinguistics. More recently due to growth of the Internet, social network analysis is spanning its roots in the study of the World Wide Web (WWW), email communications, computer networks, online marketing, and spread of viruses. This article provides overview of the interesting finding of this wonderful field of social networks. Note that research conducted is different from the research being done on development of social networking website such as Facebook, MySpace, etc., though analyses of social networking websites is a subfield in social network analyses.

Michele H. Jackson suggested the network analysis as a methodology to examine the WWW. He represented the WWW using the network analysis terms, such as actors, relation, network, and networks structures, suggesting that social network analysis is applicable to the network of the hyperlinks (Jackson, 1997). Han Woo Park summarizes various research related to hyperlink network analysis (HNA), and presents HNA as an emerging methodology (Park, 2003). Park’s paper implied that the use of social network analyses for analyzing the WWW is still in its primary stages and has many mysteries to reveal.

Although, the social analysis of the WWW is an emerging field it has already unveiled various interesting WWW’s phenomenon, several of them are listed by Barabási in his book “Linked: The New Science of Networks”. According to him, “Networks are present everywhere. All we need is an eye for them” (Barabási, 2003). He represents the WWW as a social network as opposed to the static web of sites. The network from by the websites is not different than other naturally formed networks such as human network or other biologically formed networks. He discusses several studies which reveal that most networks, small or large, natural or artificial, all exhibit a similar topology and properties. For instance, 90% of the documents of the web have 10 or fewer links, while the small numbers of pages are referenced by millions. He called these small numbers of pages as the hubs which keeps the network connected. Similar hubs found in network formed by food chain, chemical reactions, or airports. The WWW also observes the 80/20 rule, wherein “80 percent of links on the Web points to only 15 percent of Webpages” and also, “80 percent of citation go to only 38 percent of scientist” (Barabási, 2003). This property of the web is described as obeying the Power Law[1]. Existence of the power law distribution implies that small events (pages with fewer links) coexist with the larger events (pages with plenty of links), and hence generate an ever decreasing curve.

According to Gonzalez-Bailon, “(Hyper) links play a twofold role on the web: they open the channels through which users access information, and they determine the centrality of sites and their visibility” (Gonzalez-Bailon, 2009).  Gonzalez-Bailon characterizes the hyperlinks as the virtual medium through which information flows. Users navigate the WWW through these hyperlinks from webpage to webpage, and assimilating the information they need. But, these hyperlink networks are inherently biased and aid certain websites to become central and more visible compared to the others. Power law distribution gives rise to the occurrence called “rich-get-richer”.  As the small number of the websites has received a very high percent of hyperlinks, these websites become the “gravity centers” and have tendency to attract even more links. Moreover, search engines consider the number of hyperlinks pointing to a webpage as a key criterion in determining the rank of the webpage. Therefore, the search engines further aid in this mechanism, since people have tendency to reference top results and ignoring the rest (Gonzalez-Bailon, 2009). Barabási articulates that “rich-get-richer” is governed by two laws: growth and preferential attachments. The network starts from a nucleus and grows by the addition of new nodes, and these new nodes prefer the nodes with more number of links for linking themselves (Barabási, 2003).



Barabási, A.-L. (2003). Linked: The New Science of Networks . Perseus Publishing.

Brunelli, M., & Fedrizzi, M. (2009). A Fuzzy Approach to Social Network Analysis. 2009 International Conference on Advances in Social Network Analysis and Mining, (pp. 225-230).

Freeman, L. C. (2004). The Development Of Social Network Analysis: A Study in the Sociology of Science. BookSurge, LLC.

Gonzalez-Bailon, S. (2009). Opening the black box of link formation: Social factors underlying the structure of the web. Social Networks, 31.4, 271–280.

Jackson, M. H. (1997). Assessing the Structure of Communication on the World Wide Web. Journal of Computer-Mediated Communication, 3(1).

Krebs, V. (2000). The Social Life of Routers: Applying Knowledge of Human Networks to the Design of Computer Networks. Internet Protocol Journal, 3(4), 14-25.

Park, H. W. (2003). Hyperlink network analysis: A new method for the study of social structure on the web. Connections, 25, 49-61.

Zadeh, L. A. (1965). Fuzzy sets. Information and Control, 8(3), 338-353.

Zadeh, L. A. (1999). From computing with numbers to computing with words. From manipulation of measurements to manipulation of perceptions. IEEE Transactions on Circuits and Systems Part I: Fundamental Theory and Applications, 45(1), 105-119.


[1] Power law is a mathematical relationship between two quantities wherein frequency of one object varies as power of other.


Games and A.I.

We want to review the level of AI used in few video games.  It turns out that the majority of AI is scripted or hardcoded in logic with few academic A.I. techniques being used. There is great opportunity in the area for designing algorithms for video game industry.

1. Age of Empires

Age of Empires is a real-time strategy game. In Age of Empires a player builds kingdoms and armies with a goal to survive through ages, defend his own kingdom and conquer other kingdoms. A player starts with few workers and his/her primary building and then slowly builds a complete town and many buildings.

AI of Age of Empires is smart enough to find and revisit other kingdoms and their buildings, i.e.  pathfinding, and also start attacking them. One of the major drawbacks with this game is that AI is too predictable. A player can easily predict the path of AI which tends to repeat the same path repeatedly giving human players an edge. Also, AI is very poor when it comes to self-defense.

2. Half-life and Counter-Strike

Half-life is a science fiction first-person shooter game (FPS). Half-life takes shooter games to the next level of intelligent behavior of enemy monsters and won 35 ‘game of the year’ awards in 2004. Half-life is a more or less traditional game in which a player advances by killing creatures coming in his way. Monsters in this game can hear, see and track human players. Along with this they can also flee when they are getting defeated and call for help from other monsters to trap a human player.

Counter-strike is yet another team-based FPS which runs on the Half-life game engine. Unlike Half-life Counter-strike is a team based game with two teams, namely terrorist and counter-terrorist. The terrorist aims to plant the bomb while counter-terrorist aims to stop them from planting the bomb and killing all of them.

Counter-strike uses bots to simulate human players in teams to give the illusion of playing against actual game players. Bots actually show intelligent behavior in pathfinding, attacking opponents, fleeing away, planting and defusing bombs. Again, they also incorporate the problem of predictability. An experienced game player will be able to predict their behavior and wait for them at strategic locations to kill them. Partly, the reason for this behavior is that the majority of AI in bots is implemented using static finite-state machines (FSM).

3 Creature

Creature is artificial life programs. Software comes with six eggs, each with unique creatures in them. The game starts when an egg hatches and norms come out. Norms learn by interacting with the environment and a player watches them grow through interactions. A Norm passes through adolescence and adulthood and then eventually lays eggs. A player builds colonies of such creatures.

Being first in its kind this is the first real use of artificial techniques in video games. It uses machine learning, namely neural network as the learning algorithm for norms.

Coordination Games

Coordination game

Coordination is required in every aspect of day to day activities.  It can be coordination between husband and wife, for research activities, in politics and economics, or it can be for a choice of a computer technologies. All the players advantage by coordination.  For example, a situation of choosing sides on the road while driving. Consider the encounter of two vehicles on a narrow dirt road. Both drivers will successfully pass each other if they both choose different sides on the road; failure to do so will lead to an accident. Figure 1, shows a payoff matrix for such a game wherein each player receives a payoff of 5 for choosing the same side. Therefore, coordination is required for successfully crossing each other, and hence a coordination game is being played between the players.

Player 2
Player 1 Right Left
Left 5,5 0,0
Right 0,0 5,5

Figure 1: Choosing Sides

Technically, a coordination game is a game with multiple pure strategy Nash equilibriums, wherein players are better off selecting the same strategies. Payoff matrix in figure 2 represents the general form of 2 ×2 coordination game for which inequalities: a>c; d>b ,and w>y; z>x  hold. Here, {C, C}, and {D, D} are pure Nash equilibriums.

Player 2
Player 1 C D
C a, w b, x
D c, y d, z

Figure 2: Coordination game

Example of Coordination Game

Battle of the sexes is one of the most discussed coordination game. The story is about a couple trying to determine whether to go for a romantic or an action movie. General notion is that man would prefer going to an action movie, while female would prefer going to a romantic movie. Couple would still prefer going to the same movie rather than going to a different movie and spending time alone. Figure 3 shows a payoff matrix for Battle of sexes, where husband choose rows and wife choose columns. There are two pure strategy Nash equilibriums wherein both chooses a same place for going. The game represents an interesting scenario; one of the players consistently performs better than other.

Wife R A
R 3, 1 0,0
S 0,0 3, 1

Figure 3: Battle of sexes

Stag hunt, a coordination game, symbolizes conflict between individual satisfaction and social cooperation. Two hunters have decision to make, whether to hunt a stag or a hare. Hunting a hare is relatively easy, which makes a tasty but less satisfying meal. On the other hand, hunting a stag is difficult and requires coordination between hunters. Stag makes a large mean and is beneficial for the society on the whole, but requires its member to coordinate.  Figure 4 shows the payoff matrix for the stag hunt game. Again, there are two pure strategy Nash equilibriums in this game. General form of the game, based on figure 2, can be represented by inequalities a > c ≥ d > b and w > x ≥ z > y.

Player 1
Player 2 Stag Hare
Stag 4,4 0, 2
Hare 2, 0 1, 1

Figure 4: Stag Hunt

Finally, a pure coordination game is similar to the game of choosing sides. Again consider a couple trying to decide whether to go out for party or to stay home. Figure 5 shows a payoff matrix for such a game. There are two Nash equilibriums in the game, but both the payers prefer a single equilibrium over other i.e. {Party, Party}.  Such a game where a single equilibrium is preferred by all the players is called pure coordination game. With reference to figure 1, general form of the game is: a>d>b; a>d>c ,and w>z>y; w>z>x

Player 2
Player 1 Party Home
Party 15,15 0,0
Right 0,0 5,5

Figure 5: Pure Coordination game