Showing posts with label game development. Show all posts
Showing posts with label game development. Show all posts

Monday, 27 June 2016

Lifelike Artificial Intelligence in Virtual Reality

Last weekend I started a new Virtual Reality and Artificial Intelligence project. This time I am using cats to model lifelike behavior in a virtual environment of a typical home with typical furniture and other objects. Behavior and AI controlled animations are still very limited, and there is lots of work to be done in those areas.

My goal is the same as in my previous projects - to make an lifelike artificial intelligence module with personalized and unpredictable, but logical behavior which evolves while the subject learns new things and experiences both pleasant and unpleasant events. This is not based on state machines or simple behavior trees. Instead, it is based on my own research in the field of artificial intelligence, and it resembles real cognitive information processing. It has both low level reactive and higher level analytical modules. Thus, it can react quickly when necessary, but otherwise it may analyze the situation and formulate complex plans.

While AI algorithms resolve the actions and emotions of the cat, these resolutions are expressed to the viewer by animating the movement, posture and expressions of the cat. Changes in emotional state are relayed to animation subsystem, which then adjusts head, tail, fur, legs, eyes and mouth in a realistic manner.

This is just a beginning, and many behavior patterns are still missing, as are many animation patterns. But my plan is to have quite soon a believable virtual cat in a virtual reality environment.

Thursday, 26 May 2016

Train to Nowhere

Train to Prostokvashino



Prostokvashino station




Conceptart for an unpublished game

Saturday, 9 April 2016

AI Design for game and simulation environment


I have a long history in AI development, but my goal has always been to design and develop life-like AI. I see classic state machines as semi-AI, not really AI, but as a kind of a control logic. As processing power of computers and mobile devices has increased, it is now possible to program an AI which gives an impression of natural  behaviour, even on mobile platform.




This AI is designed to mimic real, unpredictable behaviour of intelligent, semi-intelligent and non-intelligent beings. It is based on ideas from fuzzy and non-linear systems, which have certain rules and causalities but some degree of randomness, also. It is not totally deterministic, but not totally random, either. It should be emphasised that this is not a state machine.



As designed, this AI develops independent behaviour patterns in a node based associative and constructive memory. Nodes represent concepts, locations, actions and objects using a simple semantic language. Based on experience and training an AI entity will generate these nodes and link them to other nodes. During this process it will evaluate these nodes according to outcome of real events. Thus, it can separate e.g. actions or objects which are harmful, and avoid them in the future, or it can assess them as beneficial.



It is possible to evolve very complex behaviour patterns with deeply linked memory nodes, where low level concepts are combined and constructed into larger concepts. Some of these nodes represent basic instinctive behaviour, but entity will gain more experience or training later on. In any situation, an AI entity will evaluate possible actions according to what objects, entities etc. are present, what kind of environment it is in, what are its present goals, mood, physical and mental condition and physical needs using the concepts it has stored in its memory and whether they lead to beneficial or harmful outcome.



An AI entity can learn and change its behaviour by changing previously evaluated and assessed things and their parameter values. This makes it possible to adapt changing environment and situation, or to learn by training, where another entity gives positive and negative feedback. Basically, an AI entity can learn by trial and error.



Part of this AI is a communication system. An entity can express itself using rudimentary language. Depending on entity this communication may use vocal expressions, visual signals, smell or other senses. Any AI entity is capable to understand its environment - not only objects, but also these signals, and respond accordingly.


This AI framework has modular design and it is possible to customize it for various scenarios where natural, unpredictable behaviour is needed to simulate lifelike entities. In this case it has been adapted to represent dog behaviour, which is interesting since it has to be balanced between strong instinctive behaviour and conditioned training.



Sunday, 22 November 2015

Avoid absurd population growth in a game world

Game designers have a responsibility to make their game world logical and realistic within its own reality. So instead of just making up some numbers that describe the behaviour of entities, you should try to calculate the implications.
As an example of miscalculation I remember an old fantasy strategy simulation game where - according to the rules of system - humanlike population grew 10% every month. My guess is that creators of game thought it as a appropriate number taking in contrast to game turn and general flow of game. And when you play the game and observe only two or three consecutive turns, it may feel OK.

Exponential Growth


From larger perspective this scenario starts to look quite weird. Unless there is a huge death ratio this population will explode in couple of years, because it more than triples in a year, leading to exponential growth. Besides, when it says "grows 10%" my assumption is, that all decreasing effects have already taken into account.
Lets assume that these humanlike creatures have average human life span. If there are no other causes of death but old age, then a 1000 head population will grow in 6 years to approximately 1 000 000. In 10 years there will be almost 100 000 000 population.

Breeding like rabbits


However, when you start to think it deeper, this is absurd from reproduction point of view, also. Assuming that this humanlike population follows human reproduction patterns, we know that there are two sexes and pregnancy lasts 9 months, and humans are not reproductive in their 10 first years of life. For simplicity's sake we assume that male/female distribution is 50/50.
Lets start with that 240 head population. Since system clearly says that population grows 10% every month, it means that there has to be women giving birth every month. Lets assume that one woman is not constantly pregnant, but has 3 month "rest period". This way we can divide the 120 woman population (50% of whole population) into 12 groups, giving birth every month.
When the first group of 10 women gives birth, they have to produce 24 children to reach that 10% growth quota. This means that on the average every woman gets twins (and we know that twins are rare in normal life), but 4 of them (40%) has to get triplets. When months and years go by even twins are not enough, since population has now grown, and those newborns won't produce children for a decade, at least. So, in couple of months those mothers have to give birth to triplets, then quadruplets and so on. Well, they still have that 3 month rest period to gather strength.

Burden to community


Combine reproduction and exponential growth with age distribution and you have a population where large part of the population are little children needing food and care, all mothers are constantly pregnant and men are doing hard time providing sustenance to all of them, which will be harder and harder to find. Actually at the end of the year 3 there will be the original 240 adults and almost 600 2-year old, about 1500 1-year old and about 5000 newborns. In total, for every adult couple there are about 30 children to take care of.
Actually those adults were lucky. There was also a game where population increased by 5% every week. However, I leave those calculations as an exercise to the reader.

Lesson learned


I can only guess the reasons for this absurd growth rate. Maybe it was needed to compensate losses in battle, sickness, famine, child death etc. Maybe it was needed to give players an impression that something is really happening in monthly game turn.
But even then, the wording should be different, like birth rate. Growth means usually net increase (or decrease) and is a sum of newborns adjusted with death figures (battles, sickness, accidents etc.). Anyway, if that 10% were birth rate, it would be absurd.
What should have been done is quite simple. First do some groundwork and calculate a realistic birth rate taking into account the age structure of population, fertility rate, reproduction age, pregnancy time. Then adjust it with death at birth and death of old age figures. Then you could list all possible random causes of death like famine, disease, accident and battles. This gives you equations to estimate how your population could grow and you can simulate what happens if some variable is increased or decrease.
In reality, the annual growth rate of human population on Earth has never been over 2%. Before Middle Ages it was not under 0.2%. Currently this growth rate is declining.

My point is that any game designer should make some calculations and look if his scenario is plausible or totally ridiculous. More importantly those calculations help in game design, because you can simulate various scenarios, especially if it is any kind of strategy or simulation game. Otherwise there will always be at least one nitpicker like me, who will quickly make some calculations and put the results in Internet for everybody's amusement.