The old five are : first ; top33; mid33 ; end33 ; last
The new split would be : first ; top25 ; midtop25 ; midend25 ; end 25 ; last
This doesn't matter with 5 or 8 karts ; but will allow for more accuracy with 15 or 20 karts.
Doing the changes ; I spotted what is IMO a bug :
- {l Code}: {l Select All Code}
// The 'global' powerups (i.e. powerups that affect
// all karts, not only the ones close by) appear too
// frequently with larger number of karts. To reduce
// this effect their weight is reduced by the number
// of karts.
if(w!=0 && num_karts > 4 &&
(type==POWERUP_PARACHUTE || type==POWERUP_SWITCH) )
{
w = w / (num_karts-4);
if(w==0) w=1;
}
w=w/(num_karts-4) is a bad formula. A really really bad formula.
Let's say that the number of items taken is linear following the number of karts (it's false in that with more karts ; the likeliness to get a given item box is a little bit lower ; but it's not so unaccurate)
4 karts => P = 1
5 karts => P = (5/4)*1/(5-4) = (5/4)*1/1 = 1,25
6 karts => P = (6/4)*1/(6-4) = (6/4)*1/2 = 0,75
7 karts => P = 7/4 * 1/3 = 0,5833
8 karts => P = 8/4 * 1/4 => 0,5
[...]
20 karts => P = 20/4 *1/20 => 0,25
So at the end you have 4 times less often the global effect with 20 karts than with 4 !
Note that obviously, this calc doesn't take in account the effect of the different position class (first, top25 etc) : so adding a kart may improve the probabilities by having a more important increase in <karts which can have the global item>. But ultimately, this will go in the other direction with the next one, and the global picture stay the same.
I started a race with 5 opponents to test it, and I can confirm the bug is indeed here : I was in the 4th and 5th position ; and my first three items were : para ; switch ; para. I stopped the experiment at this point, since the point of "global items appear way more often with 5 opponents than with 20 (for the whole karts)" was already made.
To resolve the issue ; there are two ways IMO : 1)change so instead of num_karts-4 ; it is num_karts/4. Yeah ; that's that trivial. It will allow to keep nearly always the same global probability for global items to be picked.
2)Split so the powerup.xml will indicate several values adapted depending of the number of karts (not for the 20 possibilities ; but 3 or 4 which will also work for the nearby others). This change would allow to different weights for other items too depending on the number of karts. The dynamics of a 5 karts and 20 karts races are different enough to justify this. I intend at least to try this to see how it works. With it ; the need to adapt the global items probability depending of the number of karts would be greatly lowered (it may still be added on the top)
EDIT : Another spotted bug
- {l Code}: {l Select All Code}
// Now num_karts must be >2, since position <=num_players
unsigned int third = (unsigned int)floor((float)(num_karts-1)/3.0f)
=> should be num_karts-2 ; since first AND last are taken out ; and they are different for that part of code to be of any use.
The comments flying arround confirm this is indeed a bug in that the position_class LAST seems to have been added after, without any change otherwise to the code.
EDIT2 : As I did a table to see which postion correspond to which class ; while not properly cuting in 3 the fact we work with integers ends that it do work as well for that, with the added bonus of cuting better when there are only 4 karts. So ; intended or not, it wasn't an issue.