Icon representing a recipe

Recipe: Cut And Wiggle Everything v1.2

created by KarenCH

Profile


Name
Cut And Wiggle Everything v1.2
ID
48876
Shared with
Public
Parent
None
Children
Created on
April 12, 2014 at 22:11 PM UTC
Updated on
April 12, 2014 at 22:11 PM UTC
Description

Places cuts every "stepsize", fuses, removes cuts, and fuses again. Repeats for every 1st cut at 1.."stepsize". Keeps going until threshold for change is not met.

Best for


Code


------------------------------------------------------------------------------- -- Cut And Wiggle Everything -- -- Performs a fuse-wiggle with cuts inserted every "stepsize" spot -- -- Change: v1.2, fixed error with reading threshold from dialog box -- 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.value == 0 then threshold = 1 elseif dlg.thresholdExp.value == 1 then threshold = 0.1 elseif dlg.thresholdExp.value == 2 then threshold = 0.01 elseif dlg.thresholdExp.value == 3 then threshold = 0.001 elseif dlg.thresholdExp.value == 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