PhoenixXL Posted November 14, 2012 Share Posted November 14, 2012 (edited) Hello EveryoneWhat does it mean by a SEEDIndeed upon using the Function SRandom the result of Random subsequently is always ConstantCan anyone tell me the significance of the function SRandomThanks in advance Edited November 15, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
FireFox Posted November 14, 2012 Share Posted November 14, 2012 I didn't know it myself, but I found that it's the initializer of the random function. If you set the current time in the seed, the random will be based on this seed.Br, FireFox. Link to comment Share on other sites More sharing options...
PhoenixXL Posted November 14, 2012 Author Share Posted November 14, 2012 (edited) Thanks Firefox for the LinkBut i have already tried that linkMy question is what is the Significance of the Functionbecause it sets the subsequent Random calls a ConstantLocal $rand $rand = Random() ConsoleWrite($rand&@CR) ;This is Random SRandom(0) $rand = Random() ConsoleWrite($rand&@CR) ;Always constant i.e. 0.548813502304256 Edited November 14, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
FireFox Posted November 14, 2012 Share Posted November 14, 2012 But i have already tried that linkOK sorry.Yes that's weird... I'm waiting for a dev answer too Link to comment Share on other sites More sharing options...
JohnOne Posted November 14, 2012 Share Posted November 14, 2012 (edited) I don't see the point myself either, perhaps it's just an Artifact from the golden olden days. SRandom(@hour / (@min + 1) + @sec) or something I imagine AutoIt seeds internally. Edited November 14, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted November 14, 2012 Share Posted November 14, 2012 The internal seed is based on something more changing than seconds. While 1 ConsoleWrite(Random() & @CrLf) Sleep(0) ;JohnOne is the author, not me. WEnd Link to comment Share on other sites More sharing options...
JohnOne Posted November 14, 2012 Share Posted November 14, 2012 (edited) The internal seed is based on something more changing than seconds. While 1 ConsoleWrite(Random() & @CrLf) Sleep(0) ;JohnOne is the author, not me. WEnd Serously do not run that at it is HotKeySet("{ESC}","_Exit") Local $ScriptTimer = TimerInit() Local $SleepTime = 0 SRandom(12) While 1 If TimerDiff($ScriptTimer) > 200 Then Exit ; exit after 0.2 seconds, else you will find yourself with a runaway console Sleep($SleepTime) ConsoleWrite(Random() & @LF) WEnd Func _Exit() Exit EndFunc Edited November 14, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dany Posted November 14, 2012 Share Posted November 14, 2012 It's pseudorandom i.e. maths. The generator is the Mersenne Twister.The seed is the initial start value (x). With x = 0 the outcome is always the same obviously. Same goes for any other 'hardcoded' seed, it will always produce the same sequence of numbers. When using a changing value like @MSEC or something like that as a seed, such predictable patterns are avoided.You only need to seed once, not everytime prior to calling Random()! [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
FireFox Posted November 14, 2012 Share Posted November 14, 2012 Serously do not run that at it isComputer not enough powerful ? Link to comment Share on other sites More sharing options...
JohnOne Posted November 14, 2012 Share Posted November 14, 2012 Computer not enough powerful ? lol probably not to be honest.But I've been caught by something similar beforeEven if you exit the script, the console still finishes all its writesand it went on for about five minutes before I had to kill the process. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Bowmore Posted November 14, 2012 Share Posted November 14, 2012 You should only use SRandom() to initialize the Random() when you need to be able to produce the same sequence of numbers every time you run the script. An example of this might be for testing code where you need a random set of inputs, but need to use the same set of inputs for each test run after a code change, in order that the test conditions are the same. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
FireFox Posted November 14, 2012 Share Posted November 14, 2012 Even if you exit the script, the console still finishes all its writesThat's right, but you can normally close scite without any problem. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 14, 2012 Share Posted November 14, 2012 You should only use SRandom() to initialize the Random() when you need to be able to produce the same sequence of numbers every time you run the script. An example of this might be for testing code where you need a random set of inputs, but need to use the same set of inputs for each test run after a code change, in order that the test conditions are the same.I'd have to disagree with this as a general rule, maybe as a good idea for testing but certainly not the only reason to use it. If you're creating a random sequence and want to make sure that you can change the sequence when needed, you'd use a different seed otherwise you're going to keep getting the same sets of numbers. I came up with a latin square generator script that after a certain point you almost had to use a different seed to have it complete at all. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jchd Posted November 14, 2012 Share Posted November 14, 2012 Independant of the programming language, SRandom or Seed or whatever it's called is mainly used to ascertain a repeatable sequence of pseudo-random numbers across runs or across computers. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
PhoenixXL Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) Independant of the programming language, SRandom or Seed or whatever it's called is mainly used to ascertain a repeatable sequence of pseudo-random numbers across runs or across computers.Thanks to everyoneThe Topic seems to be SOLVED now Edited November 15, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. 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