// ignore notices since we generate a bunch in calcMultiplier, but that's not an
// actual problem
error_reporting(E_ALL & ~E_NOTICE);
// Dice rolls
$sum = 0;
$minDieSum = 0;
$result = array();
$minDie = array();
$p = array(); // probability of a roll
$pMin = array(); // probability of a min Die roll
$setResult = array();
$setResult = array_pad($setResult, 109, 0);
$setProb = array();
$setProb = array_pad($setProb, 109, 0);
$setBonusResult = array();
$setBonusResult = array_pad($setBonusResult, 25, 0);
$bonusProb = array();
$bonusProb = array_pad($bonusProb, 25, 0);
$validSetCount = 0;
$sumValidBonus = 0;
for ($i = 1; $i <= 6; $i++) {
for ($j = 1; $j <= 6; $j++) {
for ($k = 1; $k <= 6; $k++) {
for ($l = 1; $l <= 6; $l++) {
$minTemp = array($i,$j,$k,$l);
sort($minTemp);
$minDie[$minTemp[1]]++;
$roll = $i + $j + $k + $l - $minTemp[0];
$result[$roll]++;
$sum += $roll;
$minDieSum += $minTemp[1];
}
}
}
}
for ($i = 3; $i < 19; $i++) {
$p[$i] = $result[$i]/1296;
}
for ($i = 1; $i < 7; $i++) {
$pMin[$i] = $minDie[$i]/1296;
}
function modifier($stat) {
return floor(($stat-10)/2);
}
function calcMultiplier($i,$j,$k,$l,$m,$n) {
$matches = array();
$matches[$i]++;
$matches[$j]++;
$matches[$k]++;
$matches[$l]++;
$matches[$m]++;
$matches[$n]++;
rsort($matches);
switch ($matches[0]) {
case 6: return 1;
case 5: return 6;
case 4: if ($matches[1] == 2) { return 15; }
else { return 30; }
case 3: if ($matches[1] == 3) { return 20; }
elseif ($matches[1] == 2) { return 60; }
else { return 120; }
case 2: if ($matches[1] == 1) { return 360; }
elseif ($matches[2] == 2) { return 90; }
else { return 180; }
case 1: return 720;
default: echo "BIG ERROR"; print_r($matches); return 1; // this should never happen
}
echo "BIGGER ERROR"; print_r($matches);
return 1; // this should never happen
}
for ($i = 3; $i <= 18; $i++) {
for ($j = $i; $j <= 18; $j++) {
for ($k = $j; $k <= 18; $k++) {
for ($l = $k; $l <= 18; $l++) {
for ($m = $l; $m <= 18; $m++) {
for ($n = $m; $n <= 18; $n++) {
$bonus = modifier($i) + modifier($j) + modifier($k) +
modifier($l) + modifier($m) + modifier($n);
$maxStat = max($i,$j,$k,$l,$m,$n);
$multiplier = calcMultiplier($i,$j,$k,$l,$m,$n);
$currentSetProb = $multiplier * $p[$i] * $p[$j] *
$p[$k] * $p[$l] * $p[$m] * $p[$n];
$allSetProb += $currentSetProb;
$allSetCount++;
$setSum = $i + $j + $k + $l + $m + $n;
$sumAllBonus += $bonus * $currentSetProb;
$allSetSum += $setSum * $currentSetProb;
if($bonus > 0 && $maxStat > 13) {
$validSetProb += $currentSetProb;
$validSetCount++;
$sumValidBonus += $bonus * $currentSetProb;
$validSetSum += $setSum * $currentSetProb;
$setResult[$setSum]++;
$setBonusResult[$bonus]++;
$setProb[$setSum] += $currentSetProb;
$bonusProb[$bonus] += $currentSetProb;
}
}
}
}
}
}
}
?>
D&D Char creation stats
Roll 4d6, drop the lowest, and sum.
Totals Per Stat
for ($i = 3; $i < 19; $i++) { ?>
occurs times with
0% probability.
} ?>
The average roll is 0
Totals Per Lowest Counted (not dropped) Die
for ($i = 1; $i < 7; $i++) { ?>
occurs times with
0% probability.
} ?>
The average lowest counted die is 0
Found unique total sets, with a total
probability of 0%, with an
average bonus of 0 and average
sum of 0. Probability to get a
valid set is 0%.
Found unique valid sets, with an average
bonus of NAN and
average sum of NAN.
Totals of Valid Sets by Sum of Stats
$tempSum = 0;
for ($i = 62; $i < 109; $i++) {
$temp = $setProb[$i]*100/$validSetProb;
$tempSum += $temp;
?>
occurs times with
0% probability, 0 percentile.
} ?>
Total Prob = %
Totals of Valid Sets by Sum of Bonuses
$tempSum = 0;
for ($i = 1; $i < 25; $i++) {
$temp = $bonusProb[$i]*100/$validSetProb;
$tempSum += $temp;
?>
+ occurs times with
0% probability, 0 percentile.
} ?>
Total Prob = %