SA-MP Forums Archive
Regarding random system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Regarding random system (/showthread.php?tid=560302)



Regarding random system - DavidLuango - 28.01.2015

I had a question, I made a dice system for my server and in there I've used SAMP random function.
I want to know if there is a way to know the upcoming 3 number( I know this doesn't make it random ) But if I roll a dice is there a way to know which number is going to be next. Because SAMP uses pseudo-random number and according to wiki this random function isn't fully random, and I learnt from somewhere where it says computer cannot just generate random numbers but follows a special sequence to generate a number for you.

If someone who is expert at this can explain me how SAMP itself uses random function to generate number?

I'd appreciate.


Re: Regarding random system - DavidLuango - 29.01.2015

Anyone?


Re: Regarding random system - Abagail - 29.01.2015

The random function generates a random integer value(I am not sure what it's based on) within the range of 0, and the given parameter(max param).

Basically: - any number between 0 up to(and or equal to) the max can be chosen. I am not really entirely sure as I wrote above exactly how the number is generated, but if someone told you its not random they're wrong.

There is no way to predict which one will be chosen next without actually calling the function, and retrieving the value.


Re: Regarding random system - DavidLuango - 31.01.2015

Uhm, Thought there was a way.


Re: Regarding random system - ATGOggy - 31.01.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
The random function generates a random integer value(I am not sure what it's based on) within the range of 0, and the given parameter(max param).

Basically: - any number between 0 up to(and or equal to) the max can be chosen. I am not really entirely sure as I wrote above exactly how the number is generated, but if someone told you its not random they're wrong.

There is no way to predict which one will be chosen next without actually calling the function, and retrieving the value.
I don't think so, because computers cannot generate a random number. They use a sequence to generate the next number. They are not like humans.

Btw, humans too can't choose a random number. They does some calculations in their brain and tells a number, the calculations maybe small or big.

OT: I don't know the sequence which pawno uses.


Re: Regarding random system - DRIFT_HUNTER - 31.01.2015

Well simple answer to your question will be NO.

Yes computers can not generate random numbers, they must use some pattern to archive random number, and if you know these pattern than you COULD predict numbers. But there are more factors except pattern and its a magic number(s) that is/are used to generate random number. Most random number generators i know depend on at least two things. First is magic number and second is computer current time (timestamp). Knowing pattern without these numbers is useless, plus these numbers are known to mutate (timestamp for example...)


Re: Regarding random system - Virtual1ty - 31.01.2015

DRIFT_HUNTER is right - I managed to find the code for the "random" function and it indeed takes a timestamp and the so called "magic number" is just the number of times the function was called, and does calculations with it. So there's really no way for you to predict what the number might be.


Re: Regarding random system - DavidLuango - 01.02.2015

That's awfully weird a guy I know made a application which would show the upcoming random number. I don't know how he did it but he had a neat video demonstration. He deleted that from ******* and is not willing to leak the application.


Re: Regarding random system - DavidLuango - 02.02.2015

Anyone got any clues ideas?