Created
July 16, 2018 19:36
-
-
Save Jorenm/b69dd505d6300d1689895df92c81230c to your computer and use it in GitHub Desktop.
Brute force the CRA math for trencher long gunners.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<script> | |
var iterations = 100000; | |
var totalDamage = 0; | |
var getRoll = function() { | |
var diceOne = Math.floor(Math.random() * 6) + 1; | |
var diceTwo = Math.floor(Math.random() * 6) + 1; | |
return diceOne + diceTwo; | |
} | |
var cra = function(bonus) { | |
var roll = getRoll(); | |
// Reroll bad rolls. | |
if (roll < 7) | |
roll = getRoll(); | |
var damage = 10 + bonus + roll; | |
return damage; | |
}; | |
var runTest = function(craSize, arm) { | |
totalDamage = 0; | |
for (var i = 0; i<iterations; i++) { | |
var damage = Math.max(cra(craSize) - arm, 0); | |
totalDamage += damage; | |
} | |
var average = totalDamage / iterations; | |
return average | |
}; | |
var arm = 18; | |
var average = runTest(11, arm); | |
console.log('Average: ' + average); | |
average = runTest(5, arm) + runTest(6, arm); | |
console.log('Average: ' + average); | |
average = runTest(4, arm) + runTest(4, arm) + runTest(3, arm); | |
console.log('Average: ' + average); | |
average = runTest(3, arm) + runTest(3, arm) + runTest(3, arm) + runTest(2, arm); | |
console.log('Average: ' + average); | |
average = runTest(2, arm) + runTest(2, arm) + runTest(2, arm) + runTest(2, arm) + runTest(3, arm); | |
console.log('Average: ' + average); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment