Profile
| Name: |
Smart Rebuild 2.42 |
| ID: |
2657 |
| Created on: |
Sun, 06/06/2010 - 14:32 |
| Updated on: |
Sun, 06/06/2010 - 21:32 |
| Description: |
Performs rebuild on a selection made in the new interface, and stores only better results after the first pass. See script for more information. |
Best For
Comments
|
| | |
|
Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
| |
| | |
| | |
|
-- lua script "Smart Rebuild" 2.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,savefirsttry)
-- tries -- this is the number of passes
-- iter -- number of iterations per rebuild.
-- savefirsttry -- after first try , before comparing segment score sum
-- 0: store first solution anyway, so that we have a reference (recommended)
-- >x: store only if solution is above x Puzzle-Points (depends on puzzle, if this is possible)
-- <0: don't store first solution in general, so it has to be better than the initial state.
-- Note!
-- If this is your second run without changes in the puzzle, you can set this to <0.
-- If you have loaded a solution (by file or undo) you want to improve, set this to <0.
resets=0 -- counts how often reset is used (better result as before)
restores=0 -- counts how often restore is used (worser result as before)
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
reset_recent_best() -- a backup at start
for try=1,tries do -- perform loop for number of tries
pscore1=0
for seg=1,numSegs do
pscore1=pscore1+get_segment_score(seg)
-- to get a reference and score beneath zero, we add the segment scores
end
print ("Pass # ",try,":")
if try>1 then print(resets," Resets, ",restores, " Restores so far") end
print (" Segment score sum: ",pscore1)
do_local_rebuild(iter)
if (try == 1) and (savefirsttry>=0) then
temp=get_score()
-- get puzzle score
if (temp>=savefirsttry) or (savefirsttry==0) then reset_recent_best() end
end
-- rebuilding most times drops the score,
-- so most times we have to store the first attempt
-- as reference for the next attempts
pscore2=0
for seg=1,numSegs do
pscore2=pscore2+get_segment_score(seg) -- sum of segment scores after rebuild
end
delta=pscore2-pscore1
-- calculate puzzle score difference
print (pscore1)
print (pscore2," Delta: ",delta)
-- show score after rebuild and difference
if delta<0 then restore_recent_best() restores=restores+1 end
-- if negative score change, restore
if delta>0 then reset_recent_best() resets=resets+1 end
-- if positive change, store
end
print("Finished with ",resets," resets and ",restores," restores.")
-- at loop-end, show # of resets and restores
end
-- remember SmartRebuild(tries,iter,savefirsttry)
SmartRebuild(10,10,0)