I was inspired, if you will, by Genuine Quantum Randomness. This uses the module described there.
use HotBits; my $x = new HotBits::; my $n1 = $x->request (32); my $n2 = $x->request (32); if((unpack("i*",$n1))>(unpack("i*",$n2))){print "Heads\n";}elsif((unpa +ck("i*",$n1))==(unpack("i*",$n2))){print "The coin flew out of sight, + sorry. No answer, and you're out \$0.25.\n";}else{print "Tails\n";}
Quite minimalistic. And slow. But it works. And it's random enough, I'd say.
Update: fixed the problem that merlyn mentioned. Although the chances of the numbers being equal are kinda slim :)
Another Update: With a bit of code suggested by saucepan, I've made it a bit simpler. More effective, too. Here it is:
use HotBits; my $HotBits = new HotBits::; my $val=$HotBits->request (32); $val=unpack('%32b*', $val)%2; if($val==1){print "Heads\n";}else{print "Tails\n";}
--Psi
print(pack("h*","e4f64702566756e60236c6f637560247f602265696e676021602075627c602861636b65627e2")."\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wacky Happy Fun Genuine Coin Flipping Software OK!
by merlyn (Sage) on Jun 05, 2001 at 09:10 UTC | |
by PsionicMan (Beadle) on Jun 05, 2001 at 09:18 UTC | |
by Arguile (Hermit) on Jun 05, 2001 at 10:53 UTC | |
by PsionicMan (Beadle) on Jun 05, 2001 at 19:39 UTC | |
by Cybercosis (Monk) on Jun 05, 2001 at 10:53 UTC | |
by John M. Dlugosz (Monsignor) on Jun 06, 2001 at 00:17 UTC | |
|
Re: Wacky Happy Fun Genuine Coin Flipping Software OK!
by John M. Dlugosz (Monsignor) on Jun 06, 2001 at 00:07 UTC |