What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » First script testing

First script testing
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: First script testing
quote:
Originally posted by markee
Matty needs to learn how to do better randomness....

code:
return rn_txt[Math.round((rn_txt.length-1)*Math.random())];

Should be:

code:
return rn_txt[Math.floor((rn_txt.length)*Math.random())];

Otherwise the first and last variable only have half the probability of being chosen as any other (assuming Math.random is truely random).
Clearly I didn't alter that function except for removing the undeclared variable.
03-13-2008 01:41 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
First script testing - by snazzpompey on 03-02-2008 at 05:46 PM
RE: First script testing - by Spunky on 03-02-2008 at 05:52 PM
RE: First script testing - by Jesus on 03-02-2008 at 06:11 PM
RE: First script testing - by Spunky on 03-12-2008 at 04:49 PM
RE: First script testing - by matty on 03-12-2008 at 05:06 PM
RE: First script testing - by Spunky on 03-12-2008 at 05:44 PM
RE: First script testing - by markee on 03-13-2008 at 01:11 PM
RE: First script testing - by matty on 03-13-2008 at 01:41 PM
RE: First script testing - by Volv on 03-13-2008 at 02:30 PM
RE: First script testing - by Jesus on 03-13-2008 at 04:03 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On