[ source / home ]


source : 花伝説-30


#!/usr/bin/perl
# 花伝説-30 シミュレーション

$cginame = 'hana30.cgi';
$title   = '花伝説-30 シミュレーション';

if ($ENV{'REQUEST_METHOD'} eq 'POST') {
    read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
}
print "Content-Type: text/html\n\n";

foreach (split(/&/,$input)) {
    ($name,$value) = split(/=/, $_);
    push(@input, $value);
}
($s, $play, $mode, $stock, $int, $start) = @input;
$def_mode  = $mode;
$def_stock = $stock;

$int = 0 if !$int;
$int_chk[$int] = 'checked';
$stock = 0 if (!$stock);
$ten   = ($start) ? $start : 1500;


# ヘッダとフォームの表示
print <<"__ FORM __";
<!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'>
<div align='right'>[ <a href='../simu_data_hana30.html'>data</a> / <a href='hana30_memo.html'>memo</a> / <a href='hana30.html'>source</a> / <a href='../index.html'>home</a> ]</div>
<br><br>
<div align='center'><h2>$title</h2></div>
<hr width='70%'><center><form action='$cginame' method='POST'>
<table border=0>
<tr><td>設定</td><td><input type='text' maxlength=1  name='s' size=14 value='$s'></td></tr>
<tr><td>試行ゲーム数</td><td><input type='text' size=14 name='play' maxlength=4 value='$play'></td></tr>
<tr><td>最初のモード</td><td><input type='text' size=14 name='mode' maxlength=4 value='$mode'></td></tr>
<tr><td>最初のストック数</td><td>BIG <input type='text' size=4 name='b_stock' maxlength=3 value='$stock'></td></tr>
<tr><td><font size=2>内部ボーナス<br>の表\示</font></td><td><input type='radio' name='int' value=0 $int_chk[0]> 無
 <input type='radio' name='int' value=1 $int_chk[1]> 有</td></tr>
</table><br>
<input type='submit' value="開始">
</form>

<font size=2>設定、モードは 1 〜 6 までの数値を入力。<br>
最初のモードを記入しない場合、朝イチモード( モード1 )になります。<br><br>
モード解説。<b>1</b>:朝イチ <b>2</b>:超天国 <b>3</b>:高放出 <b>4</b>:単発放出 <b>5</b>:通常 <b>6</b>:低放出<br>
</font></center><br><br>
__ FORM __


# エラーチェックとGET送信
if (!$s or !$play) { $error = 1; $er_msg = '記入漏れがあります。'; }
if ($mode<1 or $mode>6) { $s_mode = 1; }
if (grep { /[^\d]/ } ($s, $play, $mode, $stock)) { $error = 1; $er_msg = '不適切な文字が記入されています。'; };

if ($ENV{'REQUEST_METHOD'} ne 'POST') { $error = 1; $er_msg = 0; }
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='../simu_data_hana30.html'>data</a> / <a href='hana30_memo.html'>memo</a> / <a href='hana30.html'>source</a> / <a href='../index.html'>home</a> ]</div>};
    exit;

}

# data
@big  = (173,275,275,275,275,275); $big = $big[$s-1]; #/65536
@reg  = (100,108,116,126,136,137); $reg = $reg[$s-1];
$bell = 7800; $suika = 100; $che = 235;
$rep  = 8980;

$reprt[1] = '57126 55728 56328 56328 57126 57126 56128'; # 左から mode1~6,天井到達時 の順 /65536
$reprt[2] = '57016 55618 56218 56218 57016 57016 56018';
$reprt[3] = '57008 55610 56210 56210 57008 57008 56010';
$reprt[4] = '56998 55600 56200 56200 56998 56998 56000';
$reprt[5] = '56988 55590 56190 56190 56988 56988 55990';
$reprt[6] = '56987 55589 56189 56189 56987 56987 55989';
@reprt = split(/ /, $reprt[$s]);
@repc  = (4,77,50,50,7,1); # リプが揃った時の解除確率 /256
$bigget = 388.141; $regget=112+15;

# モード振り分け /65536 , の区切りは左から設定1〜設定6の順
@b0 = ('0 1 5243 6554 5898 47840','0 1 2621 9175 14415 39324','0 1 6554 6554 7864 44563','0 1 2621 11796 14415 36703','0 1 7864 6554 11796 39321','0 1 3276 13107 19660 29492');
$b1 = '0 58983 1 1 6550 1'; # 全設定共通
@b2 = ('0 1 45878 1 9830 9826','0 1 45878 1 6553 13103','0 1 45878 1 9830 9826','0 1 45878 1 9831 9825','0 1 45878 1 13107 6549','0 1 45878 1 9831 9825');
@b3 = ('0 1 1 1 14746 50787','0 1 1 1 21845 43688','0 1 1 1 18022 47511','0 1 1 1 29491 36042','0 1 1 1 22937 42596','0 1 1 1 29491 36042');
@b4 = ('0 1 13108 1 1 52425','0 1 5243 13108 1 47183','0 1 16384 1 1 49149','0 1 5243 22937 1 37354','0 1 22937 1 1 42596','0 1 5243 22937 1 37354');
@b5 = ('0 1 5243 6554 5898 47840','0 1 2621 9175 14415 39324','0 1 6554 6554 7864 44563','0 1 2621 16384 14415 32115','0 1 7864 6554 11796 39321','0 1 5243 16384 19660 24248');
$r0 = '49147 656 656 15075 1 1'; # 全設定共通
$r1 = '0 65532 1 1 1 1';
$r2 = '0 1 65532 1 1 1';
$r3 = '0 1 1 65532 1 1';
@r4 = ('0 5243 1 16384 43907 1','0 1311 1 19661 44562 1','0 5243 1 16384 43907 1','0 1311 1 19661 44562 1','0 5243 1 16384 43907 1','0 1311 1 19661 44562 1');
@r5 = ('0 656 656 15075 1 49148','0 656 656 19661 1 44562','0 656 656 15075 1 49148','0 656 656 19661 1 44562','0 656 656 15075 1 49148','0 656 656 19661 1 44562');

$mtb[0] = $b0[$s-1]; $mtb[1] = $b1;       $mtb[2] = $b2[$s-1];
$mtb[3] = $b3[$s-1]; $mtb[4] = $b4[$s-1]; $mtb[5] = $b5[$s-1];
$mtr[0] = $r0; $mtr[1] = $r1; $mtr[2] = $r2; $mtr[3] = $r3; $mtr[4] = $r4[$s-1]; $mtr[5] = $r5[$s-1];

print <<"__ HTML __";
<br><br><table border=1 cellspacing=0 align='center'><caption>シミュレーション結果</caption>
<tr align='center' bgcolor='#ffffcc'><td><font size=2>ゲーム数</font></td><td><font size=2>当選</font></td>
<td><font size=2>備考</font></td><td><font size=2>mode</font></td><td><font size=2>BIG<br>回数</font></td>
<td><font size=2>REG<br>回数</font></td><td><font size=2>ストック数</font></td><td><font size=2>投資</font></td>
<td><font size=2>コイン</font></td><td><font size=2>総ゲーム数</td></tr>
__ HTML __


#----------------------
#  シミュレート開始
#----------------------
$g = $count = $bigcount = $regcount = $coin = 0;
$s_mode = $mode; $mode--; $msg=' ';
$rt = ($stock) ? 1 : 0;

while (1) {
    $g++; $count++;
    if ($coin < 3) { $coin += 50; $k++; $totalk++; }
    $coin -= 3;

    $delay_p-- if $delay_p;
    $rt = 0 if ($rt_cancel && !$delay_p);

    $repr = ($rt) ? $reprt[$mode] : $rep;
    $repr = $reprt[6] if ($count >= $ten);
    $r = int(rand(65536)+1);

    if ($r<=$repr) { # replay
        if (!$rt) { $coin += 3; next; }
        else { # RT中
            if ($delay) { # 前兆 RT
                $r = int(rand(256)+1);
                if (($delay==1 && $r<=128) or ($delay==2 && $r<=240) or ($delay==3 && $r<=41)) { $coin += 3; next; }
            } else {  # 揃うリプレイとリプ解除の抽選
                $r = int(rand(8192)+1);
                if($r <= 1320) { # 揃うリプレイ
                    $coin += 3; $r = int(rand(256)+1);
                     if ($r<=$repc[$mode] && $stock) {
                         $rt_cancel = 1; $msg = '<font size=2 color=\'blue\'>リプ解除</font>';
                         $delay_p = 7+1; $r = int(rand(256)+1); $delay = ($r<=64) ? 1 : 2;
                     }
                }
            }
        }
    } elsif ($r <= ($repr+$bell)) { $coin += 8; next; } # bell
    elsif ($r <= ($repr+$bell+$che)) { # che
        $coin += 1.5;  # 振り分け不明
        $r = int(rand(256)+1);
        if ($r<=84 && $stock && !$delay) {
            $rt_cancel = 1; $msg = '<font size=2 color=\'red\'>チェリー解除</font>';
            $delay_p = 7+1; $r = int(rand(256)+1);
            $delay = ($r <= 86) ? 1 : ($r<=86+85) ? 2 : 3;
        }
    } elsif ($r <= ($repr+$bell+$che+$suika)) { $coin += 12; next; } # suika
    elsif ($r <= ($repr+$bell+$che+$suika+$big)) { # 内部 BIG
        $rt = 1 if (!$rt && !$rt_cancel);
        $stock++;
        if ($int) {
            print "<tr align='center' bgcolor='#eeefef'><td>($count)</font></td><td><font size=2>内部 777</font></td>";
            print "<td> </td><td> </td><td> </td><td> </td><td>$stock</td><td> </td><td> </td><td>$g</td></tr>\n";
        }
    } elsif ($r<=($repr+$bell+$che+$suika+$big+$reg) && !$rt_cancel) { $flag = 1; }  # REG (ストックしない)
    else {  # haz
        if($rt) {
            $rt_cancel = 1; $delay_p = 0;
            $msg = '<font size=2 color=\'#009900\'>純ハズレ解除</font>';
        }
    }


    if ($flag or ($rt_cancel && !$delay_p)) {
        if ($flag) { $regcount++; $coin += $regget; $get = '<b>REG</b>'; }
        else {
            $bigcount++; $coin += $bigget; $stock--;
            $get = '<font color=\'blue\' face=\'Arial black\'><b>777</font></b>';
            $rt = ($stock) ? 1 : 0;
        }

        # mode 移行
        @tbl = ($rt_cancel) ? split(/ /, $mtb[$mode]) : split(/ /, $mtr[$mode]);
        $r = int(rand(65536)+1);
        $i = 0; $x = $tbl[0];
        while ($r > $x) { $i++; $x += $tbl[$i]; }
        $mode = $i;

        $k = ($k > 0) ? "$k".'k' : ' ';

        $opt  = ($count < 100) ? '<font color=\'blue\'><b>' : ($count>=500 && $count<1000) ? '<font color=\'red\'>'
              : ($count>=1000) ? '<font color=\'red\'><b>'  :  '';
        $optc = ($count < 100) ? '</b></font>'              : ($count>=500 && $count<1000) ? '</font>'
              : ($count>=1000) ? '</b></font>'              :  '';

        $coin_d = int($coin);
        $m_d    = $mode+1;
        $s_mode ='' if (($bigcount+$regcount) > 1);

        $opt2  = ($m_d == 4) ? '<font color=\'blue\'>' : ($m_d == 3) ? '<font color=\'red\'>'
               : ($m_d == 2) ? '<font color=\'red\'><b>'  :  '';
        $opt2c = ($m_d==4 or $m_d==3) ? '</font>' : ($m_d == 2) ? '</b></font>'  :  '';

        if ($bigcount) { $b_prob = int($g/$bigcount+0.5); $b_prob = "(1/$b_prob)"; }
        if ($regcount) { $r_prob = int($g/$regcount+0.5); $r_prob = "(1/$r_prob)"; }

        print "<tr align='center'><td>$opt $count $opt_c</font></td><td>$get</td><td>$msg</td>";
        print "<td>$s_mode →$opt2 $m_d $opt2_c</td><td><font color='blue'>$bigcount</font> $b_prob</td>";
        print "<td><font color='blue'>$regcount</font> $r_prob</td><td>$stock</td>";
        print "<td>$k</td><td>$coin_d</td><td>$g</td></tr>\n";
        $k = ''; $count = $flag = $rt_cancel = $delay = $delay_p = 0; $msg = ' ';
    }

    if($g >= $play) {
        $k = ($k > 0) ? $k.'k' : ' ';
        $coin_d = int($coin);
        $mode_d = $mode+1;
        if ($bigcount) { $b_prob = int($g/$bigcount+0.5); $b_prob = "(1/$b_prob)"; }
        if ($regcount) { $r_prob = int($g/$regcount+0.5); $r_prob = "(1/$r_prob)"; }

        print "<tr align='center'><td>$count</td><td align='center'>ヤメ</td><td> </td>";
        print "<td align='center'>$mode_d</td><td><font color='blue'>$bigcount</font> $b_prob</td>";
        print "<td><font color='blue'>$regcount</font> $r_prob</td><td>$stock</td>";
        print "<td>$k</td><td>$coin_d</td><td>$g</td></tr>\n";
        last;
    }
}

# シミュデータの整理
$coin   = int($coin);
$toushi = $totalk * 1000;
$kankin = $coin * 20;
$shushi = $kankin - $toushi;
$opt3   = ($shushi >= 0) ? 'blue' : 'red';
$payout = ($coin-($totalk * 50))/($g * 3)*100+100;
$payout = &point($payout,2);
if ($bigcount) { $b_prob = &point(($g/$bigcount),2); $b_prob = "(1/$b_prob)"; }
if ($regcount) { $r_prob = &point(($g/$regcount),2); $r_prob = "(1/$r_prob)"; }

# 整理したデータの表示
print <<"__ RESULT __";
</table><br><br>
<table border=1 align='center' cellspacing=0>
<tr align='center' bgcolor='#ffffcc'><td colspan=2><b>花伝説-30 設定 $s</b></td></tr>
<tr><td>総プレイ数</td><td align='right'>$g P</td></tr>
<tr><td>BIG</td><td align='right'><b>$bigcount $b_prob</b></td></tr>
<tr><td>REG</td><td align='right'><b>$regcount $r_prob</b></td></tr>
<tr><td>投資</td><td align='right'>$toushi 円</td></tr>
<tr><td>獲得枚数</td align='right'><td align=right><b>$coin_d 枚</td></tr>
<tr><td>換金</td><td align='right'>$kankin 円</td></tr>
<tr><td>収支</td><td align='right'><font color='$opt3'><b>$shushi 円</b></font></td></tr>
<tr><td>PAYOUT</td><td align='right'><b>$payout %</b></td></tr>
</table>
__ RESULT __

# 再試行ボタン、フッタの表示
$start = 1500 - $count;
$mode++;

print <<"__ END __";
<br><br><table border=0 align='center' cellspacing=5>
<tr valign='bottom'><td>
<form action='$cginame' method='POST'>
<input type='hidden' name='s' value='$s'>
<input type='hidden' name='play' value='$play'>
<input type='hidden' name='mode' value='$def_mode'>
<input type='hidden' name='stock' value='$def_stock'>
<input type='hidden' name='int' value='$int'>
<input type='submit' value="再試行">
</form></td><td>

<form action='$cginame' method='POST'>
<input type='hidden' name='s' value='$s'>
<input type='hidden' name='play' value='$play'>
<input type='hidden' name='mode' value='$mode'>
<input type='hidden' name='s_big' value='$stock'>
<input type='hidden' name='int' value='$int'>
<input type='hidden' name='start' value='$start'>
<input type='submit' value="再試行2(据え置き)">
</form></td></tr></table>

<br><br><br><br>
<div align='right'>[ <a href='../simu_data_hana30.html'>data</a> / <a href='hana30_memo.html'>memo</a> / <a href='hana30.html'>source</a> / <a href='../index.html'>home</a> ]</div>
</body></html>
__ END __

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;
}


[ source / home ]