Skip to content

Commit

Permalink
fixed possible endless loop in optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
lologarithm committed Apr 6, 2021
1 parent ed52095 commit 68aa2c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
15 changes: 13 additions & 2 deletions tbc/optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func OptimalRotation(stats Stats, opts Options, equip Equipment, seconds int, nu

topDmg := 0.0
topNLB := 0
topRot := []string{}
topMets := []SimMetrics{}

numLB := 10

Expand Down Expand Up @@ -52,15 +54,24 @@ func OptimalRotation(stats Stats, opts Options, equip Equipment, seconds int, nu
if simdmg > topDmg {
topNLB = numLB
topDmg = simdmg
topMets = simmet
topRot = rotation
}

avgOOM := float64(numoom) / float64(numSims)
fmt.Printf("(%d LB: 1 CL) %0.0f DPS OOM: %0.0f percent\n", numLB, simdmg/float64(seconds)/float64(numSims), avgOOM*100)

if numLB == minLB || numLB == maxLB {
fmt.Printf("Hit bounds of sim... Found: %0.0f DPS (%d LB : 1 CL)\n", simdmg/float64(seconds)/float64(numSims), numLB)
if simdmg >= topDmg {
return simmet, rotation
}
return topMets, topRot
}
// avgOOMAt := int(float64(oomat) / float64(numoom))
if avgOOM < 0.1 {
newLB := (numLB + minLB) / 2
if numLB-minLB == 1 { // im lazy and this is easy to write...
if numLB-minLB <= 1 { // im lazy and this is easy to write...
newLB = minLB
}
if newLB == numLB {
Expand All @@ -76,7 +87,7 @@ func OptimalRotation(stats Stats, opts Options, equip Equipment, seconds int, nu
newLB := (numLB + maxLB) / 2
if maxLB-numLB <= 1 { // im lazy and this is easy to write...
newLB = maxLB
} else if avgOOM > 0.85 {
} else if avgOOM > 0.9 {
newLB = (newLB + maxLB) / 2 // skip ahead
}

Expand Down
5 changes: 3 additions & 2 deletions tbc/sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ func (sim *Simulation) Cast(cast *Cast) {
dmg *= 1 + (0.01 * sim.Options.Talents.Concussion)
}

// Average Resistance = (Target's Resistance / (Caster's Level * 5)) * 0.75 "AR"
// P(x) = 50% - 250%*|x - AR| <- where X is chance of resist
// Average Resistance (AR) = (Target's Resistance / (Caster's Level * 5)) * 0.75
// P(x) = 50% - 250%*|x - AR| <- where X is %resisted
// For now hardcode the 25% chance resist at 2.5% (this assumes bosses have 0 nature resist)
// .... Using level 70 shows a 0.35% chance of resist instead of 2.5%... not sure what is correct.
if sim.rando.Float64() < 0.025 { // chance of 25% resist
dmg *= .75
if IsDebug {
Expand Down
Binary file modified ui/lib.wasm
Binary file not shown.

0 comments on commit 68aa2c1

Please sign in to comment.