Skip to content

Commit

Permalink
Fix recursion bug in GetAllAPLValues() and add debug log for energy t…
Browse files Browse the repository at this point in the history
…hresholds
  • Loading branch information
jimmyt857 committed Oct 14, 2023
1 parent f8b2826 commit 10b45b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sim/core/apl_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ func (action *APLAction) GetAllActions() []*APLAction {
func (action *APLAction) GetAllAPLValues() []APLValue {
var values []APLValue
for _, a := range action.GetAllActions() {
values = append(values, a.impl.GetAPLValues()...)
unprocessed := a.impl.GetAPLValues()
if a.condition != nil {
values = append(values, a.condition)
values = append(values, a.condition.GetInnerValues()...)
unprocessed = append(unprocessed, a.condition)
}

for len(unprocessed) > 0 {
next := unprocessed[len(unprocessed)-1]
unprocessed = unprocessed[:len(unprocessed)-1]
values = append(values, next)
unprocessed = append(unprocessed, next.GetInnerValues()...)
}
}
return FilterSlice(values, func(val APLValue) bool { return val != nil })
Expand Down
3 changes: 3 additions & 0 deletions sim/core/apl_actions_casting.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (rot *APLRotation) newActionChannelSpell(config *proto.APLActionChannelSpel
allowRecast: config.AllowRecast,
}
}
func (action *APLActionChannelSpell) GetAPLValues() []APLValue {
return []APLValue{action.interruptIf}
}
func (action *APLActionChannelSpell) IsReady(sim *Simulation) bool {
return action.spell.CanCast(sim, action.target.Get())
}
Expand Down
4 changes: 4 additions & 0 deletions sim/core/energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ func (eb *energyBar) reset(sim *Simulation) {
eb.currentEnergy = eb.maxEnergy
eb.comboPoints = 0
eb.newTickAction(sim, true, sim.Environment.PrepullStartTime())

if eb.cumulativeEnergyDecisionThresholds != nil && sim.Log != nil {
eb.unit.Log(sim, "[DEBUG] APL Energy decision thresholds: %v", eb.energyDecisionThresholds)
}
}

type EnergyCostOptions struct {
Expand Down

0 comments on commit 10b45b2

Please sign in to comment.