Ameya
This is a collection of Game AIs that I have implemented using Unity Engine
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:
-
Cohesion: Boids try to fly towards the center of mass of neighboring boids
-
Separation: Boids try to keep a small distance away from other neighboring boids
-
Alignment: Boids try to match velocity with neighboring boids
The result of combining all these forces gives us the flocking behavior.
Group Logic
The objectives in this project are:
-
To collect all the keys(if possible).
-
Open the doors if you have the correct keys.
-
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:
-
Relative heading to the nearest mine
-
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.