Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const stages = 10
- const iterations = 1000000
- const goldCost = 3000
- type State = {
- orbs: number
- free?: boolean
- enhanced?: boolean
- progress: number
- paid: number
- juice: number
- }
- type Dwarf = {
- chance: number
- func: (state: State, value: number) => void
- }
- const dwarvesNormal: Dwarf[] = [
- {
- // Galatur's Hammer
- // Advanced Honing XP increased by 5 times
- chance: 1250,
- func: (state, value) => (state.progress += value * 4)
- },
- {
- // Ghelar's Sword
- // Advanced Honing XP increased by 3 times
- chance: 2500,
- func: (state, value) => (state.progress += value * 2)
- },
- {
- // Kuhumbar's Anvil
- // Advanced Honing XP increased by 30 and Ancestor's Grace has been recharged.
- chance: 1250,
- func: (state) => {
- state.progress += 30
- state.orbs = 6
- }
- },
- {
- // Temer's Chisel
- // Advanced Honing XP increased by 10 and next honing cost is free
- chance: 2500,
- func: (state) => {
- state.progress += 10
- state.free = true
- }
- },
- {
- // Naber's Awl
- // Next Advanced Honing is enhanced and recharges Ancestor's Grace
- chance: 1250,
- func: (state) => {
- state.orbs = 6
- state.enhanced = true
- }
- },
- {
- // Everre's Burin
- // Advanced Honing Level +1
- chance: 1250,
- func: (state) => {
- state.progress = Math.floor(state.progress / 100) * 100 + 100
- }
- }
- ]
- const dwarvesEnhanced: Dwarf[] = [
- {
- // Galatur's Hammer
- // Advanced Honing XP increased by 7 times
- chance: 2000,
- func: (state, value) => (state.progress += value * 6)
- },
- {
- // Ghelar's Sword
- // Advanced Honing XP increased by 5 times
- chance: 2000,
- func: (state, value) => (state.progress += value * 4)
- },
- {
- // Kuhumbar's Anvil
- // Advanced Honing XP increased by 80 and Ancestor's Grace has been recharged.
- chance: 2000,
- func: (state) => {
- state.progress += 80
- state.orbs = 6
- }
- },
- {
- // Temer's Chisel
- // Advanced Honing XP increased by 30 and next honing cost is free
- chance: 2000,
- func: (state) => {
- state.progress += 30
- state.free = true
- }
- },
- {
- // Everre's Burin
- // Advanced Honing Level +2
- chance: 2000,
- func: (state) => {
- state.progress = Math.floor(state.progress / 100) * 100 + 200
- }
- }
- ]
- function step(state: State) {
- const juice = state.orbs >= 6 ? 1 : 0
- const chance2 = 0.15 + 0.15 * juice
- const chance4 = 0.05 + 0.15 * juice
- const roll = Math.random()
- const step = roll < chance4 ? 40 : roll < chance4 + chance2 ? 20 : 10
- const dwarves =
- state.orbs >= 6
- ? state.enhanced
- ? dwarvesEnhanced
- : dwarvesNormal
- : undefined
- state.orbs = state.orbs >= 6 ? 0 : state.orbs + 1
- state.progress += step
- if (!state.free) state.paid += 1
- if (juice) state.juice += 1
- state.free = false
- state.enhanced = false
- if (dwarves) {
- let droll = Math.random() * 10000
- for (const d of dwarves) {
- if (droll < d.chance) {
- d.func(state, step)
- break
- }
- droll -= d.chance
- }
- }
- }
- let totalPaid = 0
- let worstPaid = 0
- let bestPaid = 1000000
- let totalJuice = 0
- for (let i = 0; i < iterations; ++i) {
- const state: State = {
- orbs: 0,
- progress: 0,
- paid: 0,
- juice: 0,
- free: false,
- enhanced: false
- }
- while (state.progress < stages * 100) {
- step(state)
- // console.log(`${state.progress} ${state.orbs}`)
- }
- totalPaid += state.paid
- totalJuice += state.juice
- worstPaid = Math.max(worstPaid, state.paid)
- bestPaid = Math.min(bestPaid, state.paid)
- }
- console.log(`gold: ${(totalPaid / iterations) * goldCost}`)
- console.log(`best gold: ${bestPaid * goldCost}`)
- console.log(`worst gold: ${worstPaid * goldCost}`)
- console.log(`juice: ${totalJuice / iterations}`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement