BLOG

Notes from the KAYAC hyper-casual team

On A/B Testing in Games

Takashi Hirayama

Hello. I'm Hirayama from the Technology Department.

In this piece I'll discuss A/B testing in games.

You may have guessed from the word "discuss" that this isn't really a blog post. It's published on a blog, but it's far beyond blog-post size: over 35,000 characters (115 KB). I've written at length about A/B testing in games, covering how to run it, its problems, and even its ethical side. The people I most want to read it are my colleagues, but in that situation it's better to publish it outside the company first, so here it is as a blog post.

Since I'm assuming most readers will be people in the same line of work, I haven't tried to make it easier to follow with diagrams and tables.

Who wrote this

Unlike with a normal technical article, here it matters what kind of work the author has done, so I'll cover that first.

I worked as an engineer on arcade games, home console games and social games for phones for about 18 years in total. Then in 2019 I joined the development of ad-monetized casual games (sometimes called hyper-casual), which is where I am now. Until about a year ago, my job was to take over a game after its original creator had built it to some extent, and improve it. The products I worked on include these:

I kept repeating the cycle of thinking "what could I change to get people to play it more?", implementing improvements, and running the A/B tests this article deals with. Some of the improvements were technical, like improving the frame rate, but most were about the game's content; for Park Master, for example, I also designed some of the stages (levels). The point at which I took them over varied: some I received almost finished and made "further improvements" to, and some I inherited when they were still close to prototypes.

After that I moved on to making games of my own, and the two that reached worldwide release are these:

With these too, the work after the prototype was the same: improvement through A/B tests.

So although I say "A/B testing in games," my hands-on experience is only with ad-monetized casual games. As for how to run A/B tests in console games or social games, I can imagine, but I have no experience.

Also, very few of these products have in-app purchases, so I don't know much about those either. I do have a little experience, though, so some of that comes up too.

Before the technical problems

In the world of medicine there is something called the clinical trial.

It's the procedure for checking whether a new drug or treatment really works. For a drug, patients are randomly assigned to a group that takes the drug and a group that doesn't, and if a "scientific procedure" shows that the group that took it is doing better, you're allowed to say "this drug works." It's thanks to this procedure, the clinical trial, that the superstition-ridden world where unproven drugs were widely used came to an end.

The "scientific procedure" part is especially important. Roughly speaking, it means "you can't tell whether doing something changes the result unless you compare it with not doing it," and "keep everything except the new change the same." If someone advertised "I passed my entrance exams with this method," it wouldn't be convincing unless you also checked what would have happened without that method, right? Or when improving a recipe, if you change the cooking time and the temperature at once, you can't tell which one made the difference, so you change just one. That sort of thing.

Now, in a clinical trial you need people who take the drug and people who don't. On top of that, the patients must not know which group they're in. "You don't know whether you yourself are taking the drug" sounds absurd, doesn't it? But strangely, people can summon some mysterious power and get better just by thinking "I'm taking medicine," and frankly, even a pill made of nothing but flour can have a therapeutic effect. So you prepare the real drug and a fake that looks exactly like it (a placebo), so the patients can't tell them apart.

Furthermore, the doctors mustn't know which patients are getting the real drug and which the fake one either. If they know, it can show in how they talk to the patient, and the patient may figure it out. Some might even let it slip on the sly (double-blind method).

So "keeping the other conditions the same" is a considerable undertaking, and that's what a scientific procedure is1. But doesn't something here make you go "hmm"?

First, I said "split people into those who take it and those who don't, without telling them," but is that even allowed?

Whoever made the drug presumably made it thinking "this will cure the illness and make people happy," and it's precisely because animal experiments and so on have given them something like conviction that it works that they move on to trials in people. And yet it's OK to withhold the drug from half of them? In practice it isn't OK, so if the illness already has a drug, the test will be between "the best drug currently known" and "a new drug that may be better," and participants give consent beforehand. Even so, something doesn't sit right.

Objectively, or scientifically speaking, the developer's belief that the drug works may just be an assumption, and however elaborate the reasoning, you won't know until you experiment. And to conclude from the experiment that the drug worked, you need a comparison with people who weren't given it. I think the clinical trial is a truly great procedure that has moved humanity forward.

But all that aside, it still doesn't sit right, does it?

In games, the setup is exactly the same

A/B testing in games, though nowhere near as serious a matter, does roughly the same thing as a clinical trial. When you want to know whether an improvement makes players happier, you split them into those who get the modified game and those who get the unmodified one. Then, if a difference shows up in how they play, you can say "this feature made a difference."

Game developers are only human, after all, and can't escape their own assumptions. Throughout history, it probably hasn't been rare for a feature that never should have gone in to be added on a whim and ruin a game. But when the conditions that make A/B testing possible are in place, you can greatly reduce the risk of that kind of tragedy.

At the same time, it clearly carries the same problem as the drug.

A developer who made an improvement has often done so thinking "this is definitely fun," and it's precisely because of that conviction that they decide to put it in front of players. Yet is it OK to give players the old version, the one they think is less fun?

There may also be cases of "well, I'm not that confident in this improvement," but that's a problem in its own way. "You're putting something you're not confident in in front of players?"

So with A/B testing in games, before any question of method, the attitude of the people shipping things to players is called into question.

The conditions under which A/B testing is possible

Given that the setup is the same as a clinical trial, you can probably already guess some of the conditions under which A/B testing is possible in games.

To start with the conclusion, most games can't do A/B testing. They may be able to do a little, but often not on any large scale.

First, you need to be able to ship updates. Even if an A/B test shows "it's better this way," that's pointless if you can't apply it. I suppose you could apply it to a sequel, but nobody does that, do they? So realistically, it only applies to game development where updates are cheap, which means, almost entirely, phones.

Second, when players are connected to one another, what you can do shrinks drastically. For example, if the game has a feature for communicating over the network, behavior that differs too much between players will stand out in conversation. What if someone says "press the button at the top left," and on the other player's screen, that button is at the bottom right? Even without a communication feature in the game, things may not match up when people talk on Twitter.

And though it isn't a constraint in principle, having lots of players and a small game scope is effectively a requirement. Otherwise you run into trouble with the procedure described later.

So-called "ad-monetized casual games" fit these conditions well, and I suspect they're effectively the first field in which A/B testing became possible for games. I don't know whether anyone did it before that.

An overview of the A/B testing procedure

Let's get into how A/B testing works in practice, using a more concrete example.

Say we're developing a racing game for phones and it's already been released. Currently, the car starts driving as soon as you launch the game, without you pressing anything. But that really is too abrupt, so we figure it would surely be better to show a title screen on launch and start when you tap a START button. So we decide to run an A/B test.

The first thing an A/B test needs is a way to assign players, like "old behavior for some players, new behavior for others." If it can change on every launch, implementation is easy, but that really won't do. You need some way to remember which group a player is in and keep the same behavior after a restart. Also, when a player who already started the game on the old version updates, it's probably best to keep the old behavior for them. Implementing and testing that is no small task. Even for a casual game, if the implementation is too sloppy, something will go wrong sooner or later.

Next, you need to know how the assigned players did. If they were playing right in front of the developer, you'd immediately see things like "it started so suddenly they panicked and crashed the car!", but tests where the developer can watch players directly aren't something you can do often. Looking up player reactions on Twitter only gets you so far, doesn't it? So you need to build data collection into the app, have it send the data to some server, and get it into the developer's hands. You can run the server yourself or use some service. Either way, you need that infrastructure in place.

You also need to decide what data to send. And to decide that, you have to decide how you'll judge which group is better. For example, if you decide "longer play time is better," you'd build code into the app so that each player's device sends their play time to the developer. And of course you'd also send whether the device was assigned to the title-screen group or not. Without that you can't aggregate. You'll be sending something like "the player with ID XXXX is in the title-screen group, and their play time so far is 1300 seconds" to the server at a suitable interval.

Next, you need infrastructure for storing and analyzing the data you receive. Do you run your own server, put the data in a database and write SQL (something like a programming language for processing data) to analyze it, or do you use an existing service that does that for you? There are many options.

Then comes evaluation. The basic idea is to aggregate the data, compute some evaluation metric, and the higher one wins. For that you have to decide what the metric will be, when to aggregate in the first place, how many people you need, and how big a difference in the metric is enough. For example, how about assigning 5 people each to "with title screen" and "without," aggregating the data 3 hours after the update, and declaring the one with the higher average play time the winner? Is 5 people enough to decide? Is 3 hours enough? If those 5 people's average is higher, is that really good enough? Those are the questions to consider. Here, I think it's better to enlist the help of statistics, both as a scientific procedure and for your own peace of mind.

And actually, deciding what to A/B test, and whether to test at all, is also quite important. As we've just seen, A/B testing takes a fair amount of effort. If you A/B tested every single change, development would slow to a crawl. Even for a single button, you could test its color, position, size and so on endlessly if you wanted to. Are you really going to test that? Are you that unsure of your own judgment?

Scientifically speaking, "people are unreliable whether they're confident or not," but we're making games here. Games! It's about the developer laying their aesthetic bare in front of the players and saying "how about that!" (personal opinion). And you're going to ask the players about even that?

This ties in with the ethical problem I wrote about at the start, and there's also the matter of the limits of A/B testing in games. Unless you "have someone play the game with setting A, travel back in time to before they played, and have them play it again with setting B," the people playing are different, so strictly speaking the conditions aren't the same. Numbers can only dilute individual differences so much. Even if you collect data from tens of thousands of people, there's absolutely no guarantee that a result obtained at one point in time holds forever. With a clinical trial you can accept to some extent that "a human body is a human body; they're all much the same," but with games, people's tastes vary endlessly and change over time. There could well be, and in fact probably are, things like "this one's better on weekdays but that one's better on weekends" or "a month ago it was this one, but now it's that one." In other words, you need to understand the limits of A/B testing in games.

To sum up, there are these elements:

  • Assignment
  • Data collection
  • Aggregation
  • Evaluation
  • The validity and cost of the A/B test itself

From here on I'll talk about each of these.

Assignment

Let's start the concrete part with how to assign players. Broadly, there are two options.

  • Do the assignment inside the app
  • Get the assignment from outside the app

The former generates a random number on first launch and assigns based on that. For example, if there are two implementations to switch between, you can decide with a random number that comes out 0 or 1.

The latter has a service such as Unity or Firebase handle the assignment for you via an SDK. For Firebase that's Remote Config, and from Unity it's Remote Settings.

Assigning inside the app

All the products I'm currently involved in assign inside the app. For a while I used Firebase Remote Config, and before that Unity's Remote Settings, but I've since stopped using both.

The nice thing about doing it yourself is that it's simple. You generate a random number on first launch to assign the player, and write the assignment into the save data.

From the second launch on, you read the assignment from the save data and set the behavior accordingly. If the save data is small, synchronous I/O calls are fine, so you don't need to worry about waiting, and the implementation stays simple.

You can tell whether it's the first launch by whether save data exists. If a player deliberately deletes the save data, it'll be treated as a first launch even though it isn't, but I think you can accept that as a rare case. This way, on Android you can redo the assignment by clearing the app's storage, which makes testing go smoothly.

Using Firebase Remote Config

The advantage of using Firebase is that you have the option of not storing the assignment in the save data. On every launch the SDK asks the server for the assignment. If you write it into the save data, there's a chance the player will tamper with it, but this way that problem goes away.

The bigger advantage is that you can change a player's assignment without updating the app. On the Firebase website you can do things like "put everyone back on the old behavior" or "move everyone to the new behavior."

In other words, once an A/B test is settled, you can roll out the winning behavior to everyone just by using the website.

Why I stopped using Firebase Remote Config

So it has quite a few advantages, but in the end I stopped using it.

To begin with, the first advantage, not needing to write to the save data, only holds if the network is connected and fast enough. If the network is down at launch, the assignment doesn't arrive from the server. There may be locally cached data it can fall back on, but I'm not really sure that works in every case. In the end you write it to the save data anyway, just in case.

The Firebase SDK takes seconds to initialize, and you can't read the assignment until it's done. That's a problem when you need it right after launch. The earlier "title screen or not" example is a good illustration. I don't want to wait even a second. In the past I even had to delay playing the BGM until I knew whether there was supposed to be BGM, which was quite a nuisance. So at one point I had a fiddly setup: "if the assignment is needed right at launch, assign inside the app; otherwise, apply it as soon as it arrives from Firebase." That's a hassle in its own way.

Also, if the network isn't connected on first launch, no assignment happens at all. You end up setting a default for when no assignment arrives, but a fair number of people aren't connected at launch, so the default group ends up larger. And many of the people whose network is down at launch have probably cut it off deliberately, and those players behave quite differently, so the data for the default group gets skewed. With no other option, I sent separate data flagging "this person's assignment didn't arrive" and aggregated them separately.

The next advantage, being able to change the assignment without updating the app, isn't all good news either, because being able to affect every existing player in the world is also a risk. If you can push bad assignment data to the whole world after the fact, you could break the game for everyone with it. You have to write code you're confident won't break even if a bad value comes from Firebase, and you have to be extremely careful when configuring it so you don't send bad values in the first place. To limit the damage, you narrow the rollout with detailed conditions like "only distribute to version such-and-such and later," but that's also complicated and nerve-racking.

On the other hand, if the app decides the assignment, then even if there's a bug, the damage is limited to that build version, so the worst-case scale of damage differs by a factor of 10 or 20.

The drawback of not being able to change the behavior without updating the app isn't much of a problem, because you can just update the app. About two and a half years ago I thought, "Updating an app is very costly, so I must make as much as possible changeable without updates." In most cases that's probably right. But if the development scale is close to that of a solo developer and the app's download size isn't large, the cost of updating is acceptable, and the download size you force on players can be kept to a level they'll forgive. These days Google's store also tries to download only the differences wherever possible.

By the way, much the same goes for Unity's Remote Settings.

Data collection

Next, let's think about collecting data. Collection involves two questions:

  • What to collect
  • Where and how to send it

First let's think about what to collect.

What to collect

What you need depends on what you want to evaluate by. But there's probably some data that's worth sending whatever the game. Working out what to collect for each product separately is a hassle, too.

Things like the following aren't very product-specific, so it seems fine to put them in a shared library:

  • Total play time
  • Number of launches
  • For level-based games (level = stage), the number of plays or number of clears
  • Time taken per level
  • Number of failures per level
  • For ad-monetized games, the number of ads shown
  • (If any) amount purchased
  • (If any) ad revenue amount
  • Frame rate information
  • Bug information
  • A/B test assignment information
  • A unique player ID
  • App version

Total play time and number of launches

Total play time is probably the most versatile metric for measuring how fun a game is. People play fun games for a long time and boring ones for a short time. When comparing which of two games is more fun, saying the one with longer play time is more fun isn't entirely accurate, but it's handy as a rough measure, and it's convincing. Of course, sometimes someone spends ten wonderfully rich minutes, feels satisfied and quits, and personally I like that kind of game too, but I think that's probably rare. It's also at a commercial disadvantage.

There are several ways to measure play time, but on phones there's no guarantee you can catch the moment the game ends, so taking the difference between start and end times doesn't work well. Adding the time since the previous frame to the save data every frame seems simplest. In Unity that's Time.deltaTime. Saving to storage can be expensive, so don't do it every frame; wait for a moment when a hitch won't be noticed, such as the end or start of a level, when a UI button is pressed, and so on.

Also, on phones, when you switch to another app and the game goes into the background, you get things like "an hour suddenly passed between one frame and the next." Unity's Time.deltaTime has a maximum value, and after a suspension it gets clamped to that maximum, so if you're adding up deltaTime you get a reasonable value without special handling, but if you add up real time, for example using unscaledDeltaTime, you need to record when the app is suspended and resumed and subtract that time. In Unity, use OnApplicationPause.

Another fairly important piece of information is the number of launches. Play time goes up if you launch the game and leave it running, and could also go up in a game with long loading times, but launching a game takes intent, so it's a good indicator of how much the game is loved. You can also spot things like a game being launched every day and played a little at a time even though its total play time is short.

Per-level information

For a level-based game, how far a player got, how many seconds a level took, how many times they failed and so on are all worth having. Even if you don't use them directly to evaluate the A/B test, as I'll describe later, you need some extra information to make sound judgments.

I think it's good to send data when a level starts and when it ends, and include how many seconds it took, how many times the player failed and so on with the end event. Information like "level 5 is taking oddly long" helps improve the game. If that's too much bother, just sending a "level end" event tells you how many levels people play on average, which is useful.

Money

For a game with in-app purchases, it's good to collect the items bought and their prices too. If you evaluate A/B tests by money, you need to know which group pays you more, so this information is essential.

Likewise, for an ad-monetized game, you can sometimes get the revenue amount from the SDK (AppLovin's MAX SDK lets you), so it's good to send that too. Then you can see how ad revenue is doing for each group.

The number of ads shown is also useful. Record the ad type too, such as banner or full-screen.

Frame rate and bugs

Say you run an A/B test to see whether five times as many enemies makes the game more fun.

It does happen that when you play it yourself it's obviously more fun, but when you actually release it to players, play time doesn't go up.

When that happens, the first thing to check is whether players found it not fun, or whether it just didn't run smoothly on their devices.

Because of that risk, I personally think developers should normally play their own games on a fairly underpowered device, but many of you probably use a high-end iPhone day to day (I get the impression many people don't realize an iPhone is a high-end device). So how smoothly the game actually runs on players' devices is important information. I think it's good to include the average frame rate at the end of each level in the level data above.

By the way, this is just my personal sense, but if the 10th percentile of the frame rate (FPS) (line people up from highest to lowest and take the FPS of the person a tenth of the way up from the bottom) is below 20, I feel the game is running a bit too heavy. It means 1 in 10 people isn't even getting 20 fps, which gets in the way of playing an action game. For a game with a sense of speed, you'd want 30. FPS usually doesn't go above 60, and more than half of players get 60 fps, so the average comes out at 40 or 50, but looking at percentiles you can clearly see things like "as many as 10% of players get frame rates too choppy to play." Many numbers are better judged by something other than the average.

By the way, the reason I recommended recording the frame rate per level is so you can spot things like "this level is heavy." You might think "I've added the most fun level ever!" when it's actually so heavy on players' devices that it's unplayable.

Then there are bugs. If you use a tool like Firebase Crashlytics, you can collect how many null reference exceptions and the like are happening, but you can't see whether bugginess differs between A/B test groups. There are probably cases where adding a feature caused bugs, so it's better to be able to aggregate bug counts per group. So let's send exceptions and the like too. In Unity, you can use Application.logMessageReceived. With a bit more effort you can add call stack information to help with debugging.

Player ID, assignment and version

Finally, there's the data needed for aggregation: the player's ID and their group assignment.

If you send "Cleared!" to the server every time a level is cleared, you're stuck without knowing who cleared it, right? To calculate how many levels each person plays, you need some kind of per-person ID.

With Firebase this ID is assigned automatically, so you don't need to do anything, and if you use Adjust you can get an ID from the SDK. If you roll your own, you'll probably need to issue IDs yourself. I don't know whether you'd have a server issue them or generate them inside the app somehow, but either way it's probably a bit of a hassle.

And of course you need the A/B test group. If you don't know who belongs to which group, you can't aggregate per group. Firebase has a concept called UserProperty, and if you put the assignment there, it's automatically attached to everything you send. For example, an event like "cleared a level" automatically comes with the player ID and the group they're assigned to. Without Firebase, with Unity Analytics for example, you probably wouldn't need to think about this, and if you store the data in your own server's database you need to design the tables carefully.

Last is the app version. As I'll describe later, you can't A/B test every little improvement, so it frequently comes down to "it's fine if this version, with all sorts of things in it, beats the old version overall". In that case you aggregate per version, so you need the version information. Firebase sends this on its own, though.

If you want to compare things like different builds with the same version number, you'd probably also need to include the build number. You can't get it with a Unity function, so I think it's good to write the build number in a text file, put it in the build and read it. But in that case I think you're better off changing the version number. I include it to check which build the app I'm running is. Testing with the wrong build installed all along isn't such a rare accident, after all. The app has a secret command that displays the build number.

Other

Sometimes, as needed, I send information unrelated to which group is better. A common example is information to confirm that things are working correctly.

For example, when you've run an A/B test on whether the title screen appears and the data has come in, you sometimes start to wonder: "Is the title screen really appearing for this group?" Of course you test it yourself before releasing the update, but as you all know, testing doesn't guarantee it works.

So if you add something like "send an event when the title screen appears," you can check "how many people in the title-screen group actually saw the title screen" and "how many people in the no-title-screen group saw it anyway." That reassures you that it really is working.

You don't always need extra data like this, but it can be useful.

How to collect

Broadly, you either send the data to your own server or use an existing service to collect it.

Rolling your own is only for people who know how, and they'll understand the issues well. I'm an amateur when it comes to servers, so I won't cover it here. That said, I think you should consider whether the product is even allowed to send data to your own server. If the app hits a server your company runs every time it sends data, there's the cost of running that server.

In the past I've used Unity Analytics and Firebase, but I've now settled on Firebase. Firebase on its own can't do much, but as I'll describe later, combining it with something called BigQuery lets you use SQL and expands what you can do. Firebase is more of a hassle to set up, though.

Sending data with Firebase

Sending data with Firebase Analytics is easy. You initialize it and call the send function whenever you want to send something. For example, you send an event when a level starts, send one with FPS and time taken when a level ends, send one when ad revenue comes in, and so on.

The tedious part is initialization. You can't send anything until initialization finishes, so if you want to send something that happened right after launch, for example, you have to wait for it. It's a good idea to give a wrapper class a queue so that the calling code doesn't need to care whether initialization has finished.

Also, if you send the assignment as a UserProperty, it gets attached to every subsequent event, which makes aggregation easy. In some cases, such as when using Firebase Remote Config, the assignment isn't available right after launch. For that reason too, I think it's good to accumulate the events you want to send in a queue and process the queue once the assignment arrives. I used to do that as well, but I stopped using Remote Config, so the problem went away.

One more thing: for continuously increasing numbers like total play time, when to send is an issue. The more often you send, the less data is lost when the app suddenly crashes, but sending too often increases the load and needlessly piles up data on the server. For example, if you send once every 10 minutes and the app crashes 9 minutes in, those 9 minutes of data are lost. It's a question of how much loss you can tolerate.

I send total play time as an extra parameter on the level start and level end events. If someone quits partway and closes the app, the play time up to that point is lost, but I know that's how it works, so it's not a problem.

Storing and aggregating data

That covers collecting and sending the data, so next comes storing and aggregating it.

If you collect and store it with your own server and database, you'll presumably set up your own environment for aggregating it with SQL too. We experimented with that a little, but it never made it into real use, so I won't cover it here.

Unity Analytics

First, Unity Analytics. My memory of it is already hazy, since it was more than two years ago, so I can't say anything for certain.

I think you could at least see graphs of things like "this many people got as far as level such-and-such," and I think you could also run A/B tests in combination with Remote Settings. For a game made in Unity, it's probably easy to set up without adding anything extra yourself.

But not being able to write your own SQL is quite inconvenient for me. For example, if you want to know "the rate at which people in Mexico failed level 8 after picking up this item, on December 23 only," it's probably painful without SQL. Also, in the discussion of deciding which group is better later on, you need to calculate the numbers the decision requires, and you probably can't get those without SQL either.

You might be able to download the data as CSV or similar, but in my experience the data piles up to hundreds of gigabytes or more, and terabytes if you have a hit, so downloading it, loading it into your own database and then using SQL seems like a bit much.

Firebase on its own

You can see all sorts of things about the data sent to Firebase on the Firebase website, such as graphs of how many times a certain event was sent or which countries have the most players.

Also, combined with Firebase Remote Config, it gives you numbers like "in this A/B test, the probability that this group is winning is 85%."

Here too, not being able to write SQL hurts, and as for A/B test decisions, even when it tells me "this group is better with 85% probability," I don't really know what that number is based on. In fact, it gives different numbers from what you get doing it yourself with the procedure I'll describe later. It probably uses Bayesian statistics or something (my guess). It's Google, after all, so I'm sure it's sophisticated, but not really understanding it is a slight minus.

Above all, the trouble is that you don't have much freedom in choosing what to evaluate by. You probably can't evaluate by a metric of your own. For example, if you want to know which group does better on "the number of full-screen ads plus a tenth of the number of banner ads," that looks impossible with Firebase alone.

Maybe you could manage it if you really mastered it, but if you don't want to use Firebase Remote Config in the first place, you're stuck. As I said, I'd rather not use Remote Config, because the wait at launch is a pain and the worst-case damage when something goes wrong is large.

Firebase + BigQuery

If you link Firebase with BigQuery, you can run SQL on the accumulated data. Once you can run SQL, you can process the data however you like.

I had a look at the SQL queries for the product I'm working on right now, and they include things like:

  • For each version and A/B test group, show the number of ads, revenue, average play time, median play time, average number of levels cleared, the 10th percentile of FPS, the number of exceptions and so on
  • Show the breakdown of players by country
  • Show the trend in daily installs
  • Show histograms of ad counts and revenue
  • List "y% of people played as far as level x" to graph how people gradually drop off
  • See how ad revenue changes by ad type and over time
  • Compare the time taken, frame rate and number of failures for each level

and I can run them whenever I want to look at the data. If you wanted, you could also run the SQL periodically, paste the results into a Google Spreadsheet and update the graphs.

SQL isn't a very hard language, and you only need to learn the features you use, so I don't think it takes that much effort to learn. It's hard to imagine an engineer who makes apps in Unity being unable to pick up SQL.

That said, our company has lots of server engineers, and dozens of people in-house know SQL, so if I get stuck I can ask someone right away. It's quite a privileged environment. The Firebase + BigQuery option was also something the server folks taught me. Somewhere without many server people, choosing it might take a bit of a leap. In fact, I didn't know SQL or BigQuery until I started this job.

...And come to think of it, even on our team, I don't think that many people casually write SQL. Maybe people want to write SQL less than I think. I can't rule out that something that saves you from writing SQL, like Unity Analytics, might make everyone happier overall.

By the way, setting up Firebase is fairly tedious, so it might be nice if you could collect the data with something else and move it into BigQuery from there. I haven't tried anything like that yet, so I don't know whether it's possible.

Evaluating the test

So the data has piled up and we've covered the tools for aggregating it. Let's move on to the heart of the matter: evaluation.

This is actually the trickiest part, and what makes it even trickier is that doing it without realizing how tricky it is might not be much of a problem, so I'll touch on that too.

The metric

The first problem is what to evaluate by.

We work to make fun games that players love, but what exactly has to happen for us to say "it's fun"? Personally I feel fun could be quantified as something like "intensity of emotion × time," but I can't think of any way an app could measure something like "intensity of emotion." Looking at plain total play time probably isn't too bad, but I'm not entirely comfortable with it.

Besides, whatever we say, we make games as a company, so we have to secure enough profit to keep making games. Even if you make some change and, as a developer, think "it's so much more fun now!", if it reduces profit, it can't go in. It'd be nice if you could tell the producer "it's way more fun, but it'll earn less!" and they'd say "sure."

So, though it feels a bit simple-minded, let's treat it as "bigger profit = happy players = we made something fun." It's not perfect, but it should be more or less right. Especially in free-to-download games with an ad revenue model, players can just quit right away if it's boring, so if you put in a bad change, players should leave. Even if you try to make money with some evil change, players who hate it will quit, so in that sense there aren't many problems. On the other hand, with a buy-once game that charges something like 5,000 yen up front, or a game with in-app purchases, things might get more complicated.

So for now, I'll proceed on the basis of running A/B tests where "the group that brings in more money wins."

Evaluating by the amount of money brought in

Which brings in more, the group with a certain feature or the group without? It's a simple question.

For a game with in-app purchases, you collect the purchase amounts with Firebase, aggregate them in BigQuery, and calculate the purchase amount per person for each group. The group with the higher number wins. For the ad revenue model too, if the SDK gives you ad revenue, you can do the same thing.

But if someone asks, "So it's fine if it's even slightly bigger?", the answer is no, right? And when should you make that decision? One day after you start distributing the update? Seven days after? What you ultimately want to know is which is better once enough time has passed, so the longer you wait, the more accurate the data you can judge by. But the longer you wait, the more development is delayed. You can probably start on the next improvement if it's unrelated to what you're testing, but a long stretch of fidgeting while you wait for results isn't pleasant, is it? Often you can't decide what to do next until you know whether that change worked. So you want to decide as soon as possible.

So what should you do?

"There's a statistically significant difference"

Say we have two dice, A and B.

You roll each once, and A comes up 6 while B comes up 1. Are these loaded dice whose six faces don't come up with equal probability? Or are they normal dice?

Statistics gives a reasonable answer to questions like this. So if we recast the A/B test problem as a question of the same form, we can use statistics. Let's try it.

"The averages of the two groups were 6 for group A and 1 for group B. Do these two groups have completely different characteristics? Or the same characteristics?"

"The groups have the same characteristics" doesn't mean everyone in the groups is the same; it means the distribution of how much people pay is the same, for example "90% of people pay 10 yen and 1% pay 100 yen." If the distribution is the same in both groups, they'll probably have the same average. But sometimes the averages differ by chance. Statistics tells you, "If the averages differ by this much, they might not have the same characteristics, you know."

Now, back to the dice. If a die is fair, the probability of rolling a 6 is 1/6, and the probability of rolling a 1 is also 1/6. The probability of die A coming up 6 and die B coming up 1 is 1/36, but that in itself means nothing; the probability of both coming up 3 is also 1/36. So we focus on the difference. The difference is 6-1, which is 5, and no other combination gives 5, so the probability is 1/36. Fairly rare, maybe? By comparison, a difference of 4 or more can happen 3 ways, (6,1), (6,2) and (5,1), so the probability is 1/12, three times as likely. You might judge that "1/12 could be chance, but 1/36 is a bit suspicious," right? Of course, you could also say 1/36 might be chance too. What probability counts as suspicious is something the person running the test can, and does, decide for themselves.

In A/B testing too, statistics lets you calculate the probability of group A's average and group B's average being 5 apart, so you can judge "no, that's not chance" or "might be chance." This "not chance" is sometimes described as "a statistically significant difference," but we're not writing a paper or talking to academics, so there's no need for that kind of language. We're just game developers, so there's no need to act like statistics experts (a note to myself).

The logic here is a little convoluted, so let's go over it once more.

First, assume the two groups have the same distribution. That's the same as assuming the dice aren't loaded. Then, using the tool called statistics, calculate "if that were true, what's the probability of the averages being this far apart?" Then look at whether that's high or low and decide for yourself whether it's chance. If you decide it isn't, that means the two groups didn't have the same distribution after all. In other words, the dice were loaded. It's a little roundabout, but this lets you say "this group is better."

Calculating the probability with statistics

There are many statistical methods for calculating the probability, and which one to use depends on how the original groups are distributed.

The luckiest case is when the original groups follow what's called the normal distribution. Lots of people are around the average, and the further above or below it you go, the fewer people there are.

Those of you who remember entrance exams will remember deviation scores; they're a handy number that uses the fact that test scores are roughly normally distributed to give you a rough idea of what percentage from the top you rank. An average person has a deviation score of 50, with half above and half below. Someone with a deviation score of 60 is in the top 15% or so, 70 is the top 2%, and 80 is the top 0.1%.

If the money players pay in a game were normally distributed, you could calculate the probability using the well-known method designed for the normal distribution, the t-test.

The numbers you need for the calculation are the number of people in each group, the mean and the variance. If you get those for each group with SQL, you can do a t-test. There are t-test calculators on the web, so there's no need to implement it yourself. You can easily calculate it on sites like t-test of the difference between two group means - High Accuracy Calculation Site. The method differs depending on whether the variances are roughly equal, so it's generally best to check "can't assume (Welch)" for "assume equal variance" (if you implement it yourself, use Welch's method).

The "significance level" is the probability below which you consider a result not to be chance; 5% is common, but decide it for yourself. When you run the test, you get output like "the null hypothesis that the means are equal is rejected." It's rather obscure wording, but it means "we assumed the means were the same, but they aren't," in other words, "the means differ."

When it says "not rejected"

So what should you do when it says "not rejected"?

You can conclude that the change was pointless and stop there, or improve it and try again, but you could also wait a bit longer.

Basically, the more people there are, the more readily the t-test reports a difference, even for a slight difference in means. You can sort of see why, right? With one die each, the probability of a difference of 5 is as high as 1/36, but with two dice each, the probability drops sharply. The difference only comes out at 5 if one pair of rolls are both 6 and the other pair are both 1, so it's a mere 1/1296. That's why the more samples you have, the lower the probability of a big difference.

With a mobile game update, the longer you wait, the more players install it, so you can detect correspondingly smaller differences. Conversely, when it says "not rejected," you can also interpret that as there having been too few people.

There's one more factor: the larger the variance, the less readily it says "rejected." Variance is a measure of spread. For example, an ordinary die produces a wider range of numbers than a coin with 1 on one side and 2 on the other used like a die, so it's more spread out: 1 to 6 versus 1 to 2. So its variance is larger too. Naturally, the more spread out the data, the more the average tends to wobble. So when you test widely spread data, it's hard to get the test to settle (my usual shorthand for getting a "rejected"). This will come up again later.

Normal distribution?

Now, a moment ago I glossed over something important. I said "if the money you get from players is normally distributed, you can use the t-test," didn't I? But is it really normally distributed?

I think this depends on the product, so I can't say for sure either way, but I've never seen it come out normally distributed. I suspect it never does.

The conditions for a normal distribution aren't all that simple, but if the data is

  • Roughly symmetric left and right
  • Most people are near the average
  • The further from the average, the fewer people

I think you can more or less say it resembles a normal distribution. But in the ad-monetized games I've seen, it's more like

  • Badly lopsided
  • Most people aren't around the average; most are around 0
  • The further from 0, not from the average, the fewer people

Not normally distributed at all.

So I figured I should use some method other than the t-test, one designed for a closer match, but annoyingly I couldn't find one.

To cut to the conclusion, though, the t-test probably works.

That's because when I wrote a program that assumes a distribution closer to the real one (an exponential distribution or a log-normal distribution) and calculates the probability by random sampling, it gave numbers similar to the t-test after all. I calculated the probability with both tools dozens of times or more, and they never disagreed much. Since I went to the trouble of writing it, I use my own program, but the t-test is probably fine. No guarantees, though.

The central limit theorem guarantees that "with an infinite sample, it doesn't have to be normal," but how many you actually need in practice you won't know until you try. That said, if you search for things like "robustness of the t-test"2, you get the sense that it seems to be OK once the sample goes over a few thousand. Ad-monetized casual games have tens of thousands of players, after all. But with tens or hundreds of people, the difference in the shape of the distribution could become a problem. I think it's best to check for your own use case.

Do we really need to be that rigorous?

This has suddenly gotten very academic, and my head is starting to spin. We're making games here; do we really need this sort of thing? Don't you wonder?

The truth is, however rigorous you are, game A/B tests have fundamental limits. If trends change, the test results are garbage, and whatever result you got only tells you "that's how it was at the time." Player behavior might change completely because a typhoon hit, or because a similar, more fun game came out.

Besides, even if you're sloppy about it ("I happened to run the SQL, this group's number was higher, so it wins!"), you'll make the right call more than 50% of the time. You could argue that's good enough.

If anything, the bigger problem is unconsciously running the SQL over and over and deciding when the result you wanted happens to come up, all while saying "data matters." If you do that, the t-test won't save you either. It's hard for humans to resist reasoning like "this change lost among all players, but if I look only at India, where we have lots of players, it's winning. It must really be winning." Everyone wants the change they worked so hard on to win. And that's fine. Putting out what you think is fun for players is how it's supposed to work. You can say "scientific procedure" with a straight face all you like, but it might just eat up time and achieve nothing, you know?

With that in mind, I don't think completely ignoring this kind of convoluted theory should be dismissed out of hand either. Of course, that also raises the question of whether we need to A/B test at all...

The variance problem

That was a digression that rather undercuts everything, but let's get back to the details. We were talking about the t-test.

Actually, there's a far more serious problem than whether the data is normally distributed: variance that's much too large. With play time, for example, if you have a wide range of people, from those who quit right away to those who play an insane amount, the variance becomes large.

When the variance is large, the t-test is reluctant to report a difference, for the reason I've already described.

But real money data probably has very large variance as a rule. Just think about it. In a game that's "free to play, with 400 yen to remove the ads," the buyers are probably a minority, so the average is close to 0. Variance is the square of the difference from the average, so something like the square of 400-0 gets added in, and the variance becomes large.

With ad-monetized casual games the situation is the same, or possibly even worse. You normally release worldwide, so you have players from all sorts of countries. And in most cases, the stronger a country's economy, the higher the ad revenue. It can differ by a factor of tens depending on the player's country. Because of this, the variance becomes insanely large. An average of 16 with a variance of 1000 isn't unusual. The square root of the variance is called the "standard deviation," and in a normal distribution about 70% of people fall below "average + standard deviation." If the average were 3 and the standard deviation 10, then "if it were normally distributed," 70% of people would be at 13 or below, which is insanely wide given the average, isn't it? That still leaves 30% above roughly four times the average. And amounts of money can't be negative in the first place, so the distribution can't be symmetric. It's clearly not a normal distribution at all.

My impression is that to settle a t-test on ad revenue, you need either an insanely good improvement or hundreds of thousands of players. When the app hasn't grown yet and doesn't have that many players, an improvement that's merely "a bit better" never settles at all, so if your rule is "you may adopt a change once the t-test settles it," you'll never be able to adopt anything.

There are various countermeasures, and I'd encourage you to think them through for yourselves, but I don't think loosening the threshold at which you consider there to be a difference is a very sound approach. If you change "5% or less means a difference" to "20% or less is OK," of course it settles more easily, but that means you're wrong one time in five, you know? Isn't that far too lax? Wouldn't it be better to just give up on A/B testing altogether?

For now, I think there are about two proper countermeasures. One is "don't test changes individually." The other is "test with a different metric that has smaller variance."

Don't test individually

I think one strong option is to stop testing each improvement that only makes a subtle difference. A/B testing is a pain, after all.

You throw several changes into the app without testing them individually: "improved the button design, fixed the slowdown that was happening, tightened up the controls that weren't great..." That doesn't mean you adopt them with no testing at all. You just compare the build with lots of changes against the previous build without them.

Fortunately, the Android store lets you distribute two versions at the same time. You can set it up as, say, 50% for the current version 1.0 and 50% for the new version 1.1. If you're worried the new version is buggy, you can also release it to only 5% at first.

Then you use the version as the A/B test grouping. Firebase collects the version number automatically, so you don't even need to implement A/B test assignment or sending.

The more changes a build contains, the more readily a difference shows up. You won't know which individual change helped, but if things got better overall, that's fine. You roll that build out to 100% and stop distributing the old version.

You just repeat this to grow the app. Then once it has grown, if you're wondering whether some earlier change was really an improvement, you can test it individually. The things you can retest later are probably minor details that don't touch the core of the game, so I think you can largely avoid the "is it even right to A/B test something like this?" kind of dilemma. Examples include the position, color and size of UI buttons, or the speed of effects and transitions.

Note that this method only works if you can distribute two versions at the same time. In the mobile market, that means Android only. On iOS, when you update, the old version stops immediately and only the new version remains.

Not being able to release two versions in parallel is a problem in itself: if the new version is buggy, the damage is large, so you have no choice but to be careful. Updating on iOS is risky to begin with, and there's also the hassle of review and so on. In my case, when I'm going all out on improving a game, I update Android once every day or two, but I update iOS only when there's been major progress on Android. About once a month, maybe?

Also, as an aside, even if the content is almost identical on Android and iOS, it's handy to give them different version numbers. When aggregating by version in BigQuery, if a version mixes iOS and Android, you have to separate them because the players are completely different, which is a hassle. iPhones are high-end devices, so iOS players have completely different spending power, and because of that, their behavior and ad revenue are completely different too.

One more thing. Before I roll a version out to 100%, I require that the new version as a whole beats the old version as a whole in a t-test (with some exceptions). Sometimes you've changed something you didn't mean to, and some changes, such as SDK updates, can't be A/B tested, so this guards against things accidentally getting worse. There's little value in rolling out an update to 100% when its difference isn't big enough to settle a t-test, and you wouldn't want it to contain a problem that only surfaces over a long period, like "actually, a bug kicks in after 14 days." So I don't stop distributing the old version until several improvements that won repeated A/B tests have accumulated and the new version as a whole clearly beats the current one. For the latest Mannequin Downhill, I've put out 60 builds so far, and I think only about a quarter of those versions reached 100% distribution.

Numbers with smaller variance

We were talking about the problem that using money as the metric gives too large a variance. The other way to deal with it is to use a different metric.

Money varies so much because of things like the huge gap between people who pay and people who don't (for purchases) and the huge differences between countries (for the ad revenue model), so if you use a number that varies little between countries and is probably roughly linked to revenue, the variance should be smaller.

Play time is one example. There probably aren't that many people with zero play time; everyone should play at least a little. And there probably aren't that many players who play dozens of times as much as an ordinary person. As a result, it shouldn't vary that much.

But that raises the question: are play time and money really linked? It also has the drawback that outliers creep in easily. When someone just leaves the game running on their desk for an hour, an abnormally high value gets mixed in. Some people don't have their screens set to turn off after a timeout, right? With lots of people, the influence of outliers is diluted, but we're having this discussion precisely because we don't have lots of people right now. For example, if you want to judge with 100 people per group and even one "left it running for an hour" person ends up in either group, that group's average goes up by 3600/100 = 36 seconds. The variance goes up too, which does make the t-test somewhat harder to settle, but with the average that much higher, you might also wrongly conclude "this group is better!"

Then there's the number of levels cleared, which might serve the same purpose. It should also roughly correlate with play time, probably won't produce outlandish numbers, and doesn't go up when the game is left running, so outliers are less likely. But what about a test that changes the levels? With a change like "the pacing was bad, so I tried making each level shorter," the new version will naturally have more levels cleared. Is that really better? Play time might actually go down, you know?

For the ad revenue model, there's also something like "number of full-screen ads shown." Since revenue comes from ads, assuming that more ad views mean more profit seems roughly right. Like levels cleared, it doesn't produce outliers when the game is left running, it roughly correlates with play time, and it seems less affected by changes to levels. In fact, I use something based on this as my main metric.

However, this has problems too. There's the question "if you show tons of ads the metric goes up, but is that really OK?", and the doubt "do more ads really mean more profit?" It's complicated, so I'll describe it later in the appendix, but because of it, using the number of ads as the metric requires a fair amount of care. Still, as long as you're careful, it seems to be a decent indicator. Also, if the SDK doesn't tell you how much each ad earned, you may have no choice but to use this as the metric. We were actually in that position in the past. I don't think we could get the revenue amount two years ago.

Another number that looks usable is the number of launches. A beloved game that people play for days will naturally get launched more. "What percentage of people are still playing after k days" (retention) is sometimes used to evaluate how good a game is, but if you use it as your metric, you'll probably run into things like "I kept making changes to increase 3-day retention, and 7-day retention actually went down," and you'll also agonize over which day's retention to use. If you evaluate by number of launches, these problems don't arise and things stay simple.

But how well the number of launches correlates with fun depends on the game. Even if more players end up staying up all night playing, the number of launches doesn't go up, and at worst players might feel satisfied and leave the game, reducing the number of launches. Whether this metric is appropriate depends on the revenue model and the nature of the game. And it takes at least several days, probably weeks, for the number of launches to show a difference, so I think it suits larger-scale games that people play for quite a long time. The ad-monetized casual games we make don't have that much content, so we rarely manage an improvement that makes a clear difference in the number of launches.

If the t-test says OK, is that enough?

Now, if you run the test and it comes out "rejected" (= not chance), does that settle it?

The answer is: decide for yourself.

For starters, what a t-test gives you is a probability, and even if it tells you "the probability is 5%, so it's not chance," if you do that 20 times, one of them will be chance. 5% = 1/20. And as we've already seen, the t-test was designed for normally distributed data, and the metrics used in game A/B tests are probably far from normally distributed, so how far you can trust the probability it gives depends on the case.

Furthermore, even before the testing procedure, there's the question of the underlying data. Say you start collecting data when you release the update containing the A/B test, and three days later you run SQL in BigQuery, do a t-test, and conclude it's not chance.

Now, what if this A/B test was about "a feature that gives you a present three days after installing"?

That result has to be bogus, right?

If it really was implemented to spec, the result is probably chance. Actually, if it were me, I'd suspect it wasn't implemented to spec.

There probably aren't many examples that extreme, but game changes range from ones where a difference shows up right away to ones where it only shows up for people who've played for a while. An easy example is "made the early levels easier." Game developers tend to make things needlessly hard, so fixes like this sometimes get made after the fact. This probably improves the numbers in the period shortly after install, because you hold on to players who would otherwise have given up because it was too hard. But what happens later isn't necessarily clear. Players who didn't find it hard in the first place might find it unsatisfying and quit. Also, even if an element is somewhat hard, if players need to understand it to enjoy the game, introducing it early and getting them to understand it is necessary to keep them playing for a long time. If you carelessly decide "it seems hard, so let's cut it," you cut the fun along with it.

In other words, even if a change looked good at one point, you don't know whether it'll still look good later. What you really want to know is what the numbers look like once enough time has passed, but the longer you wait, the slower development gets, so you can't wait that long. How long you should wait depends on the nature of the game, the nature of the players, the kind of change and so on.

If you do this kind of work long enough, I think you develop an instinct like "with this game, results after three days hardly ever get overturned," but the whole reason we do things like t-tests is that instinct can't be trusted, so you end up in the awkward position where how much you trust your instinct also comes down to instinct. But that's reality, and all you can do is face it.

Using secondary indicators

One technique for making your judgment more reliable is to use secondary indicators. For example, even if you use "number of full-screen ads shown" as the metric, you also keep an eye on play time and number of launches. Normally, if the game got more fun, play time and number of launches should go up. The number of ads shown goes up as a result of the game getting more fun, so they should all rise together. If they're moving in opposite directions, you suspect something is off, or that there still isn't enough data.

When something seems off, it's good to think it through in light of what the change was. For example, in a game where ads appear between levels, if you shortened each level to improve the pacing, the ad frequency will often go up in practice. Then play time is likely to go down. Whether that's OK is something only you can decide.

Another thing to think about is what happens if you declare a winner that didn't really win. For a test about the position of a UI button, for example, retesting later and putting it back isn't that hard. But for a change like "added a character customization feature," even if you later find out it actually made things worse, it's no longer easy to cut. So you'll probably also adjust how cautious you are depending on whether you can recover if you get it wrong.

Problems around updates

A/B tests are run through app updates. First you distribute a version of the app with the test in it and collect data, and when the result is in, you make and distribute another update that reflects it.

These updates come with quite a few problems, so let me touch on them here.

Basically, it's safest to include in the test only players who start playing on the version that contains it. A test like "improved the design of level 1" only matters to players who haven't played level 1 yet, right? Also, with things like control changes, a sudden change is bad. Besides, when data from players who are already well into the game gets mixed in, aggregation and evaluation tend to get difficult. Their progress varies, so the data ends up widely spread.

But that doesn't mean you can ignore what happens when players who've been playing since the previous version update. It's a problem if the game breaks after an update, so you need functional testing. Ideally, players who were already playing see no change in behavior after updating, but functional testing is fairly tedious. There's also an ethical question: is it acceptable to ship an update when some players will think "I updated, but nothing's changed"? In many cases, all you can tell players is "bug fixes."

On top of that, deciding what to do when a new feature you A/B tested turns out to be bad is another problem. If you remove the feature completely, players who were playing with it will see the behavior suddenly change when they take the next update. So ideally you'd leave the code in so the behavior doesn't change, but if you keep running A/B tests without ever removing any code, the codebase swells and becomes hard to manage.

The download size also grows, which could reduce the number of people who download the game. In general, the bigger an app's download size, the lower the install success rate, which directly lowers the efficiency of the ads we run to get the product in front of players. In industry lingo, "the CPI (Cost Per Install) goes up." A little is one thing, but too much bloat isn't welcome. It's bad for players, too.

So at some point you have to remove the code for features that didn't work, but the question is when. If you drag it out too long, the code gets badly bloated and the number of combinations to test grows, raising the cost of functional testing before release. Or, if you can't afford to do all the functional testing, the probability of things breaking on players' devices goes up. But if you remove it quickly, more players see the behavior suddenly change.

How you strike this balance depends on how long the product gets played. For a small product that people only need to enjoy for a few days, removing the code after, say, two weeks might cause almost no problems. But if some players love it dearly, maybe you should wait longer. That depends on the product, and also on the conscience of the people making it.

It also depends on what kind of change was A/B tested. There will be all sorts of cases: "the design obviously got cooler, so it's fine to apply it to existing players," "this change adds levels at the end, so I'd actually like existing players to get it so they can enjoy them," "the controls are fundamentally different, so a change in behavior is absolutely unacceptable," and so on.

A particularly tricky example is something like "added a feature that takes screenshots, saves them to storage and lets you view them anytime." If you test this feature and then decide to drop it because it performed badly, the feature suddenly disappearing is quite a problem. Same with something like "made power-up items purchasable with in-game currency": having something the player earned or created in the game disappear is a whole different level of problem. But elaborate changes like these tend to involve a lot of code, and if they stay in, they keep costing a lot forever. If you neglect functional testing, things will probably break too, like the feature silently breaking in some update without anyone noticing. In cases like this, I've sometimes resolved to keep changing the feature until it wins, no matter what, and polished it. It's quite common for a feature to be poorly made when first added and lose the A/B test, but if you don't give up, keep improving it and it eventually wins, the problem is solved. Park Master has a level select screen that shows screenshots from when you cleared each level, and that feature is one such example. At first it was poorly made and couldn't win, but cutting it later would have caused too many problems. In cases like that, loosening the A/B test criterion to "OK as long as it's at least even" is also an option.

Changes that alter or extend the save data format are also dangerous. If one turns out to be bad and you revert it, you have to check very carefully what happens, because the code gets rolled back while save data in the changed format already exists on players' devices. Frankly, I think it's better to resign yourself to the fact that you can't remove a change that touches the save data.

Summary

This has turned into an absurd amount of text, and there's no conclusion. It's a rambling list of whatever spilled out of my head when I, someone who has run A/B tests and will probably keep running them, decided to write something about A/B testing.

Anyway, what matters is not losing sight of the fundamental point: we're doing this to make the game better. A/B testing is just a tool for reducing uncertainty along the way. I think of A/B testing as the procedure for getting permission to add the features I want to add. Normally you'd get permission from a producer or a lead to put what you want into the game, but in casual game development like ours, it's solo development. The ones you get permission from are the players, and the procedure for that is A/B testing. If you think of it as a survey asking players what they like, you end up lost in a maze of "what do I even want to make?"

As I've said a few times, A/B testing in games may have the trappings of science, but it isn't science. The same test run next week might give the opposite result, and you can't extract universal knowledge from it. It often makes you aware of your own self-indulgence, and you learn a great deal, but I still want to hold on, to some extent, to the principle of giving players what you want to make and think is fun. Maybe I'm just old-fashioned.

By the way, I've moved topics that strayed too far from the main subject or got too detailed into an appendix at the end. With the appendix, it gets even longer. My sincere apologies.

Appendix

The Firebase China problem

Firebase is quite a hassle to set up, so I'd rather not use it if I can avoid it, but there's a bigger problem: it may not work in China. It's a Google service, so it may be caught by China's network restrictions and be inaccessible. Whether it currently works, and which parts work, is unclear. But running something whose behavior is uncertain is a risk, so when the country is identified as China (I currently get the country from the MAX SDK), I skip initializing Firebase and run dummy code instead.

In other words, I can't get data from players in China, one of the biggest markets in the world. That's a shame. I don't know whether something like Unity Analytics would work there, but if there's another way, I think it's worth considering. This was also the main reason I once tried collecting data with Adjust and handling storage and aggregation in-house.

By the way, here's what makes Firebase a hassle: I get the impression the Firebase SDK has quite a few bugs and causes trouble fairly often; it adds quite a bit to the download size; there's a fair amount of in-house paperwork; and among the files it imports into Unity, there's one over 100 MB that makes pushes to GitHub fail unless you delete it, which gets tedious.

Metrics in the ad revenue model

For a game with in-app purchases, it's fairly certain that the group with the larger purchase amount brings in more profit. I've never worked on a product built mainly around in-app purchases, though, so this is only a guess.

But with ad revenue, things get murky.

In an A/B test, it's important that the groups are independent and don't affect each other. If a change made to group A can affect group B's numbers in any way at all, the A/B test's preconditions no longer hold.

That's why I made "players don't interact with each other" a precondition, but with ad revenue, the groups may affect each other even when that condition is met.

How much ad revenue we get is decided somewhere completely outside our control, so I can only guess at the mechanism, but fundamentally, we earn ad revenue because the ads shown in our game produced results, right? "Results" would be things like a player clicking an ad and then installing some app or buying something. Old TV ads probably couldn't measure results, but now information like "a person who saw this ad installed the app" accumulates on the ad network's servers, so it's natural to guess that the revenue amount is determined by results. You can imagine that what advertisers pay to show ads in our game, which is the source of our revenue, is strongly influenced by how many results the ads shown in our game have produced in the past.

By this logic, if improving the game led to more people installing apps or buying things via ads, revenue would go up. What matters isn't the number of ad impressions but the value of the results. Even if impressions go up, if nobody clicks the ads, the revenue per ad might be cut later, leaving profit unchanged. Currently it seems revenue is earned the moment an ad is shown, but I'd guess the amount is calculated from past results. If useless ads, that is, ads that don't get clicked, increase, the revenue per ad will presumably be cut later to balance things out.

In other words, even if you keep running A/B tests with revenue as the metric and keep improving, there's no guarantee that actual profit increases. It also means there's no guarantee in the first place that revenue goes up when the game gets more fun.

In practice the problem is even more serious. As I've already said, revenue normally can't be used as the metric, because its variance is so large that you need a huge number of people. You end up using a metric based on the number of ads, but there's no guarantee that more ads mean more revenue. The case for it being a valid metric gets weaker and weaker.

In fact, when I tracked individual players' data, I saw a pattern where the ad revenue for the 2nd ad was lower than for the 1st, the 3rd lower than the 2nd, and so on, getting lower and lower. Whether that's true in every case needs further investigation, but if a decision like "this person doesn't click, so let's lower the amount" is made per individual, that sort of thing could happen. In that case, using the average number of ads as the metric becomes quite problematic.

For example, consider one group with two people who each saw 2 ads, and another with one person who saw 1 and one who saw 3. If the revenue for the 3rd ad is very low, both groups average 2 ads, but the group where both people saw 2 ads should have higher revenue. As a result, the average revenue per ad differs between groups, and the premise that "a higher average number of ads is better" falls apart.

Following this line of thought, what to use as the metric for A/B tests turns out to be a very hard question, and it leads to the question of why we're doing A/B tests in the first place.

This is a very extreme hypothetical, but something like "we showed an insane number of ads, play time went down and launches went down, but ad revenue went up and profit increased, perhaps because people got fed up and one after another installed other apps from the ads and started playing those" isn't logically impossible.

What to use as the metric for A/B tests is, you could say, still an open question. If you know a good approach, please tell me (Twitter).

An attempt to collect data with Adjust + our own server

Firebase is fairly tedious to set up, and as I mentioned, it can't get data in China.

So I considered collecting the data ourselves, using a feature that comes with Adjust's event sending, which I mentioned before: it can send the same data to your own server at the same time.

I asked the server folks and tried it out a little, but for now there are two concerns.

One is money. When you release an ad-monetized casual game worldwide, most downloads come from emerging countries. In those countries, the profit per person can easily be around 0.1 yen, so even 0.01 yen per person in server costs feels expensive. Including things like the cost of renting machines for the database, you'd want it to be about a tenth of that again. Can a server you run yourself really operate at that kind of cost?

The server's capacity is also a problem. The data collected easily exceeds 20 GB or so a day, so you need storage and a database that can handle it, and when aggregating, the time spent waiting on SQL becomes a problem too. With BigQuery, you rarely wait a minute, but can something you set up yourself deliver that performance when reading hundreds of GB? They set up Redash for me, a browser-based environment for writing SQL and working with the results, but even aggregating a product that hadn't grown yet meant waiting minutes, so if it stayed that slow, it looked like it would be painful in practice.

It might be possible to go Adjust to our server, then our server to BigQuery, cutting out only Firebase in the middle, but I haven't even looked into that yet.

What BigQuery costs

When you rely on an outside service, the worry is money. I don't pay much attention to costs, so I don't really know, but our company has two apps in the 100-million-download class, and using it for those hasn't been a problem, so I think it's probably fine? I believe we set it up to send an email if we spend more than 30,000 yen a month, but I don't think one has ever arrived.

However, with Park Master, running SQL against the raw data (the data as it came from Firebase) every time started to get pretty dicey, so I used the daily scheduled query feature to build a separate table containing only the data I needed. When you run SQL, BigQuery shows something like "this query will process xx GB," and with a hit game, if you don't do anything clever, it quickly reaches 500 GB or 1 TB. At that scale it seems to cost quite a bit too.

Stored data also costs money, so it's good to set tables to expire after a certain time. For the ad-monetized casual games we make, I think if you keep 90 days, you'll almost never need older data. If you want to track long-term trends, one approach would be to automatically run SQL every day that extracts only the data you need and appends it to a small table. Later on, it might be nice to have long-term records of how things changed over time, like the number of installs on a given day, or how many levels players who started on a given day eventually played.

Years from now, graphing the trend since the app's release might be quite moving. Then again, we haven't yet experienced years going by, and honestly, every day we have more pressing things to worry about.

A future where AI runs your A/B tests

In the past I tried something called GameTune. GameTune was in public beta at the time and may be completely different now, so I won't discuss it as such. But it got me thinking about what A/B testing might look like in the future.

With A/B testing, if you have enough people, you can say "this one is better," but there are surely players who prefer the losing variant, right? Applying the winner to everyone is, how should I put it, a blunt instrument. It might be better to choose features at a finer grain. Old Final Fantasy games let you change the color of the UI, and for UI, surely that kind of freedom is fine, right?

But making every element where tastes probably differ customizable is a pain in its own way. First, the scope grows, and implementation and testing costs go up. And for players who find the very existence of such options a nuisance, they get in the way of the game. I once had "a vibration on/off toggle button on screen" lose an A/B test, so I'm careful about adding elements to the screen. Being able to choose isn't necessarily a good thing. In Mannequin Downhill too, I removed the retry button and indicators like "Level 5" from level 1, leaving no UI on screen at all. I think first-timers can concentrate better that way, and it's like that because it won the A/B test.

Come to think of it, with difficulty selection, which is common these days, there are definitely players who think "I don't want to pick Easy because it feels like admitting defeat. But Normal was too hard, so I quit." If you could somehow identify such players and quietly put them on Easy, they might be happier.

And AI may make that possible. Based on all sorts of attribute data, the AI says "this player should get Easy," and the game switches the difficulty. Simply implementing that in an app was possible even in the old days, but by combining it with behavioral data collection and evaluation by a metric, the AI can work out on its own things like "there's a 95% probability that giving Easy to players with this attribute is better," see how things went when it actually gave them Easy, and use that in its next decision about other players. We've entered an era where that kind of thing is possible.

What's more, if you leave that system running, it can adapt automatically as players' tastes change over time. With ordinary A/B testing, you sometimes make a snap decision based on a test result at one point in time, leave it at that, and players' tastes drift until it no longer fits; this approach should solve that problem.

That said, I can't really say when it will become practical. There's also the question of price: it has to cost less than the profit it adds. Also, in the end I think it's best suited to tuning numbers, so it'll be hard to use without a way to tune continuous values. Something like "it chooses between Easy, Normal and Hard" means you have to implement three versions, Easy, Normal and Hard, which is a lot of work. If anything, I'd want tuning like "lower the enemy's HP to 94%," but with an interface of "choose from prepared options," it comes down to preparing 100 steps from 50% in 1% increments and having the AI choose. But with lots of options, the decisions probably won't work well. The more A/B test groups you have, the fewer people per group, so the t-test gets harder to settle. I think the same thing would happen here.

AI has evolved amazingly in the last few years, so maybe it's practical now. If anyone knows about this, please tell me.

iOS players and Android players

I wrote above that I basically run A/B tests on Android. But if there's a big difference between iOS players and Android players, applying Android results to iOS is too crude.

That said, once you start down that road, results for players in the US alone and in Mexico alone would differ too, and so would results for players with high-end and low-end devices.

You might be able to raise player satisfaction by fine-tuning behavior to subtle differences in conditions, but the problem is effort. Analysis takes effort, the implementation takes effort, and testing takes effort. So it comes down to how much you're willing to put up with.

For now, having different behavior on iOS and Android means only two variants, and whenever I update either, I test on devices for each anyway, so it doesn't add that much extra work. If tests show different results on Android and iOS, it might be worth considering.

Below I'll cover some areas where iOS and Android differ in particular.

Frame rate

Even for a product whose 10th percentile is around 20 fps on Android, the 10th percentile on iOS normally exceeds 50 fps. The performance is in a different league. High-end Android devices are fast too, but a large share of devices are slow.

So if you lower the rendering resolution to suit low-end Android devices, it'll probably be too low on iOS. That's why most of the products I've worked on measure the frame rate automatically and adjust the resolution, shadow quality, anti-aliasing and so on, but on first launch things look blurry for a while, so it isn't perfect.

By the way, in the old days we made prototypes on iOS first, and sometimes a game that ran fine on iOS had a painful frame rate when we brought it to Android. On the GPU side you can compensate with resolution, but on the CPU side there's nothing you can do. Now we develop on Android first, so this is less likely to happen. Conversely, there are probably many cases where things could be made more lavish on iOS.

Vibration

Newer iPhones have advanced haptics that give a crisp "tock"-like feel, similar to the Nintendo Switch.

But Android devices are all over the place, and cheap ones only have the old-fashioned "bzzzzz" kind.

So my impression is that adding vibration to make the game feel more immersive has almost no effect on Android. There are probably plenty of devices where vibration helps, but there are so many where it's better without that they cancel each other out, and the test shows no difference. And there's also the question of which model to tune it to feel good on, so you can't polish it very far.

So it might be worth running vibration tests on iOS too and looking at the iOS results on their own. On iOS, good haptics work on most devices, so if vibration helps, it should show clearly. If it wins there, turning vibration on for iOS only seems fine.

A caution about data transfer from Firebase to BigQuery

As an app grows, the data transfer from Firebase to BigQuery can run into trouble, so I'll write a little about it.

If you enable "streaming" in the export settings, data flows into BigQuery continuously, so you can see the data a few minutes after testing on your own device, which is handy. This data is stored in temporary tables with "intraday" in their names.

If you also enable the "daily" setting, these temporary tables get moved into permanent tables that no longer change. This move is where the problem lies: if it hits a capacity limit, data disappears. You end up with a table containing only part of the data, and the original temporary table is deleted.

Apparently you can raise this limit by paying, but we don't. Instead, we turn off "daily" in the export settings and leave the data in the temporary tables.

The temporary tables contain duplicates and gaps and aren't in chronological order, but my impression is that it's no problem as long as you use distinct in your SQL to remove duplicates and accept that some data may be missing.

The details are here.

  1. In reality, there are clinical trials that aren't randomized double-blind trials, and a trial isn't unscientific just because it isn't a randomized double-blind trial. ↩
  2. Annual Review of Public Health Vol. 23:151-169, for example. ↩