Monday, January 9, 2017

Dampé's Heart-Pounding Gravedigging Tour

Ah Dampé. What happened in your life that made you so cruel?

After hearing a lot of conflicting info about the guaranteed heart drop recently, I decided to open up Nemu and take a closer look into how things are working behind the scenes.



There are 8 actors that represent the 8 dig spots, and one Dampé. Actually, there are 11 visual dig spots, but the 3 double plots share the same marker actor and count as one each. Whenever you ask him to dig, he starts by performing two checks: whether he's actually standing on top of one of the marker actors, and whether you've already dug up that spot on that cycle around the graveyard. If either of these conditions fail, then Dampé will dig up nothing and steal your money. What a jerk.

If both checks pass, Dampé will dig up one of 4 prizes. The function which handles this is located at 80925FE8 on NTSC 1.0, or 801FC798 when entering Kakariko Graveyard from the Kakariko entrance. The base odds for each drop per dig are below:
  • Green Rupee (40%)
  • Blue Rupee (30%)
  • Red Rupee (20%)
  • Heart Piece or Purple Rupee (10%)
To make the minigame less luck based (heh), there are an additional set of rules that will guarantee a heart piece drop. These rules reset whenever Dampé is unloaded, or the grand prize is won.
  • If you roll a red rupee drop, and have already dug up two of them this game, the rupee drop will be converted to a green rupee drop
  • If you roll a blue rupee drop, and have already dug up four of them this game, the rupee drop will be converted to a green rupee drop
  • If you are getting a green rupee drop, and have already dug up eight this game, you will always get the Heart Piece or Purple Rupee
This means that the rule will begin to kick in starting with the 9th dig, and that at most it will take 15 digs to obtain that heart piece.

Since I was curious to figure out the odds, I wrote a program that simulates all 16,607,566 variations of Dampé's tours. The results were confirmed by Ecksters, who wrote their own Monte Carlo style simulator. Ecksters also created this nifty chart:
The source for my program can be found here. The actual raw numbers are below.

Dig:   Cumulative    :    Individual    :  Rule Cumulative : Rule Individual
01: 0.10000000000000 : 0.10000000000000 : 0.00000000000000 : 0.00000000000000
02: 0.19000000000000 : 0.09000000000000 : 0.00000000000000 : 0.00000000000000
03: 0.27100000000000 : 0.08100000000000 : 0.00000000000000 : 0.00000000000000
04: 0.34390000000000 : 0.07290000000000 : 0.00000000000000 : 0.00000000000000
05: 0.40951000000000 : 0.06561000000000 : 0.00000000000000 : 0.00000000000000
06: 0.46855900000000 : 0.05904900000000 : 0.00000000000000 : 0.00000000000000
07: 0.52170310000000 : 0.05314410000000 : 0.00000000000000 : 0.00000000000000
08: 0.56953279000000 : 0.04782969000000 : 0.00000000000000 : 0.00000000000000
09: 0.61284165500000 : 0.04330886500000 : 0.00026214400000 : 0.00026214400000
10: 0.65273713750000 : 0.03989548250000 : 0.00144179200000 : 0.00117964800000
11: 0.69319116775000 : 0.04045403025000 : 0.00716953600000 : 0.00572774400000
12: 0.73810220009500 : 0.04491103234500 : 0.02139968512000 : 0.01423014912000
13: 0.79444816181740 : 0.05634596172240 : 0.05155586685190 : 0.03015618173190
14: 0.86102179338340 : 0.06657363156600 : 0.09757431459964 : 0.04601844774774
15: 1.00000000000000 : 0.13897820661660 : 0.22265470055458 : 0.12508038595494
I won 16607566 times. Guaranteed Drop hit 11071711 times
Guaranteed Rule Odds 0.222654700554580

As a final note, there is an amusing oddity with how the base drop table was implemented. To compute what drop to give, the devs generate a random floating point number between 0 and 1, then compare it to see if it's less than 0.4 (green rupee), 0.7 (blue rupee), and lastly 0.9 (red rupee). The weird thing is that the 0.4 is stored as a constant floating point type, whereas the 0.7 and 0.9 are double precision floats.

Edit: Another amusing thing that most people probably don't know is that the heart piece itself can be skipped permanently. On digging up the heart piece, Dampé sets a permanent flag that  changes the "grand prize" drop to a purple rupee.

2 comments:

  1. Is there a chance of getting a purple rupee before Dampe digs the heart piece?

    ReplyDelete