Neural Networks Library

Description

Final personal project developed in Teesside University. It is a neural network library in C++. To demonstrate the functionality of the library, it has been done an AI in a Simple RTS using that library adapted to Unreal Engine 4.

The library has all the utilities to implement a multilayer perceptron easily. It has been implemented some neural networks in the AI, one main neural network and one for each state: Attack and Wait (the state move, does not have any neural network, the troops will just move to a random position). After few seconds, the AI will set a new state for each troop and if it is in learning mode, it will check, based on some predefined rules, if the actions made previously was good or not. In the case the previous action was beneficial, the neural networks will be updated.

The rules can be modified to set a different AI, for example, making it more defensive or more aggressive. Only a few values need to be changed to modify its behaviour, in the reward function which manages these values.

There are some state machines for the AI. The neural network will decide which state must any troop have, this based on the enemies data.

The main neural network wil decided which state will the troop have. In the case of attacking, the troop will get into the Attack state and the attack neural network will decide which troop to attack, or if it is time to attack the enemies castle.

If the main neural network decides to move, the troop will only move to a random position. If the neural network decides to wait, the wait neural network can set 4 new states:

  •  Wait: The troop will wait at their current position.
  •  Increase group: If there is a free soldier in the battlefield, that soldier will be added to this troop.
  • Request soldier: The troop requests a new soldier from the AI. The AI has a queue request system. If it has enough resources, it will give the requested soldier to the troop.
  • Update formation: All the soldiers in the troop will regroup in a position.

Up to now, the AI is learning with random situations. I know that the best way for this is train the AI playing versus another players, but I didn’t have time to prepare the game and play it.

Features:

  • Multilayer perceptron.
  • Supervised learning.
  • Learning by reinforcement.
 

In the demo,every x seconds, the game will freeze. This is because the AI is on learning mode and the neural networks are being calibrated.

Date: Jan 2019 – May 2019

Tools used:

  • Visual Studio 2017 and 2019
  • Unreal Engine 4
  • Genie
  • Git
  • Bitbucket