Monday, 23 November 2015

Data Science, Mobile Gaming and Incomplete Data

Data Science is currently an integral part of the game design covering its whole lifecycle. Game designers and producers need insights into player behaviour, and this information is used from the earliest sketches of the game all the way to the soft launch and real launch. After the launch data analysis plays even more important role in marketing and possible adjustment of game features. Of course, all these analysis results will be used while designing new games.

Record everything

In order to acquire all that insight into the game, we need data scientists to pinpoint all actions and events in game that needs to be recorded in databases. This has to be carefully planned according to the needs of later analysis. That is why data scientist has to participate actively in all game design and development from the beginning of the project.

Basically any choice player makes should be recorded, and all UI actions. Depending on the type of game it may be relevant to record some events or actions in game environment to give context for player actions - e.g. how fast player reacts to certain event.

There are several aspects of data that should be recorded - not just player data, game scores, purchases or game events. One important aspect is all such data that is used to evaluate UX, since it can be used to iron out any wrinkles that affect a smooth gaming experience. Bad UX can ruin an otherwise good game. There are other types of data too, but that is a topic of another post, later.

Unreliable internet

There is one thing that you have to consider carefully when implanting these "recording hooks". All this data is collected through internet, and your players may use any kind of internet connection. They may be using old and slow devices, also. This means that you have no guarantee that all data packages from player's device ever reach your backend databases, if they are sent at all. It is safe to assume, that at least certain percentage of data packages are lost during transmission.

Biggest reasons for missing or corrupted data packages are
- 2G/3G/4G mobile connections
- Old and unreliable wired connections
- Heavy traffic
- Computer or mobile device which is clearly under minimum specification needed.
Last of those items above is something which happens usually with Android-games. People install them on old devices which do not have enough memory or processing power. Game starts to choke up in graphics intensive scenes, and then some data package transmission are dropped.

Actually this problem appears not only in games, but in any kind of application that uses internet for data communications. In some cases you can solve this with two-way communication, where every data package has to be acknowledged as received, otherwise it will be resent etc. However, this makes communication system more complex and will increase the load on both server and client. Anyway, there is no perfect solution.

So you should build your recording events in such manner, that you can reconstruct at least the most important events with the help of other recorded events - if it happens that data is incomplete. I have encountered these situations myself, and with careful planning it can diminish the problem significantly.

Where did players go?

As an example, I had a case where a small group of players did not seem to be playing at all in a sense that they had no recorded scores. This aroused my curiosity and I wanted to see what they were doing and maybe understand why this happened. Fortunately I had implanted all kinds of game events with data recording hooks, and I had plenty of data to base my analysis.

I quickly found out, that actually most of these non-scoring players were actually playing. I could easily reconstruct this based on fact that there were recorded events of game progress, although the game end and score records were missing. Of course it is always possible that they quit the game before game end.

It was clear that some of them had been playing, but it was not clear how much. So, I continued to dig deeper, and found out that part of these players must have played at least one, perhaps more games through because they had achieved certain bonuses, which player gains only by playing the game to the end.

All this work was worthwhile. Of this non-scoring group only less than 2% were left totally unexplained, 5% clearly showed no signs of play. 23% showed signs of play progress, but it was not clear how far they had actually progressed. Rest of them (70%) could be reconstructed with reliable number of game sessions. Based on these findings I could update automatic database queries for data analysis algorithms to get correct statistics.

Data is always incomplete

I have worked for almost a decade analysing medical and bioscience data and designing data acquisition and storage systems for those fields of scientific research. In those fields you have to accept the fact that data is always incomplete. Due to human related issues, you are always missing some parts of data on many individuals. It is quite easy to believe that in games you could get accurate and complete data on all player actions, since everything happens within the computer. But it just does not happen that way.

Lesson you can learn from the incident described above is, that in computer and mobile games you really should record player events and actions as much as possible in all reasonable points of game flow. Since data acquisition is quite unreliable (for reasons mentioned above), you can never know what bits of data you need to reconstruct the missing events. In such situation you may be able to turn most of those questionable cases into real evidence.

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.