jug7.com
[ home / cgi / juggler / column / diary / bbs / link / welcome ]
source : 秘宝伝 BIG中設定判別
#!/usr/bin/perl
# 秘宝伝 BIG中設定判別
$cginame = 'hihou_big.cgi';
$title = '秘宝伝 BIG中設定判別';
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
}
foreach $str (split(/&/,$input)) {
($name,$value) = split(/=/, $str);
push(@input, $value);
}
($play, $bell, $suika, $hazure) = @input;
print "Content-Type: text/html\n\n";
# ヘッダとフォームの表示
print <<"__ HTML __";
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html lang='ja'>
<head>
<meta http-equiv='Content-Type' content="text/html; charset=shift_jis">
<title>jug7.com - cgi $title</title>
<style type="text/css"> <!--
A:hover {color:#ff0000;}
--></style>
</head>
<body text='#000000' bgcolor='#ffffff' link='#0000ff' alink='#ff0000' vlink='#0000cc'>
<hr>
<b>$title</b><br>
<form action='$cginame' method='POST'>
プレイ数、スイカ、ハズレの入力は必須<br>
(ベルは入力しなくても可)<br>
チャンス目はハズレにカウントする<br><br>
total play <input type='text' size=6 name='play' maxlength=4 value='$play'><br>
bell <input type='text' size=3 name='bell' maxlength=4 value='$bell'><br>
suika <input type='text' size=3 name='suika' maxlength=4 value='$suika'><br>
hazure <input type='text' size=3 name='hazure' maxlength=4 value='$hazure'><br><br>
<input type='submit' value="開始">
</form>
__ HTML __
# エラーチェックとGET送信
if ($ENV{'REQUEST_METHOD'} ne 'POST') {
print '<a href=\'hihou_big_memo.html\'>memo</a> <a href=\'hihou_big.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a>',"\n",'</body></html>';
exit;
}
if ($suika eq '' or $hazure eq '') {
print '<center><font size=4 color=\'red\'><b>ERROR ! (記入漏れがあります。)</b></font></center>';
print '<a href=\'hihou_big_memo.html\'>memo</a> <a href=\'hihou_big.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a>',"\n",'</body></html>';
exit;
}
if($play > 9999) {
print '<center><font size=4 color=\'red\'><b>ERROR ! (プレイ数が大きすぎです。)</b></font></center>';
print '<a href=\'hihou_big_memo.html\'>memo</a> <a href=\'hihou_big.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a>',"\n",'</body></html>';
exit;
}
if($play < $bell+$suika+$hazure) {
print '<center><font size=4 color=\'red\'><b>ERROR ! (入力に誤りがあります。)</b></font></center>';
print '<a href=\'hihou_big_memo.html\'>memo</a> <a href=\'hihou_big.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a>',"\n",'</body></html>';
exit;
}
# 秘宝伝 BIG中 data
$rand = 65536;
$che = 2048;
$jacin = 17724;
@suika = (2000, 2200, 2400, 2600, 2800, 3000);
@bell = (37000, 37500, 38000, 38500, 39000, 39500);
@hazure = (6764, 6064, 5364, 4664, 3964, 3264);
#------------
# 計算開始
#------------
$big = 0 if !$big;
$reg = 0 if !$reg;
$suika_p = &point(($play/$suika), 3) if $suika;
$bell_p = &point(($play/$bell), 3) if $bell;
$hazure_p = &point(($play/$hazure), 3) if $hazure;
for ($i=0; $i<=5; $i++) {
$p1 = ($suika[$i]/$rand)**$suika * (1-$suika[$i]/$rand)**($play-$suika);
$p2 = ($bell[$i]/$rand)**$bell * (1-$bell[$i]/$rand)**($play-$bell);
$p3 = ($hazure[$i]/$rand)**$hazure * (1-$hazure[$i]/$rand)**($play-$hazure);
if (!$bell) { $p4 = $p1 * $p3; }
else { $p4 = $p1 * $p2 * $p3; }
$t_suika_p += $p1; push(@suika_p, $p1);
$t_bell_p += $p2; push(@bell_p, $p2);
$t_hazure_p += $p3; push(@hazure_p, $p3);
$t_total_p += $p4; push(@total_p, $p4);
}
# 百分率にする
for ($i=0; $i<=5; $i++) {
$per1 = &point(($suika_p[$i]/$t_suika_p*100),3) if $t_suika_p;
$per2 = &point(($bell_p[$i]/$t_bell_p*100),3) if $t_bell_p;
$per3 = &point(($hazure_p[$i]/$t_hazure_p*100),3) if $t_hazure_p;
$per4 = &point(($total_p[$i]/$t_total_p*100),3) if $t_total_p;
push(@n_suika, $per1);
push(@n_bell, $per2);
push(@n_hazure, $per3);
push(@n_total, $per4);
}
# 結果の表示
if ($bell) { print "bell 1/$bell_p<br>"; }
print "suika 1/$suika_p<br>";
print "hazure 1/$hazure_p<br><br>";
print '<br>設定信頼度<br>';
for ($i=1; $i<=6; $i++) { print "設 $i -> $n_total[$i-1] %<br>\n"; }
print '<a href=\'hihou_big_memo.html\'>memo</a> <a href=\'hihou_big.html\'>source</a> <a href=\'../index.html\'>top へ戻る</a>',"\n",'</body></html>';
exit;
# 少数を四捨五入して指定の桁にする
sub point {
my($value, $fig, $x);
($value, $fig) = @_;
$value = int($value * (10 ** $fig) + 0.5) / (10 ** $fig);
if ($value =~ /(\d+)\.(\d+)/) { $x = $2; }
elsif ($value !~ /\./) { $x =''; $value .= '.'; }
$value = $value.'0' x ( $fig - length($x) );
return $value;
}
[ home / cgi / juggler / column / diary / bbs / link / welcome ]