function spin($a) { if (preg_match('#\\{(.+?)\\}#is', $a, $b)) { if (($i = strpos($b[1], '{')) > -1) { $b[1] = substr($b[1], $i + 1); } $c = explode('|', $b[1]); $a = preg_replace("+\\{" . preg_quote($b[1]) . "\\}+is", $c[array_rand($c)], $a, 1); return spin($a); } return $a; }
} } if ($wonlast) { $current_bet = $base_bet; } else { if ($current_bet < $maximumbet || $maximumbet == 0) { $current_bet = $current_bet * 2; } } //make sure there is enough money for bet if ($moneypot < $current_bet) { $result_text .= "not enough money left in your pot to place bet of: " . $current_bet; break; } $result_text .= "your moneypot: " . $moneypot . ". your bet: \$" . $current_bet . " on " . $color . " => "; if (spin($color)) { $wonlast = true; $moneypot += $current_bet; $result_text .= "Winner!<br/>"; } else { $result_text .= "Loser<br/>"; $wonlast = false; $moneypot -= $current_bet; } } ?> Starting Money Pot: <?php echo $startingpot; ?> <br/>
<?php $foldername = './article/'; $file = glob($foldername . "*.txt"); $rand = rand(0, count($file) - 1); $one = str_replace($foldername, '', $file[$rand]); $two = str_replace('.txt', '', $one); //echo $two.'<br><br><br>'; $getarticle = glob('article/' . $one); foreach ($getarticle as $arti) { $landz = $arti; } $article = file_get_contents($landz); $article = spin($article);
if (isset($argv[1])) { $spins = $argv[1]; } else { $spins = 10000; } $rnd = spin(); $result = array(0, 0); $seq = 1; $seqs = array(); for ($i = 0; $i < 50; $i++) { array_push($seqs, NULL); } for ($i = 0; $i < $spins; $i++) { $result[$rnd]++; $lastRnd = $rnd; $rnd = spin(); if ($lastRnd == $rnd) { $seq++; } else { if ($seqs[$seq] == NULL) { $seqs[$seq] = 1; } else { $seqs[$seq]++; } $seq = 1; } } echo "Sekvenser etter {$spins} spinn:\n"; echo "Lengde\tAntall\n"; foreach ($seqs as $length => $count) { if ($count > 0) {