Profile


Name
REH III.2
ID
31616
Shared with
Public
Parent
None
Children
Created on
September 02, 2011 at 02:24 AM UTC
Updated on
September 02, 2011 at 02:24 AM UTC
Description

improved script , error debugging

Best for


Code


----Firejuggler reh III.1 --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 recentbest.Restore () 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=7 --how many tries reboot=4 --reset to recent best every x times no improvement function dist(a,b,c) -- local j=0 -- Count the number of close segment for i=1,structure.GetCount() do -- if structure.GetDistance(a,i)<10 then j=j+1 end -- end if b==true then -- k=18-j -- determine the number of band print("nombre de bande ".. k) if k>0 then repeat l=math.random(1,structure.GetCount()) -- if structure.GetDistance(a,l)<20 then -- add k number of band, random end, if structure.GetDistance(a,l)>10 then -- with the constrainst of being in the distance band.AddBetweenSegments(a,l) -- between 10 and 20 'unit", band.SetStrength(band.GetCount(),c) -- k=k-1 -- decrease the band counter end end until k==0 end end return j -- j is used to determine if the hydrophobic segment need to be rebuild end function rb_expo () local j=0 local k=1 local l=1 local m=0 local n=0 local p=0 local bnd_str=0.5 local sc1=0 sc1=current.GetScore() for i=1, structure.GetCount() do -- structure.SetSecondaryStructure(i,"l") -- change structure to loop end -- save.Quicksave(100) p=current.GetScore() for i=1, structure.GetCount() do selection.DeselectAll() --remove any selection if structure.IsHydrophobic (i)==true then n=dist(i) l= i-1 -- Used to determine the 'range' rebuild by the script m=i+1 if current.GetSegmentEnergySubscore(i, "hiding")<-19 then -- Low hiding score is a caracteristic of exposed hydro if n<18 then -- number of close segment print ("reconstruction du segment ".. i) repeat if l<1 then l=1 end -- Error check on the starting segment if m>structure.GetCount() then m=structure.GetCount() end -- Error check on the ending segment behavior.SetClashImportance(0) repeat selection.SelectRange(l,m) structure.RebuildSelected(1) j=j+1 -- try to rebuild the segment 10 time before extending the range if j>9 then -- print("extension de la reconstruction des segment "..l.." -"..m.." jusqu'a" ) l=l-1 -- m=m+1 if l <1 then l=1 end -- if m>structure.GetCount() then m=structure.GetCount() end print(l.." -"..m) -- j=0 end if m-l>7 then break end -- break if rebuild fail 30 times until p~=current.GetScore() -- stop trying to rebuild once it manage once sc1=current.GetScore() dist(i,true,bnd_str) -- create randomized band behavior.SetClashImportance(1) structure.WiggleAll(5) band.DeleteAll() structure.ShakeSidechainsAll(2) --trying to stabilise structure.WiggleAll(5,false,true) -- structure.WiggleAll(5) -- FuzeR() if sc1< current.GetScore() then print("gain de "..sc1-current.GetScore().." points") sc1=current.GetScore() save.Quicksave(99) end if n >= dist(i) then save.Quickload(99) bnd_str=bnd_str+0.1 end l=i-1 m=i+1 j=0 selection.DeselectAll() until n<dist(i) save.Quicksave(100) end end selection.DeselectAll() bnd_str=0.3 end end FuzeR() save.Quickload(100) end rb_expo()

Comments


firejuggler Lv 1

Rebuild Exposed Hydrophobic III.2

Shouldn't crash anymore.
Try to hide the exposed hydrophobic segment. Score improvement may tag along.