Thursday, February 23, 2017

How small can you store Pokemon EVs?

How many permutations can Pokemon EVs have, and how small can you store them?
There are 6 stats (hp, atk, spatk, def, spdef, spe), each of which have the range of 0-252

There is a maximum of 510 points to be used for all the stats, so that would dramatically lower the amount of permutations.

If we didn't have this limit, it would be easy to figure out how many permutations EVs would make.
253^6 or 253x253x253x253x253x253
Which would be: 262254607552729

I had no idea how i could calculate in the strange limit of 510 points, and couldn't really find much answers.
So i instead just brute forced it and got: 10362121
That's a dramatic difference, and would definitely well translate to storage.

I find that it fits within 3 bytes.
24-bits or 3 bytes = 16777216
That means we save three bytes compared to how EVs are regularly stored, which is 6 bytes for each stat.

Loading it now becomes another problem. The data is now numbered by what permutation it is and you can no longer find out what stat spread you have without some brute force matching.

We could use a look-up table that stores each combination.

10362121*6
(number of indexes) * (the 6 bytes for each stat)
Which is:
62172726 bytes
60715.5 kilobytes
59.2 megabytes

(Not even counting pointers!)

Needless to say, the trade-off is probably not worth it.

No comments:

Post a Comment