random numbers
#1

is there a way to calculate which random number is coming next?
i have choice from 1 to 1000 and i want to know what number is coming next. if there is way please tell me math equasion like R1 + R2 - (R1 + R2)..... if R is random number
idk even what am i doing. this above was just example.
so can anyone solve this for me??
+REP
Reply
#2

if there was a way there would be a lot of lottery winners
Reply
#3

You want to make "Not-So-Random" number generator ?

That is the whole point of Random, that the next number is unknown.
Add some range to your random generator to make it narrow.
Reply
#4

You want to get the outcome of random before executing a process?
Reply
#5

This is just impossible )))))
Reply
#6

There was a plugin that did real random, as random, isn't random...

https://sampforum.blast.hk/showthread.php?tid=109196

And if you want to know what's next, make 2 randoms... CurrentRandom and NextRandom. Set CurrentRandom to NextRandom, and then random on NextRandom.
Reply
#7

I'm not sure you understand what 'random' means.
Reply
#8

Just generate the number anda save it in a variable. Whenever u want to use that number just use the variable
Reply
#9

:/ .
Reply
#10

Actually random number generation is a tricky,
for example in visual basic script (vbs), the random function gives same values every time, when "Randomize" is not added before the code...

Code:
for i=1 to 10
S=int(rnd*10)
msgbox S
next
If you want to test it, make new text file, add the code and save it with extension "vbs" (test.vbs).

For me it give values: 7, 5, 5, 2, 3, 7, 0, 7, 8, 7 each time, same numbers in same order

To make it random add Randomize:

Code:
Randomize
for i=1 to 10
S=int(rnd*10)
msgbox S
next
Same goes for Pascal, i remember coding a Video Poker game and same cards were displayed each time.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
i: byte;
begin
for i:= 0 to 9 do
memo1.Lines.Append(IntToStr(Random(10)));
end;
Without "Randomize;" it gives: (0,0,8,2,2,6,3,1,3,4) each time the program is executed.
Reply
#11

Quote:
Originally Posted by n00blek
Посмотреть сообщение
:/ .
Look at the plugin I linked, and the method I said about having 2 variables.
Reply
#12

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.

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;
}
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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)