Icon representing a recipe

Recipe: Try All Remix 1.0

created by marsfan

Profile


Name
Try All Remix 1.0
ID
103640
Shared with
Public
Parent
None
Children
None
Created on
June 26, 2020 at 23:03 PM UTC
Updated on
June 26, 2020 at 23:03 PM UTC
Description

Finds all remixes for selection, then wiggle-shakes them to improve score. Saves the best output.

Settings:


Wiggle Sidechains first: Does a quick wiggle of just the sidechains that were selected to clear clashes.


High Power Segment Wiggle: After initial wiggle, does 3 iterations at highest wiggle power possible to try to idealize the backbone.


Shake out after first wiggle: Shakes all sidechains for 2 iterations, the re-does wiggle. Helps gain a lot of points.


Disable Filters: Disable filters when wiggling, shaking, and remixing to improve perforamance.


Compress Undo: Each remix trial will only take up one point on the undo graph.

Best for


Code


startScore = 0 -- The initial score sideWiggle = false hpWiggle = false doShake = true disableFilters = true compressUndo = true function getScore() -- Calculate the score, enable/disable filters if asked to local score = 0 setFiltersDisabled(false) score = current.GetEnergyScore() setFiltersDisabled(true) return score end function setFiltersDisabled(state) if disableFilters then behavior.SetFiltersDisabled(state) end end function pass() -- A do nothing function used to indcate that nothing needs to happen return end function shakeWiggle() -- Shake and Wiggle -- Wiggle Sidechains that were remixed to clear clashes -- TODO: Have it select nearby as well to wiggle if sideWiggle then structure.WiggleSelected(25, false, true) end -- Primary Wiggle structure.WiggleAll(25) -- Do a high power wiggle to idealize the segments if hpWiggle then local wp = behavior.GetWigglePower() if behavior.HighPowerAllowed() then behavior.SetWigglePower("h") else behavior.SetWigglePower("m") end structure.WiggleSelected(3) -- Try wiggling out any ideality issues behavior.SetWigglePower(wp) end -- Shake it out and wiggle one more time if doShake then structure.ShakeSidechainsAll(2) structure.WiggleAll(25) end end function setUndo(state) -- Set undo state, but only if user wants to compress undo if compressUndo then undo.SetUndo(state) -- Wiggle once to force a push to call stack structure.WiggleAll(1) end end function settingsMenu() -- Show settings local settings = dialog.CreateDialog("Settings") local userChoice = 0 settings.sideWiggle = dialog.AddCheckbox("Wiggle Sidechains first?", sideWiggle) settings.idealize = dialog.AddCheckbox("High Power Segment Wiggle?", hpWiggle) settings.shake = dialog.AddCheckbox("Shake out after First Wiggle?", doShake) settings.filters = dialog.AddCheckbox("Disable Filters?", disableFilters) settings.undo = dialog.AddCheckbox("Compress Undo?", compressUndo) settings.ok = dialog.AddButton("OK", 1) settings.cancel = dialog.AddButton("Cancel", 0) userChoice = dialog.Show(settings) -- Update settings from dialog sideWiggle = settings.sideWiggle.value hpWiggle = settings.idealize.value doShake = settings.shake.value disableFilters = settings.filters.value compressUndo = settings.undo.value return userChoice end function getScore(disableFilters) -- Calculate the score. local score = 0 setFiltersDisabled(false) score = current.GetEnergyScore() setFiltersDisabled(true) return score end function setFiltersDisabled(state) if disableFilters then behavior.SetFiltersDisabled(state) end end function reportRemix(remixNum) -- Report the remix results to the user curScore = getScore() if (curScore > startScore) then print("Remix", remixNum, ":", curScore, "Improvement by", curScore - startScore, "points") else print("Remix", remixNum, ":", curScore) end end function main() -- Main function -- Reset recentbest to score at recipe start recentbest.Save() menuChoice = settingsMenu() if (menuChoice == 0 ) then print("User Cancelled") cleanup() return else startScore = getScore() setFiltersDisabled(true) print("Starting Score is", startScore, "Points") print("Finding Remixes...") -- Remix the selection, return number of remixes found setUndo(false) numRemixes = structure.RemixSelected(1, 99) --Try all remixes with a wigle and shake routine print(numRemixes, "Remixes found") for i = 1, numRemixes do setUndo(false) save.Quickload(i) shakeWiggle() reportRemix(i) setUndo(true) end cleanup() end end -- Clean everything up, reverting to recent best and re-enabling undo function cleanup(errorMSG) if errorMSG == nil then pass() elseif string.find(errorMSG, "Cancelled") then print("User Cancelled") else print(errorMSG) end recentbest.Restore() setFiltersDisabled(false) setUndo(true) return errorMSG end -- Call the main function xpcall(main, cleanup)

Comments