Back to Recipes Homepage
recipe picture
Recipe: SmartRebuild V3.31
Your rating: None Average: 3.6 (5 votes)
Used 149 times with an average impact of 11340 points.


Name: SmartRebuild V3.31
ID: 6215
Created on: Mon, 07/26/2010 - 07:18
Updated on: Mon, 07/26/2010 - 14:18

Needs a selection in selection interface. See script for details.

Best For


Joined: 09/18/2009
Groups: SETI.Germany
That's how the code does look like

-- lua script Smart Rebuild 3.x for FoldIt by Crashguard303
-- Performs a rebuild of a user specified selection (use new interface to make your selection!).
-- Calculates the sum of segment scores to get a reference value and handle puzzle score results under 0.
-- Default is 10 passes and no score threshold, so the first try is always stored as refrence for the other attempts.
--- Note: The script doesn't have any influence on the rebuild algorithm itself, it can only check the end results.
--- If you see better scoring results within the process, press space to store it!

function SmartRebuild(tries,iter,crunch)
-- internal values:
resets=0 -- counts how often reset is used (better result as before)
restores=0 -- counts how often restore is used (worser result as before)
equals=0 -- counts how often and equal result was found

--clean up values:
if tries<1 then tries=1 end -- assure that we minimum make one try

if iter<1 then iter=1 end -- and one iteration

numSegs=get_segment_count() -- get total number of segments

if crunch==nil then crunch=true end
if crunch==true then
print("Creating reference state...")
end -- if

reset_recent_best() -- a backup at start

print("Running multiple rebuild...")
for try=1,tries do -- perform loop for number of tries
pscore1=get_score(true) -- get score before rebuild
if try>1 then print() end
print ("Pass ",try,"/",tries)
if try>1 then print("better:",resets, " equal:",equals," worse:",restores, " so far") end
print("Before rebuild: ",pscore1)


pscore2=get_score(true) -- get score after rebuild
-- calculate puzzle score difference
print ("After:",pscore2," delta:",delta)
-- show score after rebuild and difference

if delta<0 then -- if negative score change, restore
print("Worse backbone found. Last one loaded.")
elseif delta>0 then -- if positive score change, store
print("Better backbone found and saved.")
print("No change.")
end -- if
end -- try loop
print("Finished with ",resets," resets and ",restores," restores.")
-- at loop-end, show # of resets and restores
end -- function

-- user parameters:
-- tries -- this is the number of passes
-- iter -- number of iterations per rebuild.
-- crunch -- if true, before checking multiple rebuilds, a single rebuild solution is created and saved,
-- so that there is a score reference (recommended)

-- Note!
-- If this is not your first run without changes in the puzzle, you can set this to false.

-- SmartRebuild(tries,iter,crunch)


Rav3n_pl's picture
User offline. Last seen 13 weeks 1 day ago. Offline
Joined: 06/17/2010

Error in algorithm!
Do NOT reset recent best while rebuilding!
In some cases there are better results during rebuild, then score drops!
Just RESET after 1st rebuild, rebuild in loop and restore at end.
You may also restore in loop, but IMO is useless. Better score is always stored in recent best.

Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.



Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons