Read this first! > FAQs and Tutorials

Helpful Charts by DynamixDJ

<< < (2/8) > >>

nfitc1:
Ooh, MATH! THIS I can do.

Based on my analysis of the code, it will first calculate whether or not a "special battle" will occur out of a chance of 64. Failing this it will pick from the remaining groups out of a new 64 chance.


--- Code: ---ENC_VALUE = [0..63]
For x = 0 to 3
   if (special_battle(x).chance < ENC_VALUE )
      return special_battle(x)
   endif
Next x
ENC_VALUE = [0...63]
For x = 0 to 5
   if ( battle(x).chance < ENC_VALUE )
      return battle(x)
   endif
Next x

--- End code ---
(If nothing gets returned it does the calculation again)

Let's take your base formation group as the example:

--- Quote ---Encounter 1 = 800   Exp, enc 22 (Normal Battle)
Encounter 2 = 1000 Exp, enc 21 (Normal Battle)
Encounter 3 = 1700 Exp, enc 21 (Normal Battle)
Encounter 4 = 650   Exp, enc 8   (Special Battle)
Encounter 5 = 4000 Exp, enc 2   (Special Battle)
--- End quote ---

Then what we have is this:

( (650 * ( 8 / 10) ) + (4000 * ( 2 / 10 ) ) ) * (10 / 64) + ( (800 * (22 / 64) ) + (1000 * (21 / 64) ) + (1700 * (21 / 64 ) ) * ( 54 / 64 )
( 650 * .8 + 4000 * .2 ) * .15625 + ( ( 800 * 0.34375 ) + ( 1000 * 0.328125 ) + ( 1700 * 0.328125 ) ) * 0.84375
( 520 + 800 ) * .15625 + ( 275 + 328.125 + 557.8125 ) * 0.84375
1320 * .15625 + 1160.9375 * 0.84375
206.25 + 979.541015625 = 1185.791015625

Rationale:
Since we have two groups of battles (blue are considered first) then we can calculate the average of them individually based on their weights. These are the bolded values on line 4. Since there is an unequal chance of these occurring we can't just add them and divide by two. We have to treat them as weighted values as well. This will become:

(weighted average of each special battle encounter) * (total special encounter rate / 64) + ( weighted average of each regular battle encounter ) * ( [ 64 - total special encounter rate] / 64 )

HOWEVER! This is not entirely the correct answer. It's CLOSE and ideal, but randomly generated numbers do not have a uniform distribution. Based on a few simulations I ran (10000 encounters with this encounter rate) the average was a little off (I'll get to that momentarily). This, of course, assumes the world map and the field share identical scene choosing methods: choose special encounters first then normal. Using the same RNLUT that the field uses I got an entirely different result. Go figure. Here's what I got:

Calculated average: 1185
World Map simulated average: ~1171
Field simulated average: ~1160

So why are the simulations and calculation so different?
Calculations: This is based on the assumption that all values have a likely chance of being used. The first value that is selected is the special battle encounter chance. This may or may not do anything to the average so a new value gets chosen. This happens roughly 54 out of 64 times for the above example. We then have a NEW percentage of chances for the remaining normal battles.
World Map: The world map has no RNLUT so it uses system RNG calls. This has the effect of the Normal Distribution mentioned above. This is just the way computers work. So, the middle percentages of each step have a slightly higher probability of being chosen. This takes some statistics explaining to account for, but I won't bore you all with the details. Suffice to say, this is pretty accurate to our calculation when considering this effect of randomly generated numbers.
Field: This uses the infamous RNLUT which attempts to prevent the normal distribution problem. Assuming there are no random values flying around outside of battle choosing, this will be the effect. We'll get an even distribution of 0s to 32s which we don't typically find in straight system RNG calls. But we're not calling them at the same rate. Since we sometimes get one and sometimes get two, the results get skewed a bit. Within 10000 runs, the formations each got called the following number of times:

--- Code: ---special 1: 1497
special 2: 214
normal 1: 2570
normal 2: 2858
normal 3: 2862
--- End code ---
From this we can see that the special 1 : special 2 ratio is not the 8 : 2 that our example table uses. Nor is the normal1 : normal 2 : normal 3 close to 22:21:21. If anything it's more like 20:22:22. Basically, the RNLUT doesn't solve the Normal Distribution issue either.

So it's up to you how you want to report it. The World Map average is about 98.8% of the calculated value and the Field is 97.9%. You can express the calculated as the "ideal, yet impossible average per battle" which will scale properly per area and still give a good indication of how good an area is on giving exp per formation. i.e. One area might have a calculated average per battle of 1580 and the world map equivalent would be 1564, but another area calculated at 1600 won't actually be 1550 or so.

DynamixDJ:
Hahaha that was a powerful Summon! You may now return to wherever it is that Summons go when their animations have finished playing, somewhere in the battle folder I assume!

I just about understand the maths behind all of this, and I'm thinking damn! That's a lot of maths to do for each area! I might have a fiddle with Microsoft Excel to input the formula's in that way. There is one small discrepancy with your calculations however:

( (650 * ( 8 / 10) ) + (4000 * ( 2 / 10 ) ) ) * (10 / 64) + ( (800 * (22 / 64) ) + (1000 * (21 / 64) ) + (1700 * (21 / 64 ) ) * ( 54 / 64 )

See the bit in bold? This bit I'm not getting. The sum of all the normal battle encounter rates is 64, not 54... Have you made a mistake, or am I not seeing it right?

Also, in regards to the World Maps, i know that the encounter chance doesn't work in the same way for the World Map as it does for the Field Map; the field map will do one check for the special battles, considering the encounter values for all of the Special battles, combined, and then move onto the normal battles. However, on the World Map, a check is performed for each individual battle slot, of which there are 4. So in the example used, the first check will be an 8/64 for spcl battle 1, then the 2nd check occurs which is 2/64, and then the normal battle check. All of this occurs after the Mystery Ninja check, and then the Chocobo Battle chance, which I'm not even considering into the equation, for obvious reasons.

Anyway, do you suspect that the variation in the way in which special battles are treated are the cause of the differentiation between World and Field Maps in the projected averages?

nfitc1:

--- Quote from: DynamixDJ on 2016-04-13 03:09:10 ---Hahaha that was a powerful Summon! You may now return to wherever it is that Summons go when their animations have finished playing, somewhere in the battle folder I assume!
--- End quote ---
You can't contain me!!!


--- Quote ---Have you made a mistake,
--- End quote ---
How dare you! I never usually get something correct on the first pass of a problem; But I'm actually good at math and don't often make mistakes.


--- Quote ---or am I not seeing it right?
--- End quote ---
This. And I figured as much, but I thought I'd let you mull it over for a while and decide whether or not you wanted to know WHY that's the case. Aren't I nice? :)
See, at the beginning a random number capped at 63 ([0..63]) will be generated and, in this case, the special formations have a 10 in 64 chance of appearing as you did notice is the total of their encounter rates. If no special formations are selected another [0..63] will be "rolled" and the normal battles will be chosen from that. Since this leaves only 10 values in the first role for the special formations, then that must mean the remaining 54 values will yield normal battles. OF THOSE normal battles, 22 will yield the first formation, 21 will yield the second, and 21 will yield the third. That's a separate 64 chance selection as indicated by multiplying the actual experience values by ( x / 64 ). Even if they don't total up to 64 the chance is still x / 64 for that formation and a ( 64 - x ) / 64 chance for it to NOT be chosen.



--- Quote ---Also, in regards to the World Maps, i know that the encounter chance doesn't work in the same way for the World Map as it does for the Field Map; the field map will do one check for the special battles, considering the encounter values for all of the Special battles, combined, and then move onto the normal battles. However, on the World Map, a check is performed for each individual battle slot, of which there are 4. So in the example used, the first check will be an 8/64 for spcl battle 1, then the 2nd check occurs which is 2/64, and then the normal battle check. All of this occurs after the Mystery Ninja check, and then the Chocobo Battle chance, which I'm not even considering into the equation, for obvious reasons.

Anyway, do you suspect that the variation in the way in which special battles are treated are the cause of the differentiation between World and Field Maps in the projected averages?

--- End quote ---
Well, there's a pickle, to be sure. It looks to me like the WM has the same formation choosing power that the field has. The WM doesn't use the system's RNG like I suspected for formation selection (however, it does when determining if a battle should occur). It uses a pre-computed table of "random" values that changes after so many calls (520, to be exact) and not specifically to formation selection. The Mystery Ninja uses two of these calls right off before checking where you are or even your terrain type. The special battles call this a little less predictably.

The real issue is between calculation and simulation. The calculation I gave you is correct whether on the map or in the field. The simulation for WM calls is wrong, but it's more complicated than I expected and I probably won't redo it. We can relabel this "Truly random simulation average" and the WM would probably be somewhere between the calculated and field values.

Either way, it's 98.3±.5% of the calculated value so that's statistically spot on.

DynamixDJ:
NFITC1, as a person, statistically you are spot on! Thank you for clearing this up, I understand it all now!!!
The only "hard" bit will be inputting all of these formulas into a spreadsheet which I haven't done since the days of school, but I 'm fairly confident that it can't be that hard, I'll fiddle around tonight!

Even if I can't contain you, I can still try, but first I need to obtain the Contain Materia.... Spare some Mimett Greens, anyone??? (I ran out of gil playing Super Dunk  :D)

NICE 1!!!!

-EDIT- I've just realised, seeing as we're taking an average, can 1185.791015625 be rounded up? Also, in an example where there are no special battles, can I assume that [(800 * (22/64)) + (1000*(21/64)) + (1700 * (21/64))] / 64 is a correct formula?

-Edit again- HAHAHAHAHAHAHAHA!!!!!!! I've just read the super-small print:

--- Quote ---How dare you! I never usually get something correct on the first pass of a problem; But I'm actually good at math and don't often make mistakes.
--- End quote ---

DynamixDJ:
I've just finished making a Reward Average Calculator. Thanks a bunch, NFITC1!!!!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version