How does this work?

Well, in reading the

Party Mechanics Guide by Terence, on GameFAQs, you will find that the game increases HP and MP during each level up but there is a specific calculation that occurs. First, it is noted that there is a random element to the generated outcome. A random value 1 thru 8 is generated (for both HP and MP, but separately) and it is used in determining the outcome. Also, it is noted there that there is a "curve" system in the calculation so you are penalized later if you increase your HP or MP too fast and too early. It was because of this "curve" system that it was determined that there is a certain level for each character in which it was possible to NOT achieve the max HP or MP, this was referred to as the Safety Level. From that point on, you must consult the Safe Value Chart in order to verify whether your HP and MP values are safe. Then, later on, it was determined that during the 1-8 random number generation for both HP and MP, it is NOT possible for an 8 and 8 to result, meaning that you CANNOT max both HP and MP during the same level-up. Because of this, AbsoluteSteve included a new Safe Value Chart in his

Walkthrough Guide that combines both HP and MP values that are safe, since both HP and MP cannot be maxed independently.

So I came along and asked the question why an 8-8 scenario is impossible. I found out it was due to the way the game generates the random numbers for these stat upgrades. Apparently, there is a lookup table built into the game with 256 pre-defined values. A random number from 0 to 255 is then generated and it uses that to pick out a value from that lookup table and that number is used to calculate the 1 thru 8 value for each HP and MP, and no value in that lookup table generates a 8-8 case. In fact, neither does a 4-6 or 6-4 case. More over, it was found that the resulting outcomes are very oddly scattered and have ranging probabilities. Some cases hit 1/256 times, some cases hit 9/256 times. Here is the chart indicating the disparity of the chances of hitting:

| | | | | | **MP** |

| | **1** | **2** | **3** | **4** | **5** | **6** | **7** | **8** | **Tot** |

| **1** | 2 | 4 | 5 | 8 | 1 | 7 | 5 | 1 | 33 |

| **2** | 2 | 3 | 6 | 5 | 2 | 8 | 2 | 4 | 32 |

| **3** | 6 | 3 | 2 | 2 | 4 | 4 | 2 | 8 | 31 |

**HP** | **4** | 9 | 6 | 2 | 4 | 1 | 0 | 6 | 4 | 32 |

| **5** | 3 | 6 | 2 | 3 | 6 | 2 | 5 | 5 | 32 |

| **6** | 3 | 3 | 5 | 0 | 7 | 4 | 2 | 8 | 32 |

| **7** | 4 | 3 | 4 | 7 | 3 | 5 | 4 | 2 | 32 |

| **8** | 3 | 4 | 6 | 2 | 8 | 2 | 7 | 0 | 32 |

| **Tot** | 32 | 32 | 32 | 31 | 32 | 32 | 33 | 32 | 256 |

You will find it interesting also that if you look at the column and row totals, they are almost all exactly 32/256 chance, giving each independently the feeling that they are an even 1/8 chance. However, the combination of the two are horribly uneven. Once I found out about this uneven distribution, I realized that there must be a way to utilize these probabilities to your advantage, reducing the amount of resets needed to achieve the max stats. In my practice up to that point, I was finding myself struggling with Aeris on one level, I must've reset the console over 100 times. I ended up going back to an earlier save and getting a different value, and I was able to continue with about 20 resets instead. I later found out the scenario I was up against was a 2/256 chance the first time but 7/256 chance the second time after going down a better path.

The 2 things I needed to solve was:

- How do I accurately calculate the estimated number of resets required for each character?
- How do I figure out how to improve that?

The answer to those questions are surprisingly simple and very hard to poke holes at.

At first, I was relying on running simulations. I'd run 10,000 simulations of leveling up each level and comparing the resulting HP and MP to the Safe Value Chart, if it's not safe, try again, if it is safe, continue to the next level. I'd keep track of the total resets and at the end of the simulations I'd average it out. This was the first metric I was using to determine good vs bad paths. Two problems ensued, one, simulating takes a long time (about a minute) and must be done individually on each possible safe value (the whole safe value chart would take hours if not days to complete) and two, simulating could only simulate whether a value is safe or not, there was no good logic that I could use to tell it to reject a value.

I later found out that if you were to start at the bottom (Level 99) and work your way towards the beginning, adding up the resets thru each level. Assuming the max HP and MP at Level 99, there is only one possible value for Level 99. That value itself would of course be 0 resets because you're already there. From there you move to the previous level and find it's "parents". In this case, every character only has one Level 98 value as well, you'll also find that the value you need is a 8-7 case, which means the HP value and the second highest MP value. Looking that up in the chart, the odds of hitting that is 7/256. Doing a little bit of math, you can find the number of resets needed:

`probability = 7;`

resets = (256 / probability) - 1;

In this case the estimated resets is 35.57 resets. Why subtract 1 from the equation? Because a 256/256 chance should equal 0, also, we're counting resets, not trials.

Next we move to Level 97, and the levels after that, always looping thru all the safe values for that level and calculating the estimated resets and adding to the previous resets from the higher level. There will eventually be scenarios where there are multiple safe values as you move up this safe value tree. In this scenario, each combination should have an estimated reset count on them. The math should be the same except the the probability of hitting ANY of those values is simply by adding up each of the probabilities. Now, each of the safe values may all have different estimated resets, so which of them should be used to add to the resets for the parent? The answer is all of them, in fact, it's a weighted average based on the different probabilities of each value. After repeating this calculation up all the levels till you get to Level 1 (or Level 6 for Cloud), you will get your estimated resets, running a simulation at any level can confirm those numbers.

That's a long-winded way of explaining my simple answer to question 1 above, but more simply it's working backwards adding up the weighted averages of resets at each level.

So, how to improve on this?

After all, the goal is to BEAT that number. The goal is to mathematically put you in better position and probability to achieve the max stats. The answer on how to solve this is also simple. If you have 7 possible safe values, if you remove 1 of them, does the weighted average lower the estimated resets, or increase it? Keep in mind, when you remove a value, the chances of getting a safe value, of course, will reduce your probability of getting a safe value, but it's possible that the extra resets on this level might be worth it if it means saving you resets further down the road. In Highwind, values that cost you more resets are notated in RED, these should always be passed on, if a value costs you more resets but regarded as a lateral move (no gain), the value will be notated as YELLOW, meaning you could (although not recommended) accept the value, but know that it may cost you more down the road, the simulations can prove that. Also, YELLOW values should definitely be treated as RED values if you've already reset more times than the number indicated for that value when you hover your mouse over it. Lastly, values that are always good are notated as GREEN. Each value, in Highwind, will show you two reset values, the first value is if you follow GREEN values only, the second is if you accept ANY value. The overall calculated results are shown above in the previous post.

If anyone has any questions about the math or anything else, please ask away.