Posts: 613
Threads: 11
Joined: Aug 2010
Reputation:
0
Whats wrong with using random(max) ?
Posts: 613
Threads: 11
Joined: Aug 2010
Reputation:
0
It can be predicted knowing that code, since it's using gettime.
Posts: 642
Threads: 129
Joined: Jan 2011
Reputation:
0
but... not completely... right?... it has a bunch of random() fundtions in it to make it more random.. so.. it should be almost unpredictable... right?
Posts: 642
Threads: 129
Joined: Jan 2011
Reputation:
0
Ok guys, this was just a little experiment to see how it worked out. It does do the job... but, its a bit.. INEFFICENT. :d Anyway, sorry to bother, but.. idk. I just wanted to see what you guys would think of it. :/
Posts: 1,317
Threads: 23
Joined: Feb 2010
Reputation:
0
22.05.2011, 20:59
(
Последний раз редактировалось dugi; 23.05.2011 в 13:32.
)
Don't really see the use of it, next time use pastebin though, for such scripts.
(Btw, your location doesen't really make sense;
C:/a/b/me.amx
How I look at it that would mean
'a' is in drive C, 'b' is an part of 'a' so that makes 'me' a part of 'a's b'. So you just described your location inside an 'b'?)
Posts: 15,941
Threads: 0
Joined: Jun 2008
Why have you used the numbers and algorithms you have in that code? Do you have any references to justify those choices and prove that this is COMPLETELY random - because I'm sorry to tell you that it's not!
"random" is a pseudo-random number generator. That means it has a predictable, though highly complex and long, pattern to the numbers it generates. Your code, being based on "random" and basic maths, will also have a predictable pattern. This is no better or worse than "random", it may just give a different distribution of numbers to "random" which appears better for your uses.
There are large numbers of research papers on better pseudo-random number generation techniques. One famous one (for which there is already a SA:MP plugin) is the Mersenne Twister.
Links (note that some of these are behind paywalls, if you are at a university or similar institution/company you may still be able to see them):
http://portal.acm.org/citation.cfm?id=272995 - Mersenne Twister.
http://epubs.siam.org/sicomp/resourc...v15/i2/p364_s1 - 1/P generator.
http://scholar.******.co.uk/scholar?...-random+number - Many more links.
If you want to write a good random number generator and claim that it is good, you need to be able to show that it is good - and that is non-trivial! Hence why people can write advanced maths research papers for publication.