Icon representing a recipe

Recipe: rebuild exposed hydro II

created by firejuggler

Profile


Name
rebuild exposed hydro II
ID
31284
Shared with
Public
Parent
rb_expo2
Children
Created on
August 22, 2011 at 00:23 AM UTC
Updated on
August 22, 2011 at 00:23 AM UTC
Description

added a proper fuze

Best for


Code


--Rav3n_pl Total FuzeR v1.1 --[[ Total FuzeR v1 a ranadomized fuze it does: shake on random CI wiggle all on random CI Shake and wiggle all on CI=1 min and max CI to randomize set at end of script. ]]-- --[[ Tlaloc`s math library ------------------------------------------------------------------------ The original random script this was ported from has the following notices: Copyright (c) 2007 Richard L. Mueller Hilltop Lab web site - http://www.rlmueller.net Version 1.0 - January 2, 2007 You have a royalty-free right to use, modify, reproduce, and distribute this script file in any way you find useful, provided that you agree that the copyright owner above has no warranty, obligations, or liability for such use. ------------------------------------------------------------------------ ]]-- local lngX = 1000 local lngC = 48313 local function _MWC() local S_Hi local S_Lo local C_Hi local C_Lo local F1 local F2 local F3 local T1 local T2 local T3 local A_Hi = 63551 local A_Lo = 25354 local M = 4294967296 local H = 65536 local S_Hi = math.floor(lngX / H) local S_Lo = lngX - (S_Hi * H) local C_Hi = math.floor(lngC / H) local C_Lo = lngC - (C_Hi * H) local F1 = A_Hi * S_Hi local F2 = (A_Hi * S_Lo) + (A_Lo * S_Hi) + C_Hi local F3 = (A_Lo * S_Lo) + C_Lo local T1 = math.floor(F2 / H) local T2 = F2 - (T1 * H) lngX = (T2 * H) + F3 local T3 = math.floor(lngX / M) lngX = lngX - (T3 * M) lngC = math.floor((F2 / H) + F1) return lngX end local function _abs(value) if value < 0 then value = -value end return value end local function _floor(value) return value - (value % 1) end local function _randomseed(x) lngX = x end local function _random(m,n) if n == nil and m ~= nil then n = m m = 1 end if (m == nil) and (n == nil) then return _MWC() / 4294967296 else if n < m then return nil end return math.floor((_MWC() / 4294967296) * (n - m + 1)) + m end end math= { abs = _abs, floor = _floor, random = _random, randomseed = _randomseed, } --[[ End math library ]]-- function Score() return current.GetScore() end function seed() local s=math.abs(Score()) s=s%0.001 s=1/s while s<10000000 do s=s*10 end s=s-s%1 math.randomseed(s) end seed() segCnt=structure.GetCount() p=print function round(x)--cut all afer 3-rd place return x-x%0.001 end function Wiggle(how, iters, minppi) if how==nil then how="wa" end if iters==nil then iters=6 end if minppi==nil then minppi=0.004 end if iters>0 then iters=iters-1 sp=Score() if how == "s" then structure.ShakeSidechainsAll(1) elseif how == "wb" then structure.WiggleAll(1,true,false) elseif how == "ws" then structure.WiggleAll(1,false,true) elseif how == "wa" then structure.WiggleAll(1,true,true) end ep = Score() ig=ep-sp if how~="s" then if ig > minppi then Wiggle(how, iters, minppi) end end end end function ShowBest() if #gainTable>2 then p("Best scoring settings:") for i=1,#gainTable do p("Sci: ",gainTable[i][2]," Wci: ",gainTable[i][3]," Gain:",gainTable[i][1]) end end end gainTable={} function Gained(sci,wci,gain) gainTable[#gainTable+1]={round(gain),round(sci),round(wci)} if #gainTable>1 then for a=1,#gainTable-1 do for b=a+1,#gainTable do if gainTable[a][1]<gainTable[b][1] then gainTable[a],gainTable[b]=gainTable[b],gainTable[a] end end end end if #gainTable>5 then gainTable[#gainTable]=nil end ShowBest() end bestScore=Score() function SaveBest(sci,wci) local g=Score()-bestScore if g>0 then bestScore=Score() p("Gained another ",round(g)," pts. Current score: ",round(bestScore)) save.Quicksave(3) Gained(sci,wci,g) end end function Fuze(sci,wci) behavior.SetClashImportance(sci) structure.ShakeSidechainsAll(1) behavior.SetClashImportance(wci) structure.WiggleAll(2) behavior.SetClashImportance(1) structure.ShakeSidechainsAll(1) structure.WiggleAll(2) SaveBest(sci,wci) end function FuzeR() local ss=Score() p("Starting Total FuzeR. ",loops," loops. Score=",round(ss)) selection.SelectAll() recentbest.Save () rebootCount=0 sdiff=maxSci-minSci wdiff=maxWci-minWci for i=1,loops do s=Score() sci=round(math.random()*sdiff)+minSci wci=round(math.random()*wdiff)+minWci p("Fuze ",i," of ",loops,". Shake CI= ",sci," Wiggle CI=",wci) Fuze(sci,wci) if Score()-s <0 then rebootCount=rebootCount+1 end if rebootCount>=reboot then restore_recent_best() p("Rebooting to best.") rebootCount=0 end end p("FuzeR completed, gain: ",round(Score()-ss)) ShowBest() end minSci=0.05 --minimum shake CI maxSci=0.35 --maximim shake CI minWci=0.1 --minimum wiglle CI maxWci=0.7 --maximum wiggle CI loops=4 --how many tries reboot=4 --reset to recent best every x times no improvement function dist(a,b) local j=0 for i=1,structure.GetCount() do if structure.GetDistance(a,i)<10 then j=j+1 else if b==true then if structure.GetDistance(a,i)<20 then band.AddBetweenSegments(a,i) band.SetStrength(band.GetCount(),0.3) if band.GetCount()>15 then break end end end end end return j end function rb_expo () local j =1 local k=1 local l=1 local m=0 local n=0 local p=0 for i=1, structure.GetCount() do structure.SetSecondaryStructure(i,"l") end for i=1, structure.GetCount() do hd_sc=0 selection.DeselectAll() if structure.IsHydrophobic (i)==true then n=dist(i,false) save.Quicksave(100) l= i-j m=i+j print(n) if current.GetSegmentEnergySubscore(i, "hiding")<-15 then if n<18 then repeat p=current.GetScore() if l<1 then l=1 end if m>structure.GetCount() then m=Structure.GetCount() end selection.SelectRange(l,m) structure.RebuildSelected(1) if p~=current.GetScore() then dist(i,true) behavior.SetClashImportance(0.5) structure.WiggleAll(5) band.DeleteAll() FuzeR() if n>dist(i,false) then l=i-1 m=i+1 else break end end p=dist(i) if p<n then save. Quickload(100) else if p>n then n=dist(i) save.Quicksave(100) end end n=dist(i) print(n) if l-m>7 then break end until n>18 FuzeR() end end l=1 m=1 selection.DeselectAll() end end end rb_expo()

Comments


firejuggler Lv 1

added a proper Fuze, limited the number of band, reduced the band strength.
Thanks Raven for Total FuzeR 1.1, wich I converted to V2 Lua

you might get point from it