Simple Life – AI Techniques

An ecosystem simulator making use of multiple AI techniques to emulate complex behaviour and interactions.

The project

This project was a university assignment to build a game using advanced AI techniques. For the type of game I wanted to make (an ecosystem simulator), I opted to implement Fuzzy Logic, Genetic Algorithms. I also needed to add a more simple technique called FSM (Finite State Machine) to showcase the decision making of the lifeforms.

I chose the Unity game engine to build the game due to previous experience and it has all the tools and components that I need for development. 

Implementation

Further depth into what the project/program is capable of. i.e. What algorithms it uses and how it programmatically functions. 

A large part of the game is the randomisation and inheritance of genetics in each lifeform. Genetics are mostly inherited by the parents and less so by the grand-parents of the lifeform, but each gene can undergo a mutation to introduce variety. The mutation can affect the gene positively or negatively, and can be influenced by the actions of the parents.  (Gene mutation code below).

For example the Athleticism gene governs the speed of the lifeform and is trained through active movement. This leads to a higher likelihood of a positive mutation for the next generation. I created my Genetic Algorithm, using the knowledge I gained through the Introduction to Optimization with Genetic Algorithm by Ahmed gad. 

Instead of taking in specific inputs in conditional statements to determine actions, fuzzy logic is a method of comparing and combining multiple parameters, each with a range of possible values to determine a final action. I mapped each parameter to a Bezier curve to give it a quantitative value and match it to the context. Such as being more likely to attack if your health is high.

Challenges

The biggest challenge by far was the Genetic Algorithm. It required me to build/setup all of the possible genes, each with their own mutation rates, values, and training rates. I also had a fault with the great complexity as I insisted on using templates, read-only structs and constant values. Slowly but surely I built the algorithm for mutations to take into account the genes of all the parents/grand-parents with different weighting and the training data generated by them. With more training data leading to a positive outcome. 

For The Future

I learnt that I should focus on getting a working prototype first before trying to implement every single feature and consideration when developing. However that doesn’t mean ignoring the architecture and rewriting everything later down the line. I will make notes and keep in mind its purpose and what it should be capable of.

Overall I’m pleased with how the project turned out as it worked quite well with the lifeforms making all sorts of decisions based on their surroundings and their own survival needs.