Ah cool! Yeah it looks like there's nothing much of interest going on there.
This looks like it might be looking for a free spot
in the inventory (which is pretty small, just B places).
Yeah, the game only lets you carry 4 Candies, and if this trace is used for other items as well it makes sense for B to be a maximum because the number of items you can carry of each type varies, and I don't think it ever goes past 11.
The $652E branch. Which is an alternative loop to the
earlier one. Different kind of item?
Hm, I'll look into this.
On another note, I left the fixed lua script running overnight. After 154620 trials (attempts on 154620 consecutive frames), the same chest gave me a rare item 16993 times, which is very close to 11%.
However, the length of time it takes in between opening the chest and determining what item you get varies depending on which frame you open the chest. Because of this, I'm wondering if this has skewed my results.
For example:
Frame 1000: Hit B to start opening
Frame 1001: Save state
Frame 1013: Get a common item, reload state
Frame 1001: Hit B to start opening
[this time it only takes 12 frames]
Frame 1013: Get a common item.
It's hard to say without understanding how the RNG affects drops whether this is giving me a "unique" copy of a common item, or the "same" one. If it gave me a rare on the same frame, it's still inconclusive because it doesn't rule out the above scenario if / when it occurs.