**How to get a high score in Robot Unicorn Attack (RUA)!**

I’m sure most of you have heard of this game before (it has 32,000,000 plays on the adultswim website). In case not, try it out: Link to heavy metal version. Link to original version.

**Rules of the Game:**

In this post I just want to look at how the scoring works, and we’ll see that you can use elementary mathematics to figure out near optimal strategies to take in order to achieve high scores. Playing RUA is extremely simple. Just use the “Z” and “X” keys. The “Z” key allows you to jump, and the “X” key allows you to dash. If you crash, then your run is over — you get a total of 3 runs/lives (aka wishes). Your final score is the sum of the scores of your three runs. Regarding jumping, you can initially do two jumps (one in midair) and can gain an extra jump if you dash while in the air. The longer you hold “Z”, the bigger the jump is.

**Scoring Points:**

Basically, the points work as follows:

- over time, you automatically accumulate points
- collect fairies for points
- dash through stars for points

In order to do some sort of analysis, we need to know how many points we get over time, how many points stars are worth, and how many points fairies provide. Rather than ask the developers of the game, let’s do some * science*, bitches!

**Over Time Points:**

After recording a 2 minute trial run I was able to keep track of how many points I received per second of game play. I paused at certain times to record how many points I received in total, and kept track of the points from fairies and stars as well. I did 10 test points during the 2 minute run, summarized below:

Real time elapsed (in seconds) |
Total Score at time t |
Score from fairies/stars |
Score accumulated over time (Col2-Col3) |
Number of points/second |

13 | 1358 | 160 | 1198 | 92 |

26 | 4950 | 1800 | 3150 | 121 |

35 | 8546 | 3940 | 4516 | 130 |

51 | 22296 | 14100 | 8196 | 160 |

55 | 26622 | 17600 | 9022 | 164 |

62 | 32576 | 21600 | 10976 | 177 |

75 | 38632 | 23460 | 15172 | 203 |

88 | 48956 | 29260 | 19696 | 223 |

105 | 75368 | 49000 | 26368 | 251 |

120 | 88292 | 54560 | 33732 | 280 |

Notice that as time passes, the number of points we get per second is increasing at a linear rate. This is because the game gets faster and faster as we get more points. What we want to compute is the number of points we would have after “t” seconds that come from time alone. Using the 10 data points labelled as (time, score accumulated over time) i.e. columns 1 and 4, then by using wolfram alpha we can get a least squares fit. Note that the quadratic least squares fit solution is:

**Total points after t seconds = 1.776 t^2 + 66 t + 107.**

This is formula is actually rather accurate and fits the trials I ran. After 30 seconds, we would have accumulated 3685.4 points due to time.

**Fairy Points:**

Fairy points work rather simply. For the first fairy you get 10 points. If you collect two fairies in a row, the second fairy gives 20 points. If you collect 3 fairies in a row, the third fairy gives 30 points. If you collect 4 fairies in a row, the fourth fairy gives you 40 points…. If you collect 12 fairies in a row, the 12th fairy gives you 120 points. If you happen to miss a fairy at any point, the counting starts over at 10 points.

As you can see, if you want to maximize your score by collecting fairies, it is crucial you collect every single one (and not miss any). If you collected 30 in row then the 31st fairy will be worth 310 points – but if you miss the 31st fairy then the next fairy starts over and is worth 10 points.

Let us assume you collected F fairies in a row and calculate the total number of points you have received after collecting those F fairies:

**Total points for collecting F fairies in a row = SUM (from i = 1 to F) 10*i**

= 5 F * (F+1)

= 5 F * (F+1)

This follows from the summation formula SUM(from i=1 to n) i = n * (n+1) / 2.

Now in order to get an accurate estimate on how many points we can expect from fairies, we need to know how many fairies appear in the game within the first “t” seconds. Running some simulations gives the following:

– after 2 seconds the 1st fairy appears

– after 6 seconds, the 2nd fairy appears

– after 7 seconds, the 3rd fairy appears

…

I kept track of when fairies appear for the first two minutes of a trial run. Putting the data into Matlab and finding the best fit gives the following:

**After “t” seconds, we see [0.0015 t^2 + 0.3914 t – 1.0274] fairies.**

Now, if we were to collect every single fairy, then after “t” seconds we should expect to have lots of points coming from the fairies. In particular, subbing in F=[0.0015 t^2 + 0.3914 t – 1.0274], the number of points that we would gain after t seconds from collecting all the fairies is:

**0.00001125 t^4 + 0.005871 t^3 + 0.758059 t^2 – 2.06424 t + 0.140754**

For example, after t=30seconds, we would have 788.096 points from collecting fairies (IF we collected ALL of them in a row). Comparing this with my simulation, after 30 seconds I would have collected 12 fairies, which gives a total of 10*13*12/2 = 780 points! The above formula is actually quite accurate.

**Star Points:**

Star points work the same as fairy points. For the first star you get 100 points. If you

collect two stars in a row, the second star gives 200 points. If you

collect 3 stars in a row, the third star gives 300 points. If you

collect 4 stars in a row, the fourth star gives you 400 points…. If

you collect 12 stars in a row, the 12th star gives you 1200 points. If

you happen to miss a star at any point, the counting starts over at 100

points.

Let us assume you collected S stars in a row and calculate the total

number of points you have received after collecting those S stars:

**Total points for collecting S stars in a row = SUM (from i = 1 to S) 100*i**

= 50 S * (S+1)

= 50 S * (S+1)

This follows from the summation formula used above.

One thing to note is that stars appear at a different rate than fairies. Thus, we need to figure out how many stars would appear after t seconds. Running some simulations gives the following:

– after 12 seconds the 1st star appears

– after 15 seconds, the 2nd star appears

– after 21 seconds, the 3rd star appears

…

I kept track of when stars appear for the first two minutes of a trial

run. Putting the data into Matlab and finding the best fit gives the

following:

**After “t” seconds, we see [0.0012 t^2 + 0.3299 t – 4.0277****] stars.**

Now, if we were to collect every single star, then after “t” seconds we

should expect to have TONS of points coming from the stars. In

particular, subbing in S=[0.0012 t^2 + 0.3299 t – 4.0277], the number of points that we would gain after t seconds from collecting all the stars is:

**0.000072 t^4 + 0.039588 t^3 + 5.01838 t^2 – 116.379 t + 609.7333**

For

example, after t=30 seconds, we would have 2762.1 points from

collecting stars (IF we collected ALL of them in a row). Comparing

this with my simulation, after 30 seconds I would have collected 12 stars, which gives a total of 100*8*7/2 = 2800 points, which is very close to my best fit equation above.

**Scoring Lots of Points:**

Let us combine what we know. Let’s assume we are a good enough player to last at least 30 seconds.

The table below gives us an idea of how many points we should expect from time elapse, collecting fairies, and collecting stars.

time elapsed (t) |
time points at time t |
fairy points at time t (from collecting all fairies): |
star points at time t (from collecting all stars): |
Total points: |

30.00 | 3,685.40 | 788.10 | 2,762.10 | 7,235.60 |

40.00 | 5,588.60 | 1,535.01 | 6,701.93 | 13,825.54 |

50.00 | 7,847.00 | 2,596.26 | 12,735.23 | 23,178.50 |

60.00 | 10,460.60 | 4,019.23 | 21,177.29 | 35,657.12 |

70.00 | 13,429.40 | 5,854.00 | 32,360.67 | 51,644.07 |

80.00 | 16,753.40 | 8,153.33 | 46,635.22 | 71,541.95 |

90.00 | 20,432.60 | 10,972.71 | 64,368.07 | 95,773.38 |

100.00 | 24,467.00 | 14,370.31 | 85,943.63 | 124,780.94 |

110.00 | 28,856.60 | 18,407.00 | 111,763.59 | 159,027.19 |

120.00 | 33,601.40 | 23,146.37 | 142,246.91 | 198,994.68 |

130.00 | 38,701.40 | 28,654.69 | 177,829.84 | 245,185.93 |

140.00 | 44,156.60 | 35,000.93 | 218,965.91 | 298,123.44 |

150.00 | 49,967.00 | 42,256.77 | 266,125.93 | 358,349.70 |

160.00 | 56,132.60 | 50,496.59 | 319,797.99 | 426,427.18 |

170.00 | 62,653.40 | 59,797.46 | 380,487.45 | 502,938.31 |

180.00 | 69,529.40 | 70,239.16 | 448,716.96 | 588,485.52 |

By lasting for 180 seconds, you can earn about 70k points from time

alone, but by collecting every star you earn a whopping 450k points!! If

you were to focus on collecting fairies, you would earn 70k points for

collecting all of them in a row.

This means that if you lasted 180 seconds and collected every fairy and every star, you would end up with **588,485 points**!!

**Possible Strategies:**

- Collect every fairy and every star possible. Avoid crashing.
- Try

to avoid crashing and last as long as possible. Focus on gaining points

over time and ignore the fairies and stars (but dash through stars to

avoid crashing). - Collect every star that shows up. Ignore the fairies and avoid crashing.
- Collect every fairy that shows up. Dash through stars to avoid crashing but focus mainly on getting every fairy.

#1: Obviously the optimal strategy is #1, that is, to collect every single fairy, dash through every single star, and last as long as possible. But accomplishing this is quite the feat as it is very easy to miss fairies and stars. Also, focusing on fairies and stars can cause you to crash.

#2: Most people only last 1-2 minutes when trying to last as long as possible. Using this strategy is bad as if you were to (theoretically) avoid every fairy/star your score would be in column 2 of the table above.

#3 Collecting stars is an excellent strategy. As you can see, collecting every single star in a 2 minute run gives you 142k points. This is a massive score and would be considered one of the best scores for a single run in the entire world. The only problem is that the game is designed so that you can’t tell if the star will be on the top platform or the bottom platform before it’s too late, thus, it’s quite easy to miss some which resets the bonus counter. By collecting S stars in a row (see above) you gain a massive:

**50 S * (S+1) points!**

So collecting 10 stars in a row gives 5500 points, collecting 20 in a row gives 21,000 points, 30 in a row gives 46,500 points, 40 in a row gives 82,000 points, **50 in a row gives 127,500 points**.

#4: Focusing on fairies is a bad strategy. According to simulations, there is about 1.28 times more fairies than stars, but the amount of points you receive for collecting fairies is actually worse than the points you get from time alone. Collecting 50 fairies in a row gives 12,750 points – considerably lower than stars.

Note that in a typical game, you can expect to last from 1-2 minutes, see about 40-50 stars and about 60-70 fairies. Thus, the focus should be on collecting stars.

**Conclusion (to get high scores):**

- Collect stars.
- Ignore fairies.
- Avoid crashing.
- For maximum points you MUST collect as many stars as possible in a row. Missing a single star resets the bonus counter.

andermicWhen you are doing regression, it’s a good idea to remember that there are many different models (besides the quadratic ax^2 + bx + c) that you can consider trying. You may have wanted to include graphs of the original data beside your fitting functions, or maybe a sum of error statistic, which would’ve helped to show that you selected the correct model and not an overfitted or underfitted model. In particular, I noticed that many of the coefficients of your fitting functions are very close to zero, which is suspicious.