top of page

This is a collection of Game AIs that I have implemented  using Unity Engine

Pursuit and Evade

Pursuit is a process in which the pursuer wants to catch the target not merely follow it. Evade is the opposite of pursuit. In evade the actor flees the anticipated target position.  

Obstacle Avoidance

Obstacle avoidance is a technique to avoid obstacles by generating a steering force to dodge obstacles every time one is close enough to block the path of the actor.

It is based on the two forces: 1. Lateral steering 2. Breaking 

Also the urgency for lateral steering is linear where as for breaking a quadratic urgency is used. 

Flocking

Flocking has three major components:

  1. Cohesion: Boids try to fly towards the center of mass of neighboring boids

  2. Separation: Boids try to keep a small distance away from other neighboring  boids

  3. Alignment: Boids try to match velocity with neighboring boids

The result of combining all these forces gives us the flocking behavior. 

Path Finding

This has the A* path finding algorithm with straight Manhattan distance implemented. It uses a priority queue for maintaining an open and a closed list of nodes. 

Path Following

This uses the A* path finding on 10 actors at a time and keeps them moving about the grid. It also has different areas with different weights on the grid, so the algorithm chooses the best possible route. 

State Machines

The objectives in this project are:

  1. To collect all the keys(if possible).

  2. Open the doors if you have the correct keys.

  3. If you have opened all the doors, then collect treasure if possible.

The logic is controlled with the help of a finite state machine.

Behavior Trees

The objectives in this project are:

  1. To collect all the keys(if possible).

  2. Open the doors if you have the correct keys.

  3. If you have opened all the doors, then collect treasure if possible.

The logic is controlled with the help of a behavior tree instead of a finite state machine.

Group Logic

The objectives in this project are:

  1. To collect all the keys(if possible).

  2. Open the doors if you have the correct keys.

  3. If you have opened all the doors, then collect treasure if possible.

The logic is controlled with the help of a finite state machine.

The twist here is instead of a single actor now there are two actors and they try to achieve all the three objectives in shortest possible time by cooperating with one another to complete their tasks. 

Minimax Algorithm

The min-max algorithm is used to develop AI for a 6x6 tic-tac-toe game. A depth of 5 is used in the implementation. Alpha-beta pruning is also used to minimize the thinking time of the AI. The end goal is to have most number of points by filling the board appropriately with 'X' or 'O'.

Genetic Algorithm

Genetic algorithm is used to improve the population of given tanks to collect mines more efficiently. The genome is made up of commands to left and right treads of the tank. After each round the genetic algorithm runs and improves the population to achieve a better score. The position of the mines remains the same throughout all the rounds. 

Neural Networks

The commands to the tanks are now generated using a neural network containing two hidden layers, an input layer and an output layer.

After each round the genetic algorithm is run on the weights of each neural network of each tank to get a better score in next round.

The Neural network has two inputs:

  1. Relative heading to the nearest mine

  2. Distance to the nearest mine

It has two outputs for left and right treads respectively. 

The mine positions are randomized at start of each round.

TanH is used as the activation function. 

Boid Killer

This project is a combination of pursuit,evade,flocking and obstacle avoidance to create a fun game.

Please reload

bottom of page