Back to Recipes Homepage
recipe picture
Recipe: SmartRebuild V3.22
Your rating: None
Used 150 times with an average impact of 8230 points.


Name: SmartRebuild V3.22
ID: 5445
Created on: Wed, 07/14/2010 - 15:33
Updated on: Wed, 07/14/2010 - 15:33

Now using FoldIt's new get_score()-command. 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)

--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("Resets:",resets," restores:",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)


Joined: 09/18/2009
Groups: SETI.Germany

This recipe is obsolete now.

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