Icon representing a recipe

Recipe: Cut And Wiggle Everything v1.1

created by KarenCH

Profile


Name
Cut And Wiggle Everything v1.1
ID
48874
Shared with
Public
Parent
None
Children
Created on
April 12, 2014 at 18:53 PM UTC
Updated on
April 12, 2014 at 18:53 PM UTC
Description

Places cuts every "stepsize" location, then performs fuse, deleting cuts in middle. Repeats for each initial offset of first cut from 1..stepsize. Repeats entire process until minimum gain threshold not met.

Best for


Code


------------------------------------------------------------------------------- -- Cut And Wiggle Everything -- -- Performs a fuse-wiggle with cuts inserted every "stepsize" spot -- Originally by Susume -- Gui added by KarenCH ------------------------------------------------------------------------------- stepsize=3 lowCI=0.3 highCI=1.0 shortwiggle = 2 longwiggle = 25 threshold = 1 --minimum point gain to do another iteration function DoWiggle( ) save.Quicksave(2) --starting position save.Quicksave(3) --high score segcount=structure.GetCount() highscore=current.GetEnergyScore() CI = behavior.SetClashImportance print("Original in slot 2, High score in slot 3") print("Starting score "..highscore) print("Cutting every "..stepsize.." segs, fusing, loop until less than "..threshold.." gain") repeat iter_start_score = current.GetEnergyScore() for startseg = 1, stepsize do print("Starting at seg "..startseg) for i = startseg, segcount-1, stepsize do structure.InsertCut(i) end CI(lowCI) structure.WiggleAll(shortwiggle) CI(highCI) structure.WiggleAll(longwiggle) for i = startseg, segcount-1, stepsize do structure.DeleteCut(i) end CI(lowCI) structure.WiggleAll(shortwiggle) recentbest.Save() CI(highCI) structure.WiggleAll(longwiggle) recentbest.Restore() newscore = current.GetEnergyScore() print("New score = "..newscore) if newscore > highscore then save.Quicksave(3) highscore = newscore end print("High score = "..highscore) save.Quickload(3) end until highscore - iter_start_score < threshold end function GetParams() dlg = dialog.CreateDialog("Cut And Wiggle") dlg.step = dialog.AddSlider( "Stepsize", 3, 1, 10, 0 ) dlg.lowCI = dialog.AddSlider( "LowCI", 0.3, 0, 1, 2 ) dlg.highCI = dialog.AddSlider( "HighCI", 1.0, 0, 1, 2 ) dlg.shortwiggle = dialog.AddSlider( "ShortWiggleIters", 2, 1, 10, 0 ) dlg.longwiggle = dialog.AddSlider( "LongWiggleIters", 25, 1, 50, 0 ) dlg.comment = dialog.AddLabel("Threshold Decimal Places for min gain: 1, 0.1,.. 0.0001") dlg.thresholdExp = dialog.AddSlider( "ThreshExp:1E-", 0, 0, 4, 0 ) dlg.ok = dialog.AddButton("OK", 1) dlg.cancel = dialog.AddButton("Cancel", 0) if dialog.Show(dlg) > 0 then stepsize = dlg.step.value lowCI = dlg.lowCI.value highCI = dlg.highCI.value shortwiggle = dlg.shortwiggle.value longwiggle = dlg.longwiggle.value if dlg.thresholdExp == 0 then threshold = 1 elseif dlg.thresholdExp == 1 then threshold = 0.1 elseif dlg.thresholdExp == 2 then threshold = 0.01 elseif dlg.thresholdExp == 3 then threshold = 0.001 elseif dlg.thresholdExp == 4 then threshold = 0.0001 end return true else print( "dialog cancelled" ) end return false end function cleanup() save.Quickload(3) end function main() if GetParams() then DoWiggle( ) end end xpcall(main,cleanup)

Comments