jug7.com
[ home / cgi / juggler / column / diary / bbs / link / welcome ]
source : サンダーVSPタイプ 天井狙いの機械割計算
#!/usr/bin/perl
# サンダーVスペシャル方式の天井狙いの機械割を計算
$cginame = 'calc_pay_ceiling_type_thundervsp.cgi';
$title = 'サンダーVSPタイプ 天井狙いの機械割計算';
# データの読みこみ
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
}
foreach $str (split(/&/,$input)) {
($name,$value) = split(/=/, $str);
push(@input, $value);
}
($pb1, $cb1, $pb2, $cb2, $pb3, $cb3, $c_dec, $c_inc,
$p1, $c1, $p2, $c2, $p3, $c3, $p4, $c4, $p5, $c5, $p6, $c6, $p7, $c7, $p8, $c8, $p9, $c9,
$p1c, $c1c, $p2c, $c2c, $p3c, $c3c, $p4c, $c4c, $p5c, $c5c, $p6c, $c6c, $p7c, $c7c, $p8c, $c8c, $p9c, $c9c, $ceiling, $start) = @input;
$start = 0 if $start eq '';
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'>
<font size=7><b><font face='Times New Roman,Times'>jug</font><font face='Bookman Old Style,arial black,Helvetica Black'>7</font><font face='Times New Roman,Times'>.com</font></b></font>
<hr color='#00aa00'>
<strong>[ <a href='../index.html'>home</a> / <a href='index.html'>cgi</a> / <a href='../jug/index.html'>juggler</a> / <a href='../column.html'>column</a> / <a href='../diary/index.html'>diary</a> / <a href='bbs.cgi'>bbs</a> / <a href='../link.html'>link</a> / <a href='../intro.html'>welcome</a> ]</strong>
<br><br><br>
<div align='center'><h2>$title</h2></div>
<hr width='70%'>
<div align='right'>[ <a href='calc_pay_ceiling_type_thundervsp_memo.html'>memo</a> / <a href='calc_pay_ceiling_type_thundervsp.html'>source</a> ]</div>
<center>
<form action='$cginame' method='POST'>
<br>
<table border=1 align='center' cellspacing=0 cellpadding=3>
<caption><b>ボーナス関連</b></caption>
<tr align='center' bgcolor='#ffffcc'><td colspan=2><b>ボーナス 1</b></td><td colspan=2><b>ボーナス 2</b></td><td colspan=2><b>ボーナス 3</b></td></tr>
<tr align='center' bgcolor='#ffffcc'><td>確率</td><td>純増枚数</td><td>確率</td><td>純増枚数</td><td>確率</td><td>純増枚数</td></tr>
<tr align='center'>
<td>1/ <input type='text' size=12 name='pb1' value='$pb1'></td><td><input type='text' size=12 name='cb1' value='$cb1'> 枚</td>
<td>1/ <input type='text' size=12 name='pb2' value='$pb2'></td><td><input type='text' size=12 name='cb2' value='$cb2'> 枚</td>
<td>1/ <input type='text' size=12 name='pb3' value='$pb3'></td><td><input type='text' size=12 name='cb3' value='$cb3'> 枚</td>
</tr></table>
<br>
<table border=1 align='center' cellspacing=0 cellpadding=3>
<caption><b>コイン持ち関連</b></caption>
<caption align='bottom'><font color='red'>1 か 2 のどちらかひとつの欄を入力。</font><br><font size=2>1, 2 両方とも記入された場合は、1 を優先。<br>2 を入力する時は、リプレイも忘れずに (リプレイ = 3 枚)。</font></caption>
<tr align='center' bgcolor='#ffffcc'><td> </td><td><b>通常時の1P当たりのコイン減少</b></td><td><b>天井後の1P当たりのコイン増加</b></td></tr>
<tr align='center'><td>1</td><td><b>-</b> <input type='text' size=10 name='c_dec' value='$c_dec'> 枚</td><td><b>+</b> <input type='text' size=10 name='c_inc' value='$c_inc'> 枚</td></tr>
<tr align='center'><td>2</td>
<td>小役1 1/ <input type='text' size=10 name='p1' value='$p1'> <input type='text' size=5 name='c1' value='$c1'> 枚<br>
小役2 1/ <input type='text' size=10 name='p2' value='$p2'> <input type='text' size=5 name='c2' value='$c2'> 枚<br>
小役3 1/ <input type='text' size=10 name='p3' value='$p3'> <input type='text' size=5 name='c3' value='$c3'> 枚<br>
小役4 1/ <input type='text' size=10 name='p4' value='$p4'> <input type='text' size=5 name='c4' value='$c4'> 枚<br>
小役5 1/ <input type='text' size=10 name='p5' value='$p5'> <input type='text' size=5 name='c5' value='$c5'> 枚<br>
小役6 1/ <input type='text' size=10 name='p6' value='$p6'> <input type='text' size=5 name='c6' value='$c6'> 枚<br>
小役7 1/ <input type='text' size=10 name='p7' value='$p7'> <input type='text' size=5 name='c7' value='$c7'> 枚<br>
小役8 1/ <input type='text' size=10 name='p8' value='$p8'> <input type='text' size=5 name='c8' value='$c8'> 枚<br>
小役9 1/ <input type='text' size=10 name='p9' value='$p9'> <input type='text' size=5 name='c9' value='$c9'> 枚<br>
</td>
<td>小役1 1/ <input type='text' size=10 name='p1c' value='$p1c'> <input type='text' size=5 name='c1c' value='$c1c'> 枚<br>
小役2 1/ <input type='text' size=10 name='p2c' value='$p2c'> <input type='text' size=5 name='c2c' value='$c2c'> 枚<br>
小役3 1/ <input type='text' size=10 name='p3c' value='$p3c'> <input type='text' size=5 name='c3c' value='$c3c'> 枚<br>
小役4 1/ <input type='text' size=10 name='p4c' value='$p4c'> <input type='text' size=5 name='c4c' value='$c4c'> 枚<br>
小役5 1/ <input type='text' size=10 name='p5c' value='$p5c'> <input type='text' size=5 name='c5c' value='$c5c'> 枚<br>
小役6 1/ <input type='text' size=10 name='p6c' value='$p6c'> <input type='text' size=5 name='c6c' value='$c6c'> 枚<br>
小役7 1/ <input type='text' size=10 name='p7c' value='$p7c'> <input type='text' size=5 name='c7c' value='$c7c'> 枚<br>
小役8 1/ <input type='text' size=10 name='p8c' value='$p8c'> <input type='text' size=5 name='c8c' value='$c8c'> 枚<br>
小役9 1/ <input type='text' size=10 name='p9c' value='$p9c'> <input type='text' size=5 name='c9c' value='$c9c'> 枚<br>
</td>
</tr></table>
<br>
<table border=1 align='center' cellspacing=0 cellpadding=3>
<tr><td><b>天井発動プレイ</b></td><td><input type='text' size=10 name='ceiling' value='$ceiling' maxlength=4> P から発動。</td></tr>
<tr><td><b>開始プレイ</b></td><td><input type='text' size=10 name='start' value='$start' maxlength=4> P から打ち始め。</td></tr>
</table>
<br><br>
<input type=submit value="開始"></center>
</form>
__ HTML __
# エラーチェック と GET での送信
if ($ENV{'REQUEST_METHOD'} ne 'POST') { $error = 1; $er_msg = 0; }
if (grep { /[^\d\.]/ } @input) { $error = 1; $er_msg = '不適切な文字が記入されています。'; };
if ($er_msg) {
print q{<center><b><font color='red' size=4>*** ERROR !! ***</font><br><br>},"\n";
print "$er_msg</b></center>\n";
}
if ($error) {
print '<br><br><br><br><br>';
print q{<div align='right'>[ <a href='calc_pay_ceiling_type_thundervsp_memo.html'>memo</a> / <a href='calc_pay_ceiling_type_thundervsp.html'>source</a> ]</div>};
print q{<strong>[ <a href='../index.html'>home</a> / <a href='index.html'>cgi</a> / <a href='../jug/index.html'>juggler</a> / <a href='../column.html'>column</a> / <a href='../diary/index.html'>diary</a> / <a href='bbs.cgi'>bbs</a> / <a href='../link.html'>link</a> / <a href='../intro.html'>welcome</a> ]</strong>};
print '</body></html>';
exit;
}
#--------------
# 計算開始
#--------------
if (!$c_dec) {
$dec1 = 1/$p1 * $c1 if $p1; $dec2 = 1/$p2 * $c2 if $p2; $dec3 = 1/$p3 * $c3 if $p3;
$dec4 = 1/$p4 * $c4 if $p4; $dec5 = 1/$p5 * $c5 if $p5; $dec6 = 1/$p6 * $c6 if $p6;
$dec7 = 1/$p7 * $c7 if $p7; $dec8 = 1/$p8 * $c8 if $p8; $dec9 = 1/$p9 * $c9 if $p9;
$c_dec = 3 - ($dec1+$dec2+$dec3+$dec4+$dec5+$dec6+$dec7+$dec8+$dec9);
$c_dec = &point($c_dec,3);
print "<center>通常時 1P 当たりのコイン減少 <b>$c_dec 枚</b></center>";
}
if (!$c_inc) {
$inc1 = 1/$p1c * $c1c if $p1c; $inc2 = 1/$p2c * $c2c if $p2c; $inc3 = 1/$p3c * $c3c if $p3c;
$inc4 = 1/$p4c * $c4c if $p4c; $inc5 = 1/$p5c * $c5c if $p5c; $inc6 = 1/$p6c * $c6c if $p6c;
$inc7 = 1/$p7c * $c7c if $p7c; $inc8 = 1/$p8c * $c8c if $p8c; $inc9 = 1/$p9c * $c9c if $p9c;
$c_inc = $inc1+$inc2+$inc3+$inc4+$inc5+$inc6+$inc7+$inc8+$inc9 -3;
$c_inc = &point($c_inc,3);
print "<center>天井後 1P 当たりのコイン増加 <b>$c_inc 枚</b></center>";
}
print '<br><br>';
$pb1 = 1/$pb1 if $pb1;
$pb2 = 1/$pb2 if $pb2;
$pb3 = 1/$pb3 if $pb3;
$b_prob = $pb1 + $pb2 + $pb3;
$b_coin = ($pb1 * $cb1 + $pb2 * $cb2 + $pb3 * $cb3) * 1/$b_prob;
$c_dec = -$c_dec;
$start2 = ($start < $ceiling) ? $ceiling-$start : 0;
for ($i=1; $i<=20000; $i++) {
$p = $b_prob * (1-$b_prob)**($i-1);
if ($i <= $start2) { $coin = $c_dec * $i; }
else { $coin = $c_dec * $start2 + $c_inc * ($i-$start2); }
$toushi += $p * $coin;
$coin += $b_coin - 3;
$ave_coin += $p * $coin;
}
$toushi2 = -$toushi/50;
$payout = $ave_coin/(1/$b_prob*3)*100 + 100 if (1/$b_prob);
$toushi2 = &point($toushi2,3);
$ave_coin = &point($ave_coin,3);
$payout = &point($payout,3);
print "<table border=1 cellspacing=0 align='center'><tr bgcolor='#ffffcc'><td>開始プレイ</td><td>投資額 (k)</td><td>差枚数 (枚)</td><td>機械割 (%)</td>\n";
print "<tr align='right'><td align='left'><b>$start P〜</b></td><td>$toushi2</td><td>$ave_coin</td><td><b>$payout</b></td></tr>\n";
print "</table><br><br><br>";
# フッタ
print <<"__ HTML __";
<div align='right'>[ <a href='calc_pay_ceiling_type_thundervsp_memo.html'>memo</a> / <a href='calc_pay_ceiling_type_thundervsp.html'>source</a> ]</div>
<strong>[ <a href='../index.html'>home</a> / <a href='index.html'>cgi</a> / <a href='../jug/index.html'>juggler</a> / <a href='../column.html'>column</a> / <a href='../diary/index.html'>diary</a> / <a href='bbs.cgi'>bbs</a> / <a href='../link.html'>link</a> / <a href='../intro.html'>welcome</a> ]</strong>
</body></html>
__ 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 ]