Skip to content

Commit

Permalink
Merge pull request #3645 from wowsims/apl
Browse files Browse the repository at this point in the history
Reorder functions in sim.go for readability, and 2 small fixes to acc…
  • Loading branch information
jimmyt857 authored Sep 9, 2023
2 parents b76eade + 33f2677 commit 393f722
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
86 changes: 43 additions & 43 deletions sim/core/sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,37 +227,6 @@ func (sim *Simulation) Init() {
}
}

// Reset will set sim back and erase all current state.
// This is automatically called before every 'Run'.
func (sim *Simulation) reset() {
if sim.Log != nil {
sim.Log("SIM RESET")
sim.Log("----------------------")
}

if sim.Encounter.DurationIsEstimate && sim.CurrentTime != 0 {
sim.BaseDuration = sim.CurrentTime
sim.Encounter.DurationIsEstimate = false
}
sim.Duration = sim.BaseDuration
if sim.DurationVariation != 0 {
variation := sim.DurationVariation * 2
sim.Duration += time.Duration(sim.RandomFloat("sim duration")*float64(variation)) - sim.DurationVariation
}

sim.pendingActions = make([]*PendingAction, 0, 64)

sim.executePhase = 0
sim.nextExecutePhase()
sim.executePhaseCallbacks = nil

sim.CurrentTime = 0

sim.Environment.reset(sim)

sim.initManaTickAction()
}

// Run runs the simulation for the configured number of iterations, and
// collects all the metrics together.
func (sim *Simulation) run() *proto.RaidSimResult {
Expand Down Expand Up @@ -324,13 +293,43 @@ func (sim *Simulation) run() *proto.RaidSimResult {
return result
}

func (sim *Simulation) runPendingActions(max time.Duration) {
for {
finished := sim.Step(max)
if finished {
return
}
// RunOnce is the main event loop. It will run the simulation for number of seconds.
func (sim *Simulation) runOnce() {
sim.reset()
sim.PrePull()
sim.runPendingActions(NeverExpires)
sim.Cleanup()
}

// Reset will set sim back and erase all current state.
// This is automatically called before every 'Run'.
func (sim *Simulation) reset() {
if sim.Log != nil {
sim.Log("SIM RESET")
sim.Log("----------------------")
}

if sim.Encounter.DurationIsEstimate && sim.CurrentTime != 0 {
sim.BaseDuration = sim.CurrentTime
sim.Encounter.DurationIsEstimate = false
}
sim.Duration = sim.BaseDuration
if sim.DurationVariation != 0 {
variation := sim.DurationVariation * 2
sim.Duration += time.Duration(sim.RandomFloat("sim duration")*float64(variation)) - sim.DurationVariation
}

sim.pendingActions = make([]*PendingAction, 0, 64)

sim.executePhase = 0
sim.nextExecutePhase()
sim.executePhaseCallbacks = nil

sim.CurrentTime = 0

sim.Environment.reset(sim)

sim.initManaTickAction()
}

func (sim *Simulation) PrePull() {
Expand Down Expand Up @@ -380,12 +379,13 @@ func (sim *Simulation) Cleanup() {
}
}

// RunOnce is the main event loop. It will run the simulation for number of seconds.
func (sim *Simulation) runOnce() {
sim.reset()
sim.PrePull()
sim.runPendingActions(NeverExpires)
sim.Cleanup()
func (sim *Simulation) runPendingActions(max time.Duration) {
for {
finished := sim.Step(max)
if finished {
return
}
}
}

func (sim *Simulation) Step(max time.Duration) bool {
Expand Down
2 changes: 1 addition & 1 deletion sim/rogue/rogue.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (rogue *Rogue) Initialize() {

rogue.finishingMoveEffectApplier = rogue.makeFinishingMoveEffectApplier()

if rogue.Rotation.TricksOfTheTradeFrequency != proto.Rogue_Rotation_Never && !rogue.HasSetBonus(Tier10, 2) {
if !rogue.IsUsingAPL && rogue.Rotation.TricksOfTheTradeFrequency != proto.Rogue_Rotation_Never && !rogue.HasSetBonus(Tier10, 2) {
rogue.RegisterPrepullAction(-10*time.Second, func(sim *core.Simulation) {
rogue.TricksOfTheTrade.Cast(sim, nil)
})
Expand Down
4 changes: 4 additions & 0 deletions sim/warlock/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ func (warlock *Warlock) setupImprovedSoulLeech() {
}

func (warlock *Warlock) updateDPASP(sim *core.Simulation) {
if sim.CurrentTime < 0 {
return
}

dpspCurrent := warlock.DemonicPactAura.ExclusiveEffects[0].Priority
currentTimeJump := sim.CurrentTime.Seconds() - warlock.PreviousTime.Seconds()

Expand Down

0 comments on commit 393f722

Please sign in to comment.