roll-dice.php

<?php



$i=0;
$rolls = [1=>0,2=>0,3=>0,4=>0];
$z=0;

set_time_limit(360);

$file = __DIR__.'/dice-rolls'.$_GET['file'].'.sql';
file_put_contents($file,"INSERT INTO rolls (iteration,roll,hits) VALUES ",FILE_APPEND);


$iters = (200000*231);
while($z++<$iters){

    $roll = random_int(1,4);
    $rolls[$roll]++;
    $i++;

    if ($i===231){
        $uuid=uniqid(true);
        // of 231 "rolls" 177 need to be the same number in order for the pokemon thing to come true
        $insert = 
            "('{$uuid}',1,{$rolls[1]}),"
            ."('{$uuid}',2,{$rolls[2]}),"
            ."('{$uuid}',3,{$rolls[3]}),"
            ."('{$uuid}',4,{$rolls[4]})";

            if ($z<$iters)$insert.=',';
            file_put_contents($file,$insert,FILE_APPEND);
            $i=0;
            $rolls = [1=>0,2=>0,3=>0,4=>0];
        }

}

file_put_contents($file,";\n",FILE_APPEND);

?>