Icon representing a recipe

Recipe: BandFuze with Filter

created by Xartos

Profile


Name
BandFuze with Filter
ID
103570
Shared with
Public
Parent
BandFuze.
Children
None
Created on
June 12, 2020 at 09:58 AM UTC
Updated on
June 12, 2020 at 09:58 AM UTC
Description

Script is still the awesome one from murlow, just fixed the filter mechanism.

Best for


Code


-- Banding Fuzes. -- MurloW IterationMultiplier = 1.2 -- 2.4 ItMu = IterationMultiplier if ItMu<=0 then ItMu=1 end nSegs=structure.GetCount() p=print p("") behavior.SetSlowFiltersDisabled(false) function Seed() -- Rav3n_pl seed=os.time()/math.abs(current.GetEnergyScore()) seed=seed%0.001 seed=1/seed while seed<10000000 do seed=seed*10 end seed=seed-seed%1 --p("Seed is: "..seed) math.randomseed(seed) end Seed() function score() return current.GetScore() end function cut(x) return x-x%0.000000001 end function setCI(ci) return behavior.SetClashImportance(ci) end function wig(how, it, iters, minppi) behavior.SetSlowFiltersDisabled(true) if how==nil then how="wa" end if minppi==nil then minppi=2 end if iters==nil then iters=2 end if it==nil then it=10*ItMu end it=math.ceil(it) if iters>0 then iters=iters-1 local sp=score() if how == "s" then if AllAla==false then structure.ShakeSidechainsAll(1) end elseif how == "wb" then structure.WiggleAll(it,true,false) elseif how == "ws" then structure.WiggleAll(it,false,true) elseif how == "wa" then structure.WiggleAll(it) end if score()-sp > minppi and how ~= "s" then return wig(how, it, iters, minppi) end end behavior.SetSlowFiltersDisabled(false) end function Test() save.Quicksave(93) recentbest.Save() sci=(math.random(cival*100)/100) setCI(sci) if (mut or muta)==true then p(" Mutate CI:", sci) selectMutas() structure.MutateSidechainsSelected(1) Check() selection.DeselectAll() else p(" Shake CI:", sci) wig('s') Check() end setCI(cival) wig() Check() setCI(cival/2) wig("wa",5) Check() setCI(cival) wig() Check() qStab() save.Quickload(93) setCI(cival) wig() Check() setCI(cival/2) wig("wa",5) Check() setCI(cival) wig() Check() recentbest.Restore() Check() CheckAla() if fuzt>=0 then if score()>(bestscore-fuzt) then Fuzit() end else if score()>=(bestscore+FF) then Fuzit() end end end function qStab() CheckAla() setCI(cival/2) wig("wa",5) Check() setCI(cival) wig("s") Check() wig() Check() setCI(cival/2) wig("wa",5) Check() setCI(cival) wig() Check() wig('s') Check() wig() Check() end function Fuze() Check() setCI(.05) wig("s") Check() setCI(cival) wig() Check() setCI(cival/3) wig("wa",5) Check() if Sf == false then setCI(.07) wig("s") Check() setCI(cival) wig() Check() setCI(cival/3) wig("wa",5) Check() end setCI(cival) wig("s") Check() wig() Check() end function mutaFuze() CheckAla() setCI(0.15) selectMutas() structure.MutateSidechainsSelected(1) Check() selection.DeselectAll() setCI(cival) wig() Check() setCI(cival/3) wig("wa",4) Check() setCI(cival) wig() Check() if Sf==false then CheckAla() setCI(0.2) wig("s") Check() setCI(cival) wig() Check() setCI(cival/2) wig() Check() setCI(0.87*cival) selectMutas() structure.MutateSidechainsSelected(1) Check() selection.DeselectAll() end wig("wa",9) Check() CheckAla() end function Fuzit() Sf1=math.random(-100,100) if Sf1>=0 then Sf=false else Sf=true end if muta == true then mutaFuze() else Fuze() end end function Check() if (bestscore < score()) then gain = score() - bestscore bestscore = score() save.Quicksave(1) p(" ",cut(gain),"pts.") else gain = 0 end end function CheckAla() AllAla=false local ala=0 for i=1, structure.GetCount() do local Taa=structure.GetAminoAcid(i) if (Taa=='a') or (Taa=='g') then ala=ala+1 else AllAla=false break end end if ala>=structure.GetCount() then AllAla=true end return AllAla end function selectMutas() for i=1,nSegs do if structure.IsMutable(i) == true then selection.Select(i) end end end function End(errmsg) if done then return end done=true if string.find(errmsg,"Cancelled") then p("") p(" User cancel.") Result() p("") else Result() p("") p(errmsg) end return errmsg end function Result() behavior.SetSlowFiltersDisabled(false) recentbest.Restore() Check() save.Quickload(1) Delbands() Tgain = (bestscore-startscore) if Tgain<0.008 then p(" No change.. :/ ") else p(" Startscore: "..cut(startscore)) p(" Score: "..cut(score())) p(" Total gain: "..cut(Tgain).." pts.") end setCI(cival) end function bandpull(minBS,maxBS) if KB then band.EnableAll() end local ss=score() local perc=math.random(80,200)/100 local loss=((perc*ss)/100) --p(" Min. loss: "..perc.."%, "..cut(loss),"points.") local lastBS=minBS for str=lastBS,maxBS, 0.1 do if KBSTR then local NNbands = band.GetCount() for i=oldbands+1, NNbands do band.SetStrength(i, str) end else for i=1, band.GetCount() do band.SetStrength(i, str) end end wig('wb',5,1,500) if (ss-score()>=loss) or (score()>bestscore+1) then if band.GetCount()>(nSegs/10)*2 then lastBS=str-0.1 if lastBS<minBS then lastBS=minBS end else lastBS=minBS end break end end end function bandage() if bloat==true then if KBSTR then local NNbands = band.GetCount() for i=oldbands+1, NNbands do band.SetGoalLength(i,band.GetLength(i)+4) end else for i=1, band.GetCount() do band.SetGoalLength(i,band.GetLength(i)+4) end end else if KBSTR then local NNbands = band.GetCount() for i=oldbands+1, NNbands do local leng=band.GetLength(i) local perc=math.random(20,50) local loss=((perc*leng)/100) band.SetGoalLength(i,band.GetLength(i)-loss) end else for i=1, band.GetCount() do local leng=band.GetLength(i) local perc=math.random(20,50) local loss=((perc*leng)/100) band.SetGoalLength(i,band.GetLength(i)-loss) end end end end function spacebands(amnt) local zeBands=math.random(amnt)+Qbands if zeBands<1 then zeBands = 1 end while band.GetCount()<zeBands do segO = math.random(nSegs) OsegC=1 while structure.IsLocked(segO)==true do segO=math.random(nSegs) OsegC=OsegC+1 if OsegC>25 then break end end if ZL==true then rho=0.2 else rho=math.random(10) end theta = math.random(100,314.159)/100 phi = math.random(100,314.159)/100 if phi<1 then phi=phi+1 end if theta<1 then theta=theta+1 end if segO<=nSegs and segO>=1 then if segO==nSegs then segX = segO-1 segY = segO-2 elseif segO==1 then segX = segO+1 segY = segO+2 else segX = segO-1 segY = segO+1 end if segX>nSegs then segX=nSegs-1 end if segY>nSegs then segY=nSegs-1 end if segY<1 then segY=1 end if segX<1 then segX=1 end --[[ p(segX,"X") p(segY,"Y") p(segO,"O") p(theta,"theta") p(phi,"phi") ]] lb=band.Add(segO, segX, segY, rho, theta, phi) --local lb=band.GetCount() if ZL==true then band.SetGoalLength(lb,math.random(1)) band.SetStrength(lb,math.random(10)) else band.SetGoalLength(lb,math.random(band.GetLength(lb)*2)) end end end end function Delbands() freshbands = band.GetCount() for h = oldbands, freshbands-1 do band.Delete(oldbands+1) end end cival=behavior.GetClashImportance() if cival<0.1 then cival = 1 end oldbands = 0 oldbands = band.GetCount() Qbands = 0 CheckAla() if AllAla==true then p(" No shaking, still mutating if checked.") end function Dia() if band.GetCount()~=0 then Bands=true end for i=1, nSegs do if structure.IsMutable(i) then MM = true end end opt = dialog.CreateDialog("Options.") opt.maxci=dialog.AddSlider("MaxCI:",cival,0.1,1,2) opt.Qq=dialog.AddCheckbox(" Quake.",true) opt.Bs=dialog.AddCheckbox(" BiS.",true) opt.Cmb=dialog.AddCheckbox(" Combine Quake and BiS.",false) opt.Sk=dialog.AddCheckbox(" Shock.",true) opt.Tg=dialog.AddCheckbox(" Tailgrab.",true) opt.fu = dialog.AddLabel("Fuzing threshold (negative value is gain)") opt.fuz = dialog.AddSlider("", -50, -100, 100, 1) if Bands then opt.KB=dialog.AddCheckbox("Keep original bands", true) opt.KBE=dialog.AddCheckbox("Keep enabled always",false) opt.KBSTR=dialog.AddCheckbox("Keep original strength and goal length", true) end if MM then opt.mut=dialog.AddCheckbox("Mutate once, after bands",true) opt.muta=dialog.AddCheckbox("Mutate after bands and in fuze",false) -- once or twice randomly chosen every run end opt.ok = dialog.AddButton("Go go!",1) dialog.Show(opt) QQ=opt.Qq.value BiS=opt.Bs.value Shock=opt.Sk.value TG=opt.Tg.value Combo=opt.Cmb.value fuzt=opt.fuz.value cival=opt.maxci.value if Bands then KB=opt.KB.value KBE=opt.KBE.value KBSTR=opt.KBSTR.value end if MM then mut=opt.mut.value muta=opt.muta.value end if fuzt<=0 then FF = (-1*fuzt) end return mut, muta, cival, fuzt, FF, BiS, QQ, TG, Shock, Combo end save.Quicksave(1) save.Quicksave(2) startscore = score() bestscore = startscore p(" Startscore: "..cut(score())) p(" Best score in quicksave slot 1, starting pose in slot 2 ") p(" maxCI = "..cival) function ZLb() if Combo==false then if BiS then p(" BiS ") for i=1, 2 do spacebands(nSegs/2) pci=(math.random(cival*100)/100) setCI(pci) p(" Wiggle CI:", pci) bandpull(0.2,1) Delbands() if not KBE then band.DisableAll() end Test() end end--bis end--combo ZL=true if Shock then p(" Shock ") for u=1, 2 do spacebands(nSegs/2) pci=(math.random(cival*100)/100) setCI(pci) p(" Wiggle CI:", pci) if KB then band.EnableAll() end wig('wb',5,1) Delbands() if not KBE then band.DisableAll() end Test() end end ZL=false end function BandAcross() p(" TailGrab ") for i=1, nSegs do if structure.IsLocked(i)==false then first=i break end end for u=nSegs, 1, -1 do if structure.IsLocked(u)==false then last=u break end end band.AddBetweenSegments(first,last) bandage() pci=(math.random(cival*100)/100) setCI(pci) p(" Wiggle CI:", pci) bandpull(0.2,1.4) Delbands() if not KBE then band.DisableAll() end Test() RM=math.random(-100,100) if RM>=0 then bloat=false else bloat=true end band.AddBetweenSegments(nSegs/2,first) band.AddBetweenSegments(nSegs/2,last) bandage() pci=(math.random(cival*100)/100) setCI(pci) p(" Wiggle CI:", pci) bandpull(0.2,1.4) Delbands() if not KBE then band.DisableAll() end Test() end function Quake() if Combo then p(" Combo ") for i=1, 4 do RM=math.random(-100,100) if RM>=0 then bloat=false else bloat=true end nrR=math.random(1, 19) for u=1, nrR do seg1=math.random(1,nSegs) seg2=math.random(1,nSegs) while structure.IsLocked(seg1) do seg1=math.random(1,nSegs) end while structure.IsLocked(seg2) do seg2=math.random(1,nSegs) end while seg1==seg2 do seg1=math.random(1,nSegs) end band.AddBetweenSegments(seg1,seg2) end bandage() Qbands=band.GetCount() spacebands(10) pci=(math.random(cival*100)/100) setCI(pci) p(" Wiggle CI:", pci) bandpull(0.2,2) Delbands() if not KBE then band.DisableAll() end Test() end else p(" Quake ") for i=1, 2 do RM=math.random(-100,100) if RM>=0 then bloat=false else bloat=true end nrR=math.random(1, 19) for u=1, nrR do seg1=math.random(1,nSegs) seg2=math.random(1,nSegs) while structure.IsLocked(seg1) do seg1=math.random(1,nSegs) end while structure.IsLocked(seg2) do seg2=math.random(1,nSegs) end while seg1==seg2 do seg1=math.random(1,nSegs) end band.AddBetweenSegments(seg1,seg2) end bandage() pci=(math.random(cival*100)/100) setCI(pci) p(" Wiggle CI:", pci) bandpull(0.2,2) Delbands() if not KBE then band.DisableAll() end Test() end --quake end --combo end function main() Dia() if not KB then band.DeleteAll() oldbands=0 end while true do if QQ or Combo then Quake() end ZLb() if TG then BandAcross() end save.Quickload(1) end end err=xpcall(main,End)

Comments