Icon representing a recipe

Recipe: V2 Rav3n_pl Total FuzeR v1.1

created by CharlieFortsConscience

Profile


Name
V2 Rav3n_pl Total FuzeR v1.1
ID
30998
Shared with
Public
Parent
None
Children
Created on
August 11, 2011 at 17:20 PM UTC
Updated on
August 11, 2011 at 17:20 PM UTC
Description

A working V2 version

Best for


Code


--[[ Total FuzeR v1 a randomised fuze What it magically 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. ]]-- 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 teh math library ]]-- function Score() return current.GetEnergyScore() 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(3,true,false) elseif how == "ws" then structure.WiggleAll(3,false,true) elseif how == "wa" then structure.WiggleAll(1) 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=250 --how many tries reboot=4 --reset to recent best every x times no improvement FuzeR()

Comments