Kmining.com : Business Intelligence, Knowledge Discovery, Data mining : Discovery 
Science
drCRM scripts
genCal
phpKenoSim »
Back to Kmining.com
Kmining.com > phpKenoSim
Click here to download source (keno.tar.gz)
<?PHP
/*
  "phpkenosim" - PHP Keno Simulator (version 0.5-alpha)
  Copyright (C) 2003 drCRM http://www.kmining.com/drcrm/

  "phpkenosim" is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  "phpkenosim" is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with "phpkenosim"; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


set_time_limit(0); // Setting time limit: unlimited
// payout rules of keno
$winning=Array(
"3"=>Array("1"=>"1","2"=>"2","3"=>"25"),
"4"=>Array("1"=>"1","2"=>"2","3"=>"5","4"=>"40"),
"5"=>Array("2"=>"1","3"=>"2","4"=>"10","5"=>"250"),
"6"=>Array("2"=>"1","3"=>"2","4"=>"5","5"=>"50","6"=>"1000"),
"7"=>Array("3"=>"1","4"=>"2","5"=>"15","6"=>"250","7"=>"2000"),
"8"=>Array("4"=>"2","5"=>"8","6"=>"40","7"=>"400","8"=>"4000"),
"9"=>Array("4"=>"2","5"=>"5","6"=>"20","7"=>"80","8"=>"500","9"=>"5000"),
"10"=>Array("4"=>"1","5"=>"2","6"=>"20","7"=>"100","8"=>"500","9"=>"1000","10"=>"5000")
);
$game=Array();$player=Array();
$games=$_GET["games"];if ($games<1) { $games=10; }
$bet=10; // bet is currently set to 10

for ($a=1;$a<=$games;$a++) { // if $games=10 then make 10 simulation
  
$gametype=rand(3,10);
  for (
$b=0;$b<20;) { $n=rand(1,80); if (!in_array($n,$game)) { $game[$b]=$n;$b++; } }
  for (
$c=0;$c<$gametype;) { $n=rand(1,80); if (!in_array($n,$player)) { $player[$c]=$n;$c++; } }
  
$m=0;for ($c=0;$c<$gametype;$c++) { if (in_array($player[$c],$game)) { $m++; } }
  
$stat[($winning[$gametype][$m]*$bet)]++;
  
$payout=$payout+($winning[$gametype][$m]*$bet);
}
echo
"Money out: <B>$payout</B>, money in: <B>".($games*$bet)."</B>, distribution of winnings:<BR>";
asort($stat);
while (list(
$key, $val) = each($stat)) {
   echo
"$key => $val<BR>";
}

?>



Copyright © 2004 Kmining.com. All rights reserved. Suggestions, comments, feedback: info@kmining.com