0) { $firstVisit = false; } $trials = 1000; $damage1 = 9; $chance1 = 100; $damage2 = 5; $chance2 = 70; $damage3 = 25; $chance3 = 30; $alert = ""; if (array_key_exists('damage1', $_POST) && is_numeric($_POST['damage1'])) { $damage1 = max(1, $_POST['damage1']); } if (array_key_exists('damage2', $_POST) && is_numeric($_POST['damage2'])) { $damage2 = max(1, $_POST['damage2']); } if (array_key_exists('chance3', $_POST) && is_numeric($_POST['chance3'])) { if ( $_POST['chance3'] <= 0) { $alert .= "Alert: Chance of weapon 3 was less than or equal to 0%.
\n"; } elseif ($_POST['chance3'] > 100) { $alert .= "Alert: Chance of weapon 3 was greater than 100%.
\n"; } $chance3 = max(0.1, $_POST['chance3']); $chance3 = min($chance3, 100); } $totalDamage1 = 0; $totalDamage2 = 0; $totalDamage3 = 0; ?>

Puzzle 2

You are an assistant game designer working on a RPG and you need to ensure each weapon below is balanced.
Set the proper numbers to ensure each weapon does the same amount of damage, on average.
Note: Not all of the numbers are editable.

\n"; echo "After ".$trials." tries, the average damage done by Weapon 2 was "; echo round($totalDamage2/$trials, 1)." damage.
\n"; echo "After ".$trials." tries, the average damage done by Weapon 3 was "; echo round($totalDamage3/$trials, 1)." damage.
\n"; echo "
\n"; } ?>
Weapon Damage Dealt Chance of hitting (%)
Weapon 1
Weapon 2
Weapon 3


Back to Puzzle List