Icon representing a recipe

Recipe: Behaviour wiggle fuze v6

created by Bruno Kestemont

Profile


Name
Behaviour wiggle fuze v6
ID
109193
Shared with
Public
Parent
Servca Rebuild copy
Children
None
Created on
September 25, 2025 at 14:49 PM UTC
Updated on
September 25, 2025 at 18:02 PM UTC
Description

Wiggle all with high importance for several options importances like hiding, clashing, bonding etc. Code revised by AI, added random order and a second loop if gains

Best for


Code


--by Bruno Kestemont in collaboration with AI (Copilot) --Wiggle all with high importance for several options importances like hiding, clashing, bonding etc. --Parent: Behaviour wiggle fuze --v6 (25/09/2025) -- Parameters local importanceMin = 0.5 local importanceMax = 3.0 local importanceStep = 0.5 local wiggleCount = 25 local maxNoGainCycles = 12 -- Initialisation BestScore = current.GetScore() BestBonus = filter.GetBonusTotal() save.Quicksave(3) local noGainCounter = 0 function SaveBest() local score = current.GetScore() local bonus = filter.GetBonusTotal() if score > BestScore and bonus >= BestBonus then print("Improved: Score " .. score .. " | Bonus: " .. bonus) BestScore = score BestBonus = bonus save.Quicksave(3) noGainCounter = 0 else print("No gain") noGainCounter = noGainCounter + 1 end end function RunFuze(name, setFunc, resetFunc, importance) print(name .. " | Importance: " .. importance) save.Quickload(3) recentbest.Save() setFunc(importance) structure.WiggleAll(wiggleCount, true, true) recentbest.Restore() SaveBest() resetFunc() end -- List of behaviours local behaviors = { {name = "SidechainHBond", set = behavior.SetSidechainHBondImportance, reset = function() behavior.SetSidechainHBondImportance(1) end}, {name = "BackboneHBond", set = behavior.SetBackboneHBondImportance, reset = function() behavior.SetBackboneHBondImportance(1) end}, {name = "Pairwise", set = behavior.SetPairwiseImportance, reset = function() behavior.SetPairwiseImportance(1) end}, {name = "Packing", set = behavior.SetPackingImportance, reset = function() behavior.SetPackingImportance(1) end}, {name = "Hiding", set = behavior.SetHidingImportance, reset = function() behavior.SetHidingImportance(1) end}, {name = "Clashing", set = function(i) behavior.SetClashImportance(0.9) end, reset = function() behavior.SetClashImportance(1) end} } -- Randomisation function shuffle(tbl) for i = #tbl, 2, -1 do local j = math.random(i) tbl[i], tbl[j] = tbl[j], tbl[i] end end -- Main for i=1, 2 do print("Main loop "..i.. "/ max 2 if gain") for importance = importanceMax, importanceMin, -importanceStep do if noGainCounter >= maxNoGainCycles then print("Stop after " .. maxNoGainCycles .. "no gaining cycles.") break end print("Testing Importance = " .. importance) shuffle(behaviors) for _, b in ipairs(behaviors) do RunFuze(b.name, b.set, b.reset, importance) if noGainCounter >= maxNoGainCycles then print("No gain, automatic stop") break end end save.Quickload(3) end end

Comments