WolfWorld Posted August 24, 2009 Share Posted August 24, 2009 Make one and post it as a UDF (I am very lazy now)(Using Ramdom.org API) Thanks. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
jvanegmond Posted August 24, 2009 Share Posted August 24, 2009 (edited) Here you go. You can donate using PayPal directly to josvanegmond at gmail dot com #include <INet.au3> $s = _Random(0, 1000) MsgBox(0,"", $s) Func _Random($min, $max) Return _INetGetSource("http://www.random.org/integers/?num=1&min=" & $min & "&max=" & $max & "&col=1&base=10&format=plain&rnd=new") EndFunc Edited August 24, 2009 by Jos changed email to avoid spam github.com/jvanegmond Link to comment Share on other sites More sharing options...
herewasplato Posted August 24, 2009 Share Posted August 24, 2009 @Manadar, If you were/are serious about making a UDF to use this site, then you might want to build in the features needed to make the UDF comply with this info... http://www.random.org/clients/ http://www.random.org/clients/http/#quota ...so as not to get the user of the UDF IP banned: http://www.random.org/banned-hosts/ Not that it seems to be a giant problem. :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
jvanegmond Posted August 24, 2009 Share Posted August 24, 2009 Hah, pretty clever website. Too bad I wasn't being serious, really. github.com/jvanegmond Link to comment Share on other sites More sharing options...
omikron48 Posted August 24, 2009 Share Posted August 24, 2009 (edited) Opt("MustDeclareVars", 1) Global Const $multiplier = 16807 Global Const $increment = 0 Global Const $modulus = _Pow(2, 31) - 1 Global $seed Func _SetSeed($value) $seed = $value EndFunc Func _NextSeed() $seed = Mod($multiplier * $seed + $increment, $modulus) Return $seed EndFunc Func _Pow($base, $exp) Local $result = 1 For $i = 1 To $exp $result *= $base Next EndFunc Just use _SetSeed when priming the random number generator, then keep calling _NextSeed to generate numbers. Code is for basic LCG using Apple Carbon parameters. http://en.wikipedia.org/wiki/Linear_congruential_generator Number range is [0, 2^31 - 1). If you want it unit random, [0, 1), get the decimal result of (_NextSeed() / $modulus). That should be enough for basic needs. Don't ask for a Mersenne Twister... x_x Edited August 24, 2009 by omikron48 Link to comment Share on other sites More sharing options...
WolfWorld Posted August 24, 2009 Author Share Posted August 24, 2009 I already read all of that. But we(the maker) are not getting ban the one who uses it are getting it >_ Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
WolfWorld Posted August 24, 2009 Author Share Posted August 24, 2009 Opt("MustDeclareVars", 1) Global Const $multiplier = 16807 Global Const $increment = 0 Global Const $modulus = _Pow(2, 31) - 1 Global $seed Func _SetSeed($value) $seed = $value EndFunc Func _NextSeed() $seed = Mod($multiplier * $seed + $increment, $modulus) Return $seed EndFunc Func _Pow($base, $exp) Local $result = 1 For $i = 1 To $exp $result *= $base Next EndFunc Just use _SetSeed when priming the random number generator, then keep calling _NextSeed to generate numbers. Code is for basic LCG using Apple Carbon parameters. http://en.wikipedia.org/wiki/Linear_congruential_generator Number range is [0, 2^31 - 1). If you want it unit random, [0, 1), get the decimal result of (_NextSeed() / $modulus). That should be enough for basic needs. Don't ask for a Mersenne Twister... x_x This is NOT true randomness but nice work! Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
omikron48 Posted August 24, 2009 Share Posted August 24, 2009 (edited) If you want true randomness, go stare at a radioactive isotope... >_< Yeah, the code I posted is only for psuedo rng, but that's what computing power is for. Most random number generation done on computers use pseudo random number generators, due to ease of replication for testing and verification. Edited August 24, 2009 by omikron48 Link to comment Share on other sites More sharing options...
WolfWorld Posted August 24, 2009 Author Share Posted August 24, 2009 If you want true randomness, go stare at a radioactive isotope... >_<Yeah, the code I posted is only for psuedo rng, but that's what computing power is for. Most random number generation done on computers use pseudo random number generators, due to ease of replication for testing and verification.This is just a proof of concept and adding a UDF to the community. It does not need to have a reason. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
omikron48 Posted August 24, 2009 Share Posted August 24, 2009 Ah. I have C# code for LCG, MRG and Mersenne Twister. I'm currently just not in the mood to convert it into AutoIt script. It's kind of messy translating OO code to procedural since it's no longer encapsulated, thus not as fault proof. For twister, you need 32-bit uint(s) for bit shifting. C Rand() sucks. Even that basic LCG gives better numbers than Rand(). If you want random numbers, you're better off coding your own rng than relying on the ones readily available. At least you know what you're getting. Link to comment Share on other sites More sharing options...
monoceres Posted August 24, 2009 Share Posted August 24, 2009 If you want random numbers, you're better off coding your own rng than relying on the ones readily available. At least you know what you're getting.In AutoIt you get the twister >_< Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
WolfWorld Posted August 24, 2009 Author Share Posted August 24, 2009 Ah. I have C# code for LCG, MRG and Mersenne Twister.I'm currently just not in the mood to convert it into AutoIt script. It's kind of messy translating OO code to procedural since it's no longer encapsulated, thus not as fault proof.For twister, you need 32-bit uint(s) for bit shifting.C Rand() sucks. Even that basic LCG gives better numbers than Rand().If you want random numbers, you're better off coding your own rng than relying on the ones readily available. At least you know what you're getting.Can you send me the code? I will translate it, I got nothing to do. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
jvanegmond Posted August 24, 2009 Share Posted August 24, 2009 (edited) You're requesting a Random UDF because you're lazy, but at the same time you have nothing to do and start more projects. This strikes me as odd. Edited August 24, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
WolfWorld Posted August 24, 2009 Author Share Posted August 24, 2009 You're requesting a Random UDF because you're lazy, but at the same time you have nothing to do and start more projects. This strikes me as odd.Let's see. I did not write in Autoit mainly for almost a month now and I feel that the syntax is hard so I felt lazy. But when the word C#(my main language other c++ now) I felt like fun >_< Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
GEOSoft Posted August 24, 2009 Share Posted August 24, 2009 You're requesting a Random UDF because you're lazy, but at the same time you have nothing to do and start more projects. This strikes me as odd.And after I invested all that time in it too !!!@athiwatc, the bill's in the mail. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
herewasplato Posted August 24, 2009 Share Posted August 24, 2009 ... Don't ask for a Mersenne Twister... x_xFrom the help file under the Random function:Comments based on the original sourceThis function uses the Mersenne Twister random number generator, MT19937, written by Takuji Nishimura, Makoto Matsumoto, Shawn Cokus, Matthe Bellew and Isaku Wada. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
omikron48 Posted August 24, 2009 Share Posted August 24, 2009 From the help file under the Random function:Cool. Then I don't need to bother with the twister then.I wouldn't know since I have yet to need random numbers in my AutoIt scripting so I have yet to investigate any available random functions.But a question though, how is the twister queue populated by the code?The thing with Mersenne twister is that it produces good random numbers, but if you don't use another rng to initially populate the array it uses for generating numbers, the random numbers it spits out at the start are bad quality. Mesenne twister quality improves after a lot of generates but sucks at the initial. LCG on the other hand is good at the start but starts declining when called a lot of times. Link to comment Share on other sites More sharing options...
herewasplato Posted August 25, 2009 Share Posted August 25, 2009 ... But a question though, how is the twister queue populated by the code? ...I have no clue, but the Random func has been a part of AutoIt long enough that the source code can probably be found in the info from this post:http://www.autoitscript.com/forum/index.php?showtopic=8389 [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
WolfWorld Posted August 25, 2009 Author Share Posted August 25, 2009 And after I invested all that time in it too !!!@athiwatc, the bill's in the mail.>_< Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now