Icon representing a recipe

Recipe: Random Idealize 2.1.3

created by mirp

Profile


Name
Random Idealize 2.1.3
ID
100786
Shared with
Public
Parent
None
Children
Created on
July 14, 2018 at 09:48 AM UTC
Updated on
July 14, 2018 at 09:48 AM UTC
Description

random idealize with shake, wiggle, fuze and mutate

Best for


Code


recipe_name = "Random Idealize 2.1.3" -- random idealize with shake, wiggle, fuze and mutate --[[ Author: mirp Version 1.0 (12/11/2013): - First Release Version 1.1 (12/28/2013): - Idealize requires at least two adjacent segments - Handle locked or frozen segments - Wiggle all after each idealize added - Fuze added - Mutate added - Ask for keeping bands, freeze and ci - Note with the result added - Verbose mode added - No sign means no change - Elapsed time added - Clean break added - Best solution is stored in slot 3 Version 1.2 (01/17/2014): - Loop limit added - Simple walker added - Presets added - Fast: similar to version 1.0 - Slow: similar to version 1.1, but larger segments - Slower: larger segments than Slow and walker if small gain Version 2.0 (03/14/2015): - Changed min. Segments back to 1. Idealize doesn't require at least two adjacent segments anymore. - Toggle filters added - Wiggle local option added - Walker removed - Presets changed Version 2.1 (03/17/2015): - Shake local after idealize added - Minor bug fixes Version 2.1.1 (03/21/2015): - Filter detection fixed Version 2.1.2 (07/14/2018): - Min gain added Version 2.1.3 (07/14/2018): - Min gain range changed - Toggle filters option added, was automatic before. ]]-- -- ##### Functions ##### -- Preset functions function isFast() if loop_length == fast_loop_length and max_segments == fast_max_segments and flag_idealize_shake_selected == fast_flag_idealize_shake_selected and flag_idealize_wiggle_selected == fast_flag_idealize_wiggle_selected and flag_idealize_wiggle_all == fast_flag_idealize_wiggle_all and flag_loop_wiggle == fast_flag_loop_wiggle and flag_loop_fuze == fast_flag_loop_fuze and flag_idealize_mutate == fast_flag_idealize_mutate and flag_loop_mutate == fast_flag_loop_mutate then return true else return false end end -- function function isDefault() if loop_length == default_loop_length and max_segments == default_max_segments and flag_idealize_shake_selected == default_flag_idealize_shake_selected and flag_idealize_wiggle_selected == default_flag_idealize_wiggle_selected and flag_idealize_wiggle_all == default_flag_idealize_wiggle_all and flag_loop_wiggle == default_flag_loop_wiggle and flag_loop_fuze == default_flag_loop_fuze and flag_idealize_mutate == default_flag_idealize_mutate and flag_loop_mutate == default_flag_loop_mutate then return true else return false end end -- function function isSlow() if loop_length == slow_loop_length and max_segments == slow_max_segments and flag_idealize_shake_selected == slow_flag_idealize_shake_selected and flag_idealize_wiggle_selected == slow_flag_idealize_wiggle_selected and flag_idealize_wiggle_all == slow_flag_idealize_wiggle_all and flag_loop_wiggle == slow_flag_loop_wiggle and flag_loop_fuze == slow_flag_loop_fuze and flag_idealize_mutate == slow_flag_idealize_mutate and flag_loop_mutate == slow_flag_loop_mutate then return true else return false end end -- function function setFast() loop_length = fast_loop_length max_segments = fast_max_segments flag_idealize_shake_selected = fast_flag_idealize_shake_selected flag_idealize_wiggle_selected = fast_flag_idealize_wiggle_selected flag_idealize_wiggle_all = fast_flag_idealize_wiggle_all flag_loop_wiggle = fast_flag_loop_wiggle flag_loop_fuze = fast_flag_loop_fuze flag_idealize_mutate = fast_flag_idealize_mutate flag_loop_mutate = fast_flag_loop_mutate recipe_name_preset = recipe_name.." Fast" end -- function function setDefault() loop_length = default_loop_length max_segments = default_max_segments flag_idealize_shake_selected = default_flag_idealize_shake_selected flag_idealize_wiggle_selected = default_flag_idealize_wiggle_selected flag_idealize_wiggle_all = default_flag_idealize_wiggle_all flag_loop_wiggle = default_flag_loop_wiggle flag_loop_fuze = default_flag_loop_fuze flag_idealize_mutate = default_flag_idealize_mutate flag_loop_mutate = default_flag_loop_mutate recipe_name_preset = recipe_name end -- function function setSlow() loop_length = slow_loop_length max_segments = slow_max_segments flag_idealize_shake_selected = slow_flag_idealize_shake_selected flag_idealize_wiggle_selected = slow_flag_idealize_wiggle_selected flag_idealize_wiggle_all = slow_flag_idealize_wiggle_all flag_loop_wiggle = slow_flag_loop_wiggle flag_loop_fuze = slow_flag_loop_fuze flag_idealize_mutate = slow_flag_idealize_mutate flag_loop_mutate = slow_flag_loop_mutate recipe_name_preset = recipe_name.." Slow" end -- function -- Filter functions function checkFilters() save.Quicksave(temp_slot) behavior.SetFiltersDisabled(true) dis_filter_score = current.GetScore() behavior.SetFiltersDisabled(false) initial_score = current.GetScore() save.Quickload(temp_slot) return (dis_filter_score ~= initial_score) end function GetFilterScore() -- replaces current.GetScore() if flag_filters then save.Quicksave(temp_slot) behavior.SetFiltersDisabled(false) filter_score = current.GetScore() behavior.SetFiltersDisabled(true) save.Quickload(temp_slot) else filter_score = current.GetScore() end -- if return (filter_score) end function SetRecentBest() -- replaces recentbest.Save() recent_best = current_score save.Quicksave(recent_best_slot) SaveBest() end function RefreshRecentBest() -- updates recent_best if current_score > (recent_best + mingain_score) then SetRecentBest() end SaveBest() end function LoadRecentBest() -- replaces recentbest.Restore() save.Quickload(recent_best_slot) end function SaveBest() -- replaces saveSlot3 if current_score > (best_score + mingain_score) then saveSlot3() best_score = current_score end end function LoadBest() -- replaces save.Quickload(3) save.Quickload(3) end -- Puzzle functions function puzzleHasMutable() for i = 1,n do if structure.IsMutable(i) then return true end -- if end -- for return false end -- function function puzzleHasLocked() for i = 1,n do if structure.IsLocked(i) then return true end -- if end -- for return false end -- function function noteSegment() for i=n,1,-1 do if structure.GetNote(i) ~= "" then if i == n then return(-1) else return(i+1) end end -- if end -- for return(1) end -- function function saveSlot3() if flag_note and loop_n > 0 then structure.SetNote(note_segment,string.format("(%s) %.3f + %s (%i)[%i] %.3f", user.GetPlayerName(),roundScore(initial_score),recipe_name_preset,loop_n,idealize_n,roundScore(current_score))) end -- if save.Quicksave(3) end -- function function roundScore(score) return score - score % 0.001 end -- function function notLockedSegments() if n < 1 then return {} end -- not locked list not_locked_list = {} if flag_locked_puzzle or flag_freeze_puzzle then last_segment = false -- segment i for i = 1,n do if not freeze.IsFrozen(i) and not structure.IsLocked(i) then not_locked_list[#not_locked_list+1] = i end -- if end -- for else for i = 1,n do not_locked_list[#not_locked_list+1] = i end -- for end -- if/else if #not_locked_list == 0 then return {} end return not_locked_list end -- function -- Select segments function randomSegments() if flag_locked_puzzle or flag_freeze then -- select random start segments start_index = math.random(#not_locked_list) -- random range segments = math.random(max_segments) if segments == 1 then segment_range = {start_index,start_index} return segment_range else segments = segments - 1 end -- if/else for i = 1,segments do if start_index + i > #not_locked_list then end_index = #not_locked_list else if not_locked_list[start_index] + i == not_locked_list[start_index+i] then end_index = start_index + i else return {not_locked_list[start_index],not_locked_list[end_index]} end -- if/else end -- if/else end -- for segment_range = {not_locked_list[start_index],not_locked_list[end_index]} else -- select random segments start_seg = math.random(n) segments = math.random(max_segments) if start_seg + segments > n then end_seg = n else end_seg = start_seg + segments - 1 end -- if/else segment_range = {start_seg,end_seg} end -- if/else return segment_range end -- function -- Print function printScore(score_label,initial_score,pre_score,post_score,flag_total,flag_iterations) if flag_total then if post_score - initial_score > 0 then gain_sign = "+" else gain_sign = "" end total_string = ", "..gain_sign..string.format("%.3f", post_score - initial_score) else total_string = "" end -- if/else if flag_iterations then iterations_string = ") ["..idealize_n.."]" else iterations_string = ")" end -- if/else if post_score - pre_score > 0 then gain_sign = "+" else gain_sign = "" end print(score_label..": ",roundScore(post_score), "("..gain_sign..string.format("%.3f", post_score - pre_score) ..total_string..iterations_string) end -- function function printTime() elapsed_time = os.time() - start_time seconds = elapsed_time % 60 minutes = ((elapsed_time - seconds) % (60 * 60)) / 60 hours = (elapsed_time - minutes * 60 - seconds) / 3600 print(string.format("Elapsed time: %ih %02im %02is",hours,minutes,seconds)) end -- function -- Random Idealize function loopMutate() current_score = GetFilterScore() SetRecentBest() pre_score = current_score selection.SelectAll() structure.MutateSidechainsSelected(loop_mutate_iterations) current_score = GetFilterScore() RefreshRecentBest() LoadRecentBest() current_score = GetFilterScore() post_score = current_score if post_score > pre_score then SaveBest() printScore("Loop mutate all",initial_score,pre_score,post_score,true,false) else if ((flag_verbose == 2) or (flag_verbose == 1 and post_score > pre_score)) then printScore("Loop mutate all",initial_score,pre_score,post_score,true,false) end -- if end -- if/else LoadBest() end -- function function loopWiggle() current_score = GetFilterScore() SetRecentBest() pre_score = current_score selection.SelectAll() structure.WiggleSelected(loop_wiggle) current_score = GetFilterScore() RefreshRecentBest() LoadRecentBest() current_score = GetFilterScore() post_score = current_score if post_score > pre_score then SaveBest() printScore("Loop wiggle all",initial_score,pre_score,post_score,true,false) else if ((flag_verbose == 2) or (flag_verbose == 1 and post_score > pre_score)) then printScore("Loop wiggle all",initial_score,pre_score,post_score,true,false) end -- if end -- if/else LoadBest() end -- function function fuze() current_score = GetFilterScore() SetRecentBest() pre_score = current_score selection.SelectAll() behavior.SetClashImportance(0.1*pre_ci) structure.ShakeSidechainsSelected(fuze_shake_iterations) current_score = GetFilterScore() RefreshRecentBest() behavior.SetClashImportance(0.6*pre_ci) structure.WiggleSelected(fuze_wiggle_iterations) current_score = GetFilterScore() RefreshRecentBest() behavior.SetClashImportance(1*pre_ci) structure.WiggleSelected(fuze_wiggle_iterations) current_score = GetFilterScore() RefreshRecentBest() fuze1_score = current_score LoadRecentBest() current_score = GetFilterScore() post_score = current_score if post_score > pre_score then SaveBest() if post_score > fuze1_score then fuze1_score = post_score end -- if end -- if behavior.SetClashImportance(0.6*pre_ci) structure.WiggleSelected(fuze_wiggle_iterations) current_score = GetFilterScore() RefreshRecentBest() behavior.SetClashImportance(1*pre_ci) structure.ShakeSidechainsSelected(fuze_shake_iterations) current_score = GetFilterScore() RefreshRecentBest() structure.WiggleSelected(fuze_wiggle_iterations) current_score = GetFilterScore() RefreshRecentBest() selection.DeselectAll() behavior.SetClashImportance(1*pre_ci) current_score = GetFilterScore() RefreshRecentBest() fuze2_score = current_score LoadRecentBest() current_score = GetFilterScore() post_score = current_score if post_score > pre_score then if post_score > fuze2_score then fuze2_score = post_score end -- if end -- if if post_score > pre_score then SaveBest() printScore("Fuze",initial_score,pre_score,post_score,true,false) else if flag_verbose == 2 then printScore("Fuze",initial_score,pre_score,post_score,true,false) end -- if end -- if/else if ((flag_verbose == 2) or (flag_verbose == 1 and post_score > pre_score)) then printScore(" Step 1",initial_score,pre_score,fuze1_score,false,false) if fuze1_score > pre_score then pre_score = fuze1_score end printScore(" Step 2",initial_score,pre_score,fuze2_score,false,false) end -- if LoadBest() end -- function function askDialog() local ask = dialog.CreateDialog(recipe_name_preset) ask.loopLimit = dialog.AddSlider("Loop limit", loop_limit, 0, 50, 0) ask.loopLength = dialog.AddSlider("Loop length", loop_length, 25, 125, 0) -- Idealize ask.segmentsLabel = dialog.AddLabel("Maximum selected segments for idealize") ask.maxSegments = dialog.AddSlider("Segments", max_segments, 1, 30, 0) ask.mingainScore = dialog.AddSlider("Min gain", mingain_score, 0, 100, 1) -- Mutate after idealize if flag_mutable_puzzle then ask.flagIdealizeMutate = dialog.AddCheckbox("Mutate local after each idealize",flag_idealize_mutate) end -- if -- Shake local after idealize ask.flagIdealizeShakeSelected = dialog.AddCheckbox("Shake local after each idealize",flag_idealize_shake_selected) -- Wiggle local after idealize ask.flagIdealizeWiggleSelected = dialog.AddCheckbox("Wiggle local after each idealize",flag_idealize_wiggle_selected) -- Wiggle all after idealize ask.flagIdealizeWiggleAll = dialog.AddCheckbox("Wiggle all after each idealize",flag_idealize_wiggle_all) -- Mutate after loop if flag_mutable_puzzle then ask.flagLoopMutate = dialog.AddCheckbox("Mutate all after each loop",flag_loop_mutate) end -- if -- Wiggle all after each loop ask.flagLoopWiggle = dialog.AddCheckbox("Wiggle all after each loop",flag_loop_wiggle) -- Fuze ask.flagLoopFuze = dialog.AddCheckbox("Fuze after loop",flag_loop_fuze) -- Filter ask.toggleFilters = dialog.AddCheckbox("Toggle filters",flag_filters) -- Verbose ask.verboseLabel = dialog.AddLabel("Verbose mode (0 = off, 1 = when gained, 2 = always)") ask.flagVerbose = dialog.AddSlider("Verbose mode", flag_verbose, 0, 2, 0) if note_segment > 0 then ask.flagNote = dialog.AddCheckbox("Save result as note in segment "..note_segment,flag_note) else flag_note = false end -- if/else -- Keep Bands/Freeze/CI if flag_bands then ask.flagBands = dialog.AddCheckbox("Keep bands",keep_bands) end if flag_freeze then ask.flagFreeze = dialog.AddCheckbox("Keep frozen",keep_frozen) end if flag_ci then ask.flagCI = dialog.AddCheckbox("Keep clash importance",keep_ci) end -- Buttons ask.Fast = dialog.AddButton("Fast", 2) ask.Normal = dialog.AddButton("Default", 3) ask.Slow = dialog.AddButton("Slow", 4) ask.OK = dialog.AddButton("OK", 1) ask.Cancel = dialog.AddButton("Cancel", 0) dialog_show_ask = dialog.Show(ask) max_segments = ask.maxSegments.value mingain_score = ask.mingainScore.value loop_limit = ask.loopLimit.value loop_length = ask.loopLength.value flag_idealize_wiggle_selected = ask.flagIdealizeWiggleSelected.value flag_idealize_shake_selected = ask.flagIdealizeShakeSelected.value flag_idealize_wiggle_all = ask.flagIdealizeWiggleAll.value flag_loop_wiggle = ask.flagLoopWiggle.value flag_loop_fuze = ask.flagLoopFuze.value flag_filters = ask.toggleFilters.value if flag_mutable_puzzle then flag_idealize_mutate = ask.flagIdealizeMutate.value flag_loop_mutate = ask.flagLoopMutate.value end -- if flag_verbose = ask.flagVerbose.value if note_segment > 0 then flag_note = ask.flagNote.value end -- if if flag_bands then keep_bands = ask.flagBands.value end if flag_freeze then keep_frozen = ask.flagFreeze.value end if flag_ci then keep_ci = ask.flagCI.value end return dialog_show_ask end -- function function randomIdealize() show_dialog = default_preset repeat if show_dialog == 2 then setFast() elseif show_dialog == 3 then setDefault() elseif show_dialog == 4 then setSlow() end show_dialog = askDialog() until show_dialog < 2 -- repeat if show_dialog > 0 then if isFast() then recipe_name_preset = recipe_name.." Fast" elseif isDefault() then recipe_name_preset = recipe_name elseif isSlow() then recipe_name_preset = recipe_name.." Slow" else recipe_name_preset = recipe_name.." Custom" end selection.DeselectAll() if (flag_bands and not keep_bands) then band.DeleteAll() end if (flag_freeze and not keep_frozen) then freeze.UnfreezeAll() end if (flag_ci and not keep_ci) then pre_ci = 1 behavior.SetClashImportance(1) end -- if if not flag_mutable_puzzle then flag_idealize_mutate = false flag_loop_mutate = false end -- if print(recipe_name_preset) print("") print("Best solution is stored in slot 3") if flag_note then print("Save result as note in segment "..note_segment) end SaveBest() if loop_limit > 1 then print(loop_limit.." Loops with "..loop_length.." idealizes each") elseif loop_limit == 1 then print("1 Loop with "..loop_length.." idealizes") else print("No loop limit, "..loop_length.." idealizes each loop") end print("Maximum selected segments: "..max_segments) if mingain_score > 0 then print("Min gain: "..mingain_score) end if flag_idealize_mutate then print("Mutate local after each idealize") end if flag_idealize_shake_selected then print("Shake local after each idealize") end if flag_idealize_wiggle_selected then print("Wiggle local after each idealize") end if flag_idealize_wiggle_all then print("Wiggle all after each idealize") end if flag_loop_mutate then print("Mutate all after each loop") end if flag_loop_wiggle then print("Wiggle all after each loop") end if flag_loop_fuze then print("Fuze after loop") end if flag_filters then print("Toggle filters") end if flag_verbose == 1 then print("Verbose mode: when gained") end if flag_verbose == 2 then print("Verbose mode: always") end print("") print("Loop 1 initial score: ",roundScore(initial_score), "(gain, total) [#idealize]") if flag_filters and not behavior.GetFiltersDisabled() then behavior.SetFiltersDisabled(true) end start_time = os.time() repeat loop_n = loop_n + 1 loop_score = current_score for i = 1,loop_length do idealize_n = idealize_n + 1 -- Save current_score = best_score SetRecentBest() pre_score = current_score -- Select random_segments = randomSegments() start_seg = random_segments[1] end_seg = random_segments[2] selection.DeselectAll() selection.SelectRange(start_seg,end_seg) -- Idealize structure.IdealizeSelected() current_score = GetFilterScore() RefreshRecentBest() if flag_verbose > 0 then idealize_score = current_score end -- Mutate if flag_idealize_mutate then selection.DeselectAll() for i = start_seg,end_seg do if structure.IsMutable(i) then selection.Select(i) end end -- for structure.MutateSidechainsSelected(idealize_mutate_iterations) current_score = GetFilterScore() RefreshRecentBest() selection.SelectRange(start_seg, end_seg) if flag_verbose > 0 then mutate_score = current_score end end -- if -- Shake if flag_idealize_shake_selected then structure.ShakeSidechainsSelected(idealize_shake_iterations) current_score = GetFilterScore() RefreshRecentBest() if flag_verbose > 0 then shake_score = current_score end end -- if -- Wiggle if flag_idealize_wiggle_selected then structure.WiggleSelected(idealize_wiggle_selected) current_score = GetFilterScore() RefreshRecentBest() if flag_verbose > 0 then wiggle_selected_score = current_score end end -- if if flag_idealize_wiggle_all then selection.SelectAll() structure.WiggleSelected(idealize_wiggle_all) current_score = GetFilterScore() RefreshRecentBest() if flag_verbose > 0 then wiggle_all_score = current_score end end -- if segment_score = current_score LoadRecentBest() current_score = GetFilterScore() post_score = current_score if start_seg == end_seg then range = "Segment "..start_seg else range = "Segments "..start_seg.."-"..end_seg end if post_score > pre_score then SaveBest() printScore(range,initial_score,pre_score,post_score,true,true) else LoadBest() if flag_verbose == 2 then printScore(range,initial_score,pre_score,segment_score,false,true) end end -- if/else if ((flag_verbose == 2) or (flag_verbose == 1 and post_score > pre_score)) then printScore(" Idealize local",initial_score,pre_score,idealize_score,false,false) pre_score = idealize_score if flag_idealize_mutate then printScore(" Mutate local",initial_score,pre_score,mutate_score,false,false) pre_score = mutate_score end -- if if flag_idealize_shake_selected then printScore(" Shake local",initial_score,pre_score,shake_score,false,false) pre_score = shake_score end -- if if flag_idealize_wiggle_selected then printScore(" Wiggle local",initial_score,pre_score,wiggle_selected_score,false,false) pre_score = wiggle_selected_score end -- if if flag_idealize_wiggle_all then printScore(" Wiggle all",initial_score,pre_score,wiggle_all_score,false,false) end end -- if end -- for -- Loop mutate all if flag_loop_mutate then loopMutate() end -- Loop wiggle all if flag_loop_wiggle then loopWiggle() end -- Loop fuze if (flag_loop_fuze and post_score - fuze_score > trigger_fuze) then fuze() fuze_score = current_score -- reset cumulative gain end -- if printScore("Loop "..loop_n,initial_score,loop_score,best_score,true,true) printTime() until loop_n == loop_limit -- repeat -- save with filter enable if flag_filters and behavior.GetFiltersDisabled() then behavior.SetFiltersDisabled(false) end saveSlot3() end -- if (no dialog cancel) end -- main function cleanbreak() LoadRecentBest() current_score = GetFilterScore() SaveBest() LoadBest() if flag_filters and behavior.GetFiltersDisabled() then behavior.SetFiltersDisabled(false) end saveSlot3() selection.DeselectAll() behavior.SetClashImportance(pre_ci) printScore("Loop "..loop_n,initial_score,loop_score,best_score,true,true) printTime() end -- function -- ##### Variables ##### -- Protein n = structure.GetCount() -- length of the protein flag_mutable_puzzle = puzzleHasMutable() flag_locked_puzzle = puzzleHasLocked() not_locked_segments = notLockedSegments() -- Preset Fast fast_loop_length = 100 -- length of a loop fast_max_segments = 8 -- max. number of segments selected for idealize fast_flag_idealize_shake_selected = true -- local wiggle all after each idealize fast_flag_idealize_wiggle_selected = false -- local wiggle all after each idealize fast_flag_idealize_wiggle_all = false -- wiggle all after each idealize fast_flag_loop_wiggle = true -- wiggle all after each loop fast_flag_loop_fuze = false -- fuze after loop fast_flag_idealize_mutate = false -- mutate selected after each idealize fast_flag_loop_mutate = false -- mutate all after each loop -- Preset Default default_loop_length = 75 default_max_segments = 10 if flag_mutable_puzzle then default_flag_idealize_shake_selected = false else default_flag_idealize_shake_selected = true end default_flag_idealize_wiggle_selected = true default_flag_idealize_wiggle_all = false default_flag_loop_wiggle = true default_flag_loop_fuze = false default_flag_idealize_mutate = true default_flag_loop_mutate = false -- Preset Slow slow_loop_length = 50 slow_max_segments = 12 slow_flag_idealize_shake_selected = true slow_flag_idealize_wiggle_selected = true slow_flag_idealize_wiggle_all = true slow_flag_loop_wiggle = true slow_flag_loop_fuze = true slow_flag_idealize_mutate = true slow_flag_loop_mutate = true -- Preset init loop_length = 0 max_segments = 0 flag_idealize_wiggle_selected = false flag_idealize_shake_selected = false flag_idealize_wiggle_all = false flag_loop_wiggle = false flag_loop_fuze = false flag_idealize_mutate = false flag_loop_mutate = false recipe_name_preset = recipe_name setDefault() default_preset = 3 -- default preset: 2 = fast, 3 = default, 4 = slow loop_limit = 0 -- ends after loop_limit (0 = no limit) -- Iterations idealize_mutate_iterations = 1 -- mutate selected iterations after each idealize idealize_shake_iterations = 1 -- shake selected iterations after each idealize idealize_wiggle_selected = 5 -- wiggle selected iterations after idealize idealize_wiggle_all = 1 -- wiggle all iterations after each idealize loop_wiggle = 10 -- loop wiggle iterations after each loop fuze_wiggle_iterations = 10 -- wiggle iterations while fuzing fuze_shake_iterations = 5 -- shake iterations while fuzing loop_mutate_iterations = 1 -- mutate all iterations after each loop -- Fuze trigger_fuze = 1 -- fuze if cumulative gain is greater than trigger_fuze -- Verbose flag_verbose = 0 -- more information (0 = off, 1 = when gained, 2 = always) -- Note flag_note = true -- save result as note in segment note_segment note_segment = noteSegment() -- Log start_time = 0 loop_n = 0 idealize_n = 0 -- Random math.randomseed(os.time()) -- Scores initial_score = 0 mingain_score = 0 -- Recent Best Slot recent_best_slot = 73 temp_slot = 1 flag_filters = checkFilters() current_score = initial_score idealize_score = initial_score shake_score = initial_score mutate_score = initial_score wiggle_score = initial_score wiggle_all_score = initial_score fuze_score = initial_score -- last fuze score loop_score = initial_score pre_score = initial_score post_score = initial_score recent_best = initial_score - 1000 best_score = initial_score - 1000 -- Keep keep_bands = true -- keep bands keep_frozen = true -- keep frozen keep_ci = false -- don't keep ci pre_ci = behavior.GetClashImportance() -- Flags flag_bands = band.GetCount() > 0 flag_freeze = math.max(freeze.GetCount()) > 0 flag_freeze_puzzle = flag_freeze flag_ci = behavior.GetClashImportance() ~= 1 -- ##### Start ##### -- quit when not enough segments if freeze.GetCount() == n then print("Puzzle is frozen.") return end -- if if #not_locked_segments == 0 then print("There are not enough segments.") return end -- if -- randomIdealize() -- for debugging xpcall(randomIdealize,cleanbreak) -- no error messages

Comments


mirp Lv 1

  • Min gain range changed
  • Toggle filters option added, was automatic before.