Icon representing a recipe

Recipe: Freeze Burst v1.2

created by StackOverflow

Profile


Name
Freeze Burst v1.2
ID
48700
Shared with
Public
Parent
None
Children
None
Created on
March 31, 2014 at 14:09 PM UTC
Updated on
March 31, 2014 at 14:09 PM UTC
Description

Freezes the best, fuses the rest.

Best for


Code


-- Freeze Burst v1.2 -- -- added "MaximumWiggle" to bleed every last point out of each burst -- -- now allowing for puzzles with locked structures, such as 'docking design' -- Freeze Burst v1.1 -- -- added code cleanup if script is cancelled by user -- -- Freeze Burst v1.0 -- -- Written by StackOverflow -- saveSlot = 92 startScore = current.GetScore () savedScore = current.GetScore () startRank = scoreboard.GetRank () clash = behavior.GetClashImportance () save.Quicksave ( saveSlot ) function main () print ( "Freeze Burst started" ) frozen = structure.GetCount () - TotalLockedStructures () - 2 while ( frozen > 1 ) do FreezeBurst ( frozen ) frozen = frozen / 2 end print ( "Freeze Burst finished" ) Report () end function FreezeBurst ( freeze_count ) FreezeBest ( freeze_count ) QuickFuseBurst () freeze.UnfreezeAll () RestoreBest () end function cleanup () behavior.SetClashImportance ( clash ) RestoreBest () freeze.UnfreezeAll () end function Report () d = dialog.CreateDialog ( "Freeze Burst" ) d.lbl1 = dialog.AddLabel ( "Freeze Burst finished" ) if ( savedScore > startScore ) then d.lbl2 = dialog.AddLabel ( "+" .. ( savedScore - startScore ) .. " points!" ) rank = scoreboard.GetRank () if ( rank < startRank ) then d.lbl3 = dialog.AddLabel ( "Gained " .. ( startRank - rank ) .. " Ranks!" ) end else d.lbl4 = dialog.AddLabel ( "No gains achieved, sorry :(" ) end d.btn = dialog.AddButton( "Thanks" , 1 ) dialog.Show ( d ) end function RestoreBest () cscore = current.GetScore () if ( cscore > savedScore ) then print ( "+" .. (cscore - savedScore) .. " points!" ) savedScore = cscore save.Quicksave ( saveSlot ) else save.Quickload ( saveSlot ) end end -- maximum wiggle, tracks score increase, wiggling until the score stops going up -- function MaximumWiggle () decimals = 3 cscr = current.GetScore () - 1 nscr = round ( current.GetScore () , decimals ) iter = 2 while ( nscr > cscr ) do structure.WiggleAll ( iter , true , true ) cscr = nscr nscr = round ( current.GetScore () , decimals ) iter = iter + 1 end end function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end function TotalLockedStructures () c = 0 for i = 1 , structure.GetCount () do if ( structure.IsLocked ( i ) ) then c = c + 1 end end return c end function QuickFuseBurst () temp = behavior.GetClashImportance () behavior.SetClashImportance ( 0.01 ) structure.WiggleAll ( 2 ) structure.ShakeSidechainsAll ( 2 ) behavior.SetClashImportance ( 0.5 ) structure.WiggleAll ( 2 ) structure.ShakeSidechainsAll ( 1 ) behavior.SetClashImportance ( 1 ) structure.WiggleAll ( 2 ) structure.ShakeSidechainsAll ( 1 ) MaximumWiggle () behavior.SetClashImportance ( temp ) end function FuseBurst () temp = behavior.GetClashImportance () ci = 0.01 while ( ci < 1 ) do behavior.SetClashImportance ( ci ) structure.WiggleAll ( 2 ) structure.ShakeSidechainsAll ( 2 ) ci = ci * 2 end behavior.SetClashImportance ( 1 ) structure.WiggleAll ( 4 ) structure.ShakeSidechainsAll ( 1 ) behavior.SetClashImportance ( temp ) end function FreezeBest ( top ) t = top while ( t >= 1 ) do t = t - 1 bestid = 0 bestsc = 0 for i = 1 , structure.GetCount () do if ( freeze.IsFrozen ( i ) == false and structure.IsLocked ( i ) == false ) then sc = current.GetSegmentEnergyScore ( i ) if ( sc > bestsc ) then bestid = i bestsc = sc end end end if ( bestid > 0 ) then freeze.Freeze ( bestid , true , true ) end end end xpcall ( main , cleanup )

Comments


StackOverflow Lv 1

When I was totally stuck, I wrote this up and it gained about 14 points, enough to rank me up :) can't promise it'll do the same for you, but give it a shot.

What it does:
Freezes the best scoring structures and Aggressively wiggles (Fuse Burst)
Repeats this process, freezing less and less of your protein as it goes.
Restores the best result

Enjoy

StackOverflow Lv 1

– Freeze Burst v1.2 –
– added "MaximumWiggle" to bleed every last point out of each burst –
– now compatible with puzzles that have locked structures, such as 'docking design' –

– Freeze Burst v1.1 –
– added code cleanup if script is cancelled by user –