Language: C/C++
Library: OpenGL
Description: Demo showcasing how the non playing character supports the main player using artificial intelligence. Red ball is the player and the green ball is the NPC. Player fires at the enemy which is represented using triangles. Depending upon the situation the NPC character shows different behavior.
Couple of artificial algorithm techniques have been used in this project, some of them are:
Fuzzy Logic
Naive Bayes classifier
Simplified decision tree
Emotional modelling.
Observation is done to see, how the non playing characters are trained with a set of data, and then how they use these training data to get some result according to environment around them.
The game initialises by creating the render screen and calling a function which stores all the training data to be used in Bayes classifier. The training data at present is stored in an array. In the beginning all the entity are at their respective positions.When the player makes a move and starts to fire at the enemy, the non playing character makes a move, according to the probability result it calculates from the conditional set of data’s.
At the same time the enemy uses fuzzy logic to check the range of the player and its present health condition. If the situation demands that enemy should fire, depending upon the result from the fuzzy logic the enemy open fires at the player and the non playing character.The non-playing character is shown using a sphere shape in green colour. It is controlled by Bayes classifier algorithm. It keeps a check on the status of the player and the enemy, also its health and ammunition level.
When non playing character gets a fight order, it moves up and starts firing. At that instant its ammunition number decreases and the collision check is performed to check whether there is any collision with bullet from the enemy.As all the conditional data of the non playing character changes, it is checked with the training data to see whether it’s a new set of conditions or not. If it’s a new condition then probability of the new condition is calculated
Non playing character supports the player within that area where there is a fight and does not move forward beyond the obstacle mark. The non playing character movement is restricted to a certain range.
Code Snippets:
BayesClassifier.h
BayesClassifier.cpp