Icon representing a recipe

Recipe: Mutate-Wiggle loop

created by marsfan

Profile


Name
Mutate-Wiggle loop
ID
103582
Shared with
Public
Parent
None
Children
None
Created on
June 13, 2020 at 05:31 AM UTC
Updated on
June 13, 2020 at 05:31 AM UTC
Description

Performs mutate and then wiggle until an iteration results in no gain.

Does not change any parameters (selected elements, CI, Wiggle Power, Filter States, etc.), allowing users to run without affecting strategy.

Best for


Code


startScore = current.GetEnergyScore() save.Quicksave(90) function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end function cleanup(err) if string.find(err, "Cancelled") then print("User Cancelled") else print(err) end save.Quickload(90) print("Total score increase:", round(current.GetEnergyScore() - startScore, 5)) return err end function main() local iteration = 1 print("Starting Mutate-Wiggle Loops") print("Initial Score:", startScore) repeat local curScore = current.GetEnergyScore() save.Quicksave(90) structure.MutateSidechainsAll(2) structure.WiggleAll(25, true, true) print("Iteration", iteration, "had a gain of", round(current.GetEnergyScore() - curScore, 5), "points") iteration = iteration + 1 until round(current.GetEnergyScore(), 5) == round(curScore, 5) cleanup("No gain in last iteration") end xpcall(main, cleanup)

Comments