22.01.2018, 02:49
Well fella's, PAWN's random source code is all over GitHub. In fact I even converted it to PAWN. You could easily add another function that determines the next random number without seeding it for the next call.
I'll prolly just add this to that repo...
EDIT: Keep in mind, the PAWN version is obviously slower than the original simply because it's in PAWN. But with the code converted to PAWN we can seed the next random number, add a minimum value, or even check the next value before seeding it again (like so).
pawn Код:
stock next_random(max)
{
if(simplex_seed == INITIAL_SEED)
simplex_seed = gettime();
new lo, hi, ll, lh, hh, hl;
new result;
lo = simplex_seed & 0xffff;
hi = simplex_seed >> 16;
ll = lo * (IL_RMULT & 0xffff);
lh = lo * (IL_RMULT >> 16 );
hl = hi * (IL_RMULT & 0xffff);
hh = hi * (IL_RMULT >> 16 );
result = ((ll + 12345) >> 16) + lh + hl + (hh << 16);
result &= ~(-2147483647);
if (max != 0)
result %= max;
return result;
}
EDIT: Keep in mind, the PAWN version is obviously slower than the original simply because it's in PAWN. But with the code converted to PAWN we can seed the next random number, add a minimum value, or even check the next value before seeding it again (like so).
