Profile


Name
Low2High 1.1
ID
49633
Shared with
Public
Parent
Low2High 1.0
Children
None
Created on
July 18, 2022 at 18:41 PM UTC
Updated on
July 18, 2022 at 18:41 PM UTC
Description

Infinite run: 4 quick tests (e.g. shifting from latest result in Low wiggle power to High wiggle power), 4 quick tests wiggles

Best for


Code


--[[Low2High by Bruno Kestemont v1.0 To shift from Low wiggle power to High or Medium wiggle power, best shift v1.1 continues trying if no success, indefinitely, but keeps the best ones in undos ]]-- recipeName="Low2High" version="1.1" ci=behavior.SetClashImportance wiggle=structure.WiggleAll kOriginalStructureOrNewBest = 1 -- the starting structure, or any subsequent improvement, will be stored in this quicksave slot LowSlot=10 -- The starting structure at low wiggle power counterSlot=10 minimum=0.20 -- the minimum move (0.20=20%) under which to try other method than simple wiggle medium function r3 ( i ) -- printing convenience return i - i % 0.001 end function Score() return current.GetEnergyScore() end function scorebest() -- adapted in order to take track of all different results counterSlot=counterSlot+1 save.Quicksave ( counterSlot ) if ( Score() > best_score ) then best_score = Score() print ( ">>> Improvement to ".. r3 ( best_score ) ) save.Quicksave ( kOriginalStructureOrNewBest ) end end function Abstract() print("Abstract:") for i=LowSlot, counterSlot do save.Quickload ( i ) print(i..") "..r3(Score())) end save.Quickload (LowSlot) save.Quickload ( kOriginalStructureOrNewBest ) print("Undos ending with start (Low) score then best score") end function SimpleFuze(cii1,cii2,cii3) for loop = 1, 3 do print("Quick fuze "..loop) save.Quickload ( LowSlot ) if loop<2 then cii=cii1 elseif loop<3 then cii=cii2 else cii=cii3 end ci(cii) wiggle(1,true,false) ci(1) wiggle(25,true,true) scorebest() end end function main() print (recipeName, version) format=string.format print(format("current score: %.3f",current.GetScore())) math.randomseed(os.clock()) math.random() --recentbest.Save() save.Quicksave ( kOriginalStructureOrNewBest ) save.Quicksave ( LowSlot ) best_score = Score() startScore=Score() --print ( "Start score " .. r3 ( best_score ) ) for i= 1, 1000 do save.Quickload ( kOriginalStructureOrNewBest ) save.Quicksave ( LowSlot ) -- starting again from the best advanced one loopScore=Score() print("Loop "..i.. "/1000") print(format("current score: %.3f",current.GetScore())) --Simple wiggle all ci(1) print("Simple wiggle all") wiggle(25,true,true) scorebest() if loopScore * (1+minimum) >Score() then -- if it didn't move more than minimum%, try other ways --wiggle all after small disturbance (small fuze) local ccci1, ccci2, ccci3= 0.9, 0.5, 0.01 repeat print("Trying with other settings") SimpleFuze(ccci1*1.05,ccci2*0.9,ccci3*0.7) until loopScore * (1+minimum/2) <Score() end Abstract() end end function cleanup () start,stop,line,msg=err:find(":(%d+):%s()") err=err:sub(msg,#err) print('---') if err:find('Cancelled')~=nil then print("User stop.") else print("unexpected error detected.") print("Error line:", line) print("Error :", err) end recentbest.Restore() print ( "Cleaning up" ) behavior.SetClashImportance ( 1.0 ) print("Start score= "..r3(startScore).." Total gain= "..r3(Score()-startScore)) end --main () xpcall ( main , cleanup )

Comments


Bruno Kestemont Lv 1

1) First simple Wiggle ( in cas you just changed from Low to Medium or High wiggle power).
2) If it did not gain more than 20% points, it starts 3 different quick fuzes
3) If it did not gain more than 10%, it starts again indefinitely with other fuze settings
ALWAYS starting from the starting position again.

All solutions are printed and available in successive undos.

B) If it did gain more than 20%:
Start again everything with this new score as a new starting position.

Note: This is intended to jump from Low to High wp. It could also be used to unlock a situation, but due to settings ("20% gain") you should stop it quickly in this case.