I have a match-3 mobile game, similar to these popular games in the store. Mechanics are different, but the gameplay stays the same:

  • NxN board
  • X moves
  • Y objectives to complete to win
  • tons of different levels. When you complete a level, you unlock a new one

When you run out of moves, you have to buy moves or try again, so you have to think on each move.

And the problem is in the moves, I'm trying to calculate the amount of moves required for each level. I want it to be be slightly lower than the average, so it takes 3-4 attempts for an average player to complete.

I discovered that "being stuck" 2 or 3 times on a level makes it a lot more fun, than completing levels each time with a single attempt.

My current solution

I have couple hundred players and with them - some statistics. With each level attempt (lost or won) I save it on my server to use it for calculations:

ID | Level Number | Used Moves | Lost/Won

Then, each week, I compute a sum of attempts on each level, and I do this for all players. Then, I compute a mean average on each level:

avg_lvl_attempts = sum_level_attempts / player_count

So if 3 people took level 10, all of them with 4 attempts, it would be:

avg = (4 + 4 + 4) / 3 = 4

Which means that it takes the players 4 attempts, on average, to complete level 10. Then, based on that, I increase the amount of moves on level 10 by a small amount, so it's a little bit easier for them (because I want to achieve 3 on average). And I do that for each level.

The problem with that solution is that it can produce strange results, for instance if someone had 130 attempts (it happens sometimes).

The question

Is there any algorithm, or mathematical trick to do these kind of things more accurately, like excluding edge cases etc?

  • \$\begingroup\$ This sounds like the statistical practice of excluding outliers. Have you tried applying some of the standard outlier detection approaches described on the Wikipedia page? If they're not working for your needs, then you might want to consult a statistician on the statistics StackExchange, Cross Validated. \$\endgroup\$
    – DMGregory
    May 20, 2019 at 12:13
  • \$\begingroup\$ Can you compute, instead of a simple average, the histogram of attempts? If you obtain a bimodal distribution, then it can be easy to decide where to put the cutoff between "normal players" and "extraordinary players" who attempt much more than usual. \$\endgroup\$
    – Turms
    May 20, 2019 at 13:58

1 Answer 1


I wrote a comment but I think it needs some pictures to be explained, so I'm writing an answer.

Let's say you have an array of attemps, entry i is the number of attempts of players i for a certain level: level_1_attempts = [3, 4, 10, 180, 13, 4, 5, ...]

You can compute an histogram of these attempts. That is, you count how many players attempted 1 times, how many attempted 2 times, and so on.

Then, you can visualize such histogram using some software (python with the matplotlib module, for example). What you see will help you deciding how to modify the number of moves of your level. Let's consider an example of what you could observe:

enter image description here In this case, you can clearly see that there are two populations of players. One is attempting 'normally' a few times (less than 10) and then succeeds. The other population is extermely bad at playing and needs 180 attempts. Since the latter population is very small, you want to exclude those from your statistics (pink lines). It might be useful to use log-log scale or semilog, in your case, especially if you observe some very high values.

Of course, it could be much more complicated than that, for example if you have a somewhat flat distribution that does not have a clear mean. One needs to observe the data and take a decision. The histogram is a great way to do that.


This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .