I think that's going to incorrectly favor the pools with lower indices, it's pretty likely to exhaust the available points unevenly instead of evenly distributing the points. You'd be better to do something like Rolan7's approach, where at every iteration you pick a pool to add a single point. This is because you're picking a random fraction of the remaining point total for each subsequent pool, which means the probabilities are

*dependent* probabilities rather than what I think is wanted which is

*independent* probabilities.

You've also got a bug (I think?) in that each pool can always end up with max pool points, not the max of the remainder of available points; you've got that

`set /a max_pool_points=!max_points!`

but you never update max_points from what I can see?

Did that get created by ChatGPT? It starts what looks like a Windows batch file with 'bash' which makes no sense...

A much simpler approach is like

`while(there are more points to distribute)`

{

target_pool = randomly pick one of the pools that isn't already maxed out

increment the point count for the target_pool

if( target_pool count is now the limit for a single pool )

{

remove target_pool from the list of pools that can be filled

}

}

Also beware of partitioning a RAND() result into a range by doing a modulus operation: you're very likely going to have a slightly low-weighted count. Consider a random number generator that spit out values between 0 and 15; if you are trying to pick from 6 elements you're going to short-change some of them, because you have 3 ways to get x % 6 equal to 0,1,2,or 3 but only 2 ways to get x % 6 to equal 4 or 5.