Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: How do I make a random shuffle deterministic?

by Anonymous Monk
on Dec 05, 2012 at 17:46 UTC ( #1007346=note: print w/replies, xml ) Need Help??


in reply to Re^4: How do I make a random shuffle deterministic?
in thread How do I make a random shuffle deterministic?

Thanks for the tips. It is acceptable if some hosts have the same seed. Still, lessening those occurrences is a good thing. How about this:

sub seed { my $string = shift; my $seed; my @ascii = map ord, split //, $string; my $product = pop @ascii; for ( @ascii ) { $seed += $_ }; $seed = $seed * $product; srand $seed; }

Replies are listed 'Best First'.
Re^6: How do I make a random shuffle deterministic?
by LanX (Chancellor) on Dec 05, 2012 at 17:53 UTC
    "rolfi" and "flori"?

    just a guess: try multiplying each ord with a different prime (by position) and do a module biggest prime <256 before adding.

    or start a new thread about efficient checksums! :)

    UPDATE: the automatic seeding is quite efficient, so why don't you determine a unique seed at installation time from a random number.

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007346]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2016-09-30 17:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (570 votes). Check out past polls.