Tuesday, August 2, 2016

Genetic Learning for Artificial AI makes for better games

Welcome visitor, to the deep recesses of my cranium.
This blog will supplement work done during the final semester of my bachelor degree (Games and Virtual Worlds), and in particular, will describe both the background knowledge and implementation of a GPU-based neural learning system which allows your game agents to adaptively learn how to best defeat each other, as well as real players - reactive AI which bring their game to you, and which can adapt to your strategies in realtime.

The system described can work for basically any game, and a lot of other well-defined problem domains, and does not rely on any expert knowledge of the game or other simulation environment.
This means that it does not matter if your game features spell-casting mages and arrow-shooting elves, or whether you are simulating crowd panic behavior in the case of some emergency scenario, or any other simulation involving intelligent automatons.

Especially, we are not working with State Machine technology, neither FSM nor DSM are relevant to this work - there is no talk of behavior trees (or even defined behaviors), there are no conditions tested, there is no code or script implementing any logic resulting in predefined behavior.

In nature, there are two primary mechanisms which contribute to the process we know as the evolution of species. The first one, which many are familiar with, is called Natural Selection.
Even the religious people who disclaim evolutionary theory (creationists) can agree that Natural Selection does occur, it simply means that living entities which are 'unfit' for any reason are culled by natural processes, resulting in a healthier population. Whether this is caused by God, is a Causal Effect, or something else, is a subject for another blog - what interests me is that we can create software models of life, based on our theoretical understandings, and those models are able to produce conditions beyond their design, which share many similarities to those we so often discover when studying any population of living entities.

 The second mechanism, which is less-celebrated but nonetheless well-known both to the educated and to the ignorant, is called Genetic Mutation... Mainly, we can think of this as the SHUFFLING of a set of cards that the universe hands an individual Living Entity in terms of which of its genes are actually expressed, versus which are dormant - given two parent entities, their child usually resembles them both in some ways - but due to this genetic shuffle, things can change in one generation very quickly. Existing genes - even if they are dormant in the parent creatures, are the most likely to appear - our creatures have a Genotype - they have well-defined characteristics that tend to survive across many generations, which can be used to identify their Species - but they also have a Phenotype, which describes how our creatures actually look and to a lesser extent behave - how the active genes are expressed is a result of the environment that the creature finds itself trying to exist within. It still depends on those genes being present, but not dominantly so.
While natural selection is a Filter mechanism which tends to reduce genetic diversity within a population of Living Entities, genetic mutation is also a mechanism by which the genetic potential of a population may be improved and increased, more than just a reshuffling of the hand you have been dealt.
It can involve environmental factors which actually modify the genetic code, or DNA, of a Living Entity during its lifetime, such that its offspring are genetically equipped to cope with conditions that might not be endured by the offspring of its peers, who lack such genetic diversity.
Triggers for inducing genetic mutation include radiation sources, dietary factors, environmental factors such as prevailing weather conditions and other ambient conditions such as temperature and humidity, in fact the number of things that can cause genetic mutation is huge, and is the reason that life still exists on this planet, of that I am convinced.
It is noteworthy to mention that Genetic Mutation can result in positive, negative, and neutral outcomes: negative phenotypes tend to be culled through Natural Selection and similar processes (such as the ostrasization and ejection of  many such individuals from their population due to their alarming differences), neutral phenotypes represent genes whose expression may occur infrequently or skip some generations, and positive phenotypes represent 'winners' within any given generation - the fittest of the species, with respect to the genetic average.

The study of biology, with respect to genetics, touches on such mathematical topics as Probability and Statistics - effectively, each Living Entity is a Pool of Genetic Potential, and each Genetic Pool is subject to variable conditions - Natural Selection (and a third genetic mechanism, husbandry or artificial selection) and
Genetic Mutation are the main influencing mechanisms but there are others.




No comments:

Post a Comment