I don't want to admit how long it took me to figure that out.
I also think I've figured out what's causing playerLevel to start out at minus two billion, even though I know by math that it's supposed to start out at zero. See, the exact player level on a new game is -2,147,483,648. Recognize that number? Yup, it's -231, the lowest number that can be displayed in 32-bit number-crunching. I wanted "XP to next level" to always be twice what it was the last level - which is given by the function:
[LEVEL] = log2(([XP] + 1) / 2) +1
At zero XP, then, you're level zero, because log2 of 1/2 is -1 (and then add one to make it zero). Take one action, and BAM, you're level one. Two more actions and you're level two, and so on and so forth. For some reason, though - probably because of how the logarithm function works under the hood - it's making it (for all intents and purposes) negative infinity. This could be caused by the fact that I'm calculating the binary logarithm as "log2n = log10n / log102," which is mathematically correct but might be causing the 'puter to throw a fit. Hmm.Anyway, that's a headache for another day. Here's the Hula beta, source code below the jump. Also, I learned how to make the binary logarithm function here on Stack Overflow, since Microsoft decided to excise it from cmath. Because who would ever want to take a binary logarithm of something? Huge dorks and lesser dweebs1, that's who.
Notes:
1. I swear by the stars that I got this from Strong Bad, but I can't find it right now.