Difference between revisions of "Talk:Seedable PRNG"
Jump to navigation
Jump to search
Gigs Taggart (talk | contribs) (stuff) |
|||
Line 1: | Line 1: | ||
Shouldn't prng_get update the seed? This works on the same principal as a script i wrote ([http://www.lslwiki.net/lslwiki/wakka.php?wakka=LibraryPseudoRandomGenerator Pseudo-Random Number Generator]). [[User:Strife Onizuka|Strife Onizuka]] 00:51, 19 March 2007 (PDT) | Shouldn't prng_get update the seed? This works on the same principal as a script i wrote ([http://www.lslwiki.net/lslwiki/wakka.php?wakka=LibraryPseudoRandomGenerator Pseudo-Random Number Generator]). [[User:Strife Onizuka|Strife Onizuka]] 00:51, 19 March 2007 (PDT) | ||
:I don't think so, though it is interesting how similar mine came out to be to yours. I swear I wasn't looking at yours when I wrote this. :P Yours doesn't seem to generate random numbers, at least not in any way I'm used to calling random! | |||
<pre> | |||
integer pseudo_random(string text, integer nonce, integer start, integer end) | |||
{//(c)(cc-by) Strife Onizuka, http://creativecommons.org/licenses/by/2.5/ | |||
return (integer)("0x"+llGetSubString(llMD5String(text, nonce), start, end)); | |||
} | |||
string feed = "How much wood would a wood chuck chuck if a wood chuck could chuck wood?"; | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
} | |||
touch_start(integer next) | |||
{ | |||
integer x; | |||
next = pseudo_random(feed, 30 * ((integer)llGetGMTclock() / 30), 0, 7); | |||
for (x=0;x<10;x++) | |||
llSay(0, (string)next); | |||
} | |||
} | |||
</pre> | |||
Output: | |||
<pre> | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
[12:19] Object: 120920825 | |||
</pre> | |||
Mine has something yours doesn't have, it basically runs the MD5 in OFB mode by rehashing the previous hash over again. [[User:Gigs Taggart|Gigs Taggart]] 12:32, 19 March 2007 (PDT) |
Revision as of 12:32, 19 March 2007
Shouldn't prng_get update the seed? This works on the same principal as a script i wrote (Pseudo-Random Number Generator). Strife Onizuka 00:51, 19 March 2007 (PDT)
- I don't think so, though it is interesting how similar mine came out to be to yours. I swear I wasn't looking at yours when I wrote this. :P Yours doesn't seem to generate random numbers, at least not in any way I'm used to calling random!
integer pseudo_random(string text, integer nonce, integer start, integer end) {//(c)(cc-by) Strife Onizuka, http://creativecommons.org/licenses/by/2.5/ return (integer)("0x"+llGetSubString(llMD5String(text, nonce), start, end)); } string feed = "How much wood would a wood chuck chuck if a wood chuck could chuck wood?"; default { state_entry() { } touch_start(integer next) { integer x; next = pseudo_random(feed, 30 * ((integer)llGetGMTclock() / 30), 0, 7); for (x=0;x<10;x++) llSay(0, (string)next); } }
Output:
[12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825 [12:19] Object: 120920825
Mine has something yours doesn't have, it basically runs the MD5 in OFB mode by rehashing the previous hash over again. Gigs Taggart 12:32, 19 March 2007 (PDT)