|
@@ -0,0 +1,53 @@ |
|
|
|
|
|
import { Asphodice } from "./asphodice" |
|
|
|
|
|
import { Outcomes } from "./asphodice" |
|
|
|
|
|
import { DiceResult } from "./asphodice" |
|
|
|
|
|
|
|
|
|
|
|
interface ItemCount { |
|
|
|
|
|
item: string | number | Outcomes; |
|
|
|
|
|
count: number; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare let ItemCountSet: Array<ItemCount>; |
|
|
|
|
|
|
|
|
|
|
|
let rerollCounts: { [rerolled: string]: number }; |
|
|
|
|
|
let totalCounts: { [total: string]: number }; |
|
|
|
|
|
let balanceCounts: { [balance: string]: number }; |
|
|
|
|
|
|
|
|
|
|
|
let numRolls = 1000000; |
|
|
|
|
|
let maxDice = 10; |
|
|
|
|
|
|
|
|
|
|
|
for (let numDice = 1; numDice <= maxDice; numDice++) { |
|
|
|
|
|
let asphodice = new Asphodice(); |
|
|
|
|
|
rerollCounts = { "true": 0, "false": 0 }; |
|
|
|
|
|
totalCounts = {}; |
|
|
|
|
|
balanceCounts = {}; |
|
|
|
|
|
// count rerolls, totals and outcome balances |
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < numRolls; i++) { |
|
|
|
|
|
let result = asphodice.roll(numDice) |
|
|
|
|
|
|
|
|
|
|
|
if (result.reroll) { |
|
|
|
|
|
rerollCounts.true += 1; |
|
|
|
|
|
} else { |
|
|
|
|
|
rerollCounts.false += 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let total = String(result.total); |
|
|
|
|
|
if (total in totalCounts) { |
|
|
|
|
|
totalCounts[total]++; |
|
|
|
|
|
} else { |
|
|
|
|
|
totalCounts[total] = 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let balance = String(result.balance); |
|
|
|
|
|
if (balance in balanceCounts) { |
|
|
|
|
|
balanceCounts[balance]++; |
|
|
|
|
|
} else { |
|
|
|
|
|
balanceCounts[balance] = 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
console.log(numRolls, "rolls,", numDice, "dice. Reroll counts:", rerollCounts); |
|
|
|
|
|
console.log(numRolls, "rolls,", numDice, "dice. Total counts:", totalCounts); |
|
|
|
|
|
console.log(numRolls, "rolls,", numDice, "dice. Balance counts:", balanceCounts); |
|
|
|
|
|
} |