In Part 1 we talk about how to estimate the score of your game based on a single snapshot. However, we hadn't yet corrected for the fact that 4's sometimes spawn. So, to compensate for the number of 4's that spawn, we need to know how often they spawn! The online, open-source version has a 10\% chance of spawning a 4, but based on nearly 38,000 (No, I didn't count them all, I'll show you how I came about this in a little bit.) spawns on my iPhone app version, there is about a 15.3\% chance that a 4 will spawn (leading me to believe that it's supposed to be a 15\% chance).
With that in mind, we need to have an estimate for the total number of tiles spawned. And under our old assumption (that only 2's spawn), we can compute that very easily. Consider the following. Every 2 tile that spawns counts as a spawn. Therefore, every 4 tile that we have is really two total tiles that spawned (the two 2 tiles). The 8's are 4 spawns (two 4 tiles each with two 2 tiles spawning). It doesn't take long to figure out that each tiles has
c_a = a/2
where a is the face value of the tile. Thus we just sum this for each of the 16 tiles on the board and we have a good estimate for the number of total tiles that spawned, C_e
C_e = \sum_{16\;Tiles}c_a
Well, we just assumed that all the spawns were number 2 tiles. To compensate for the fact that 4 tiles can spawn at a probability of p_4 we know the following two relationships:
p_4 = \frac{C_4}{C_a}
C_a = C_e - C_4
where C_4, C_a, and C_e are the number of 4 tiles spawned, the actual number of total tiles spawned, and the estimated total tiles spawned, respectively. The first relationship is fairly straight forward; it's how the probability of a four-spawn is defined. However, the second relationship involves a little more thought. We guessed, based on only 2 tiles spawning that there are C_e total spawns. If we actually know that there are C_4 four-spawns, then we have to account for the number of two-spawns that would've smashed into these 4's. So, since there are two 2's that make a 4 we have C_2 = C_e - 2C_4 two-spawns. To get the actual number of spawns we add the two-spawns to the four-spawns
C_a = C_2 + C_4 = (C_e - 2C_4) + C_4 = C_e - C_4
Plugging the second equation into the first and solving for C_4 we find out that
C_4 = \frac{p_4C_e}{1+p_4}
Lastly, since each of these 4's that spawned does not give us 4 points (we assumed we got the points for all 4 tiles), our expected score (S_x) is the estimate score (S_e) minus four times the number of 4's that spawned:
S_x = S_e - 4C_4 = S_e - 4\frac{p_4C_e}{1+p_4}
Since we know p_4 and we know how to find S_e (See Part 1) and C_e, we can compute our expected score. I played approximately 30 games with this and the average relative error for these guesses is about 0.2\%. The results were even better once you scored above 10,000. Only averaging the games with scores higher than 10,000 (which was all but four of them), the average relative error was about 0.1\%. Pretty cool results!
I said I would tell you how I came about the probability of a four-spawn of 15.3\%. So I played a bunch of games and compared the actual score of the game to what I estimated it would be if there were only 2 tiles that spawned. The difference between these two divided by four is the actual number of 4 tiles that spawned. With that I used the two equations above and calculated what p_4 was!
There are a few more questions about 2048 that I still have. What is the highest score one can get? What is the lowest score? These questions (and others if I think of more) will be discussed in Part 3.
No comments:
Post a Comment