<?xml version="1.0" encoding="windows-1252"?>
<node id="1007327" title="Re: How do I make a random shuffle deterministic?" created="2012-12-05 11:30:46" updated="2012-12-05 11:30:46">
<type id="11">
note</type>
<author id="712372">
kennethk</author>
<data>
<field name="doctext">
&lt;p&gt;Rigging the shuffle to be identical on a given host is easy -- simply feed a fixed seed to [doc://srand] before your first call to [doc://rand].
&lt;p&gt;This makes variation between hosts easy by simply choosing a host-specific property as your seed -- perhaps a mangled hardware address?
&lt;c&gt;#!/usr/bin/perl -w
use strict;
use 5.10.0;

my ($eth) = `ifconfig` =~ /HWaddr (\S+)/;
$eth =~ s/\W//g;
{
    no warnings 'portable';
    srand hex $eth;
}

say rand for 1 .. 10;
&lt;/c&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-712372"&gt;
&lt;hr /&gt;
&lt;p&gt;#11929 First ask yourself `How would I do this without a computer?'  Then have the computer do it the same way.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1007319</field>
<field name="parent_node">
1007319</field>
</data>
</node>
