Icon representing a recipe

Recipe: ->FuzEvolution<-

created by amayhew

Profile


Name
->FuzEvolution<-
ID
46325
Shared with
Public
Parent
None
Children
None
Created on
June 20, 2013 at 18:24 PM UTC
Updated on
June 20, 2013 at 18:24 PM UTC
Description

my version of Evolution of fuze v1 beta

Best for


Code


--[[ Got fuzes is my version of Evolution of fuzes. Loops through opcodes as shown below. optimized opcodes, Opcodes as well as Fuzes evolve by Score now ]]-- -- options VVVV normal=true --set false to seek energy in exploration puzzles minPpi = 2 --minimum poinst gain from loop to run again allowloss = 300 --minimum loss per round before recent best is restored -- acceptloss = 100 --the amount of loss your willing to accept per round without restore of recentbest -- end of options ^^^^^^ opcodes={} opcodes_old={} --[[ Opcodes 1=set CI 1 and wiggle 2=set CI .9 and wiggle 3=set CI .8 and wiggle 4=set CI .7 and wiggle 5=set CI .6 and wiggle 6=set CI .5 and wiggle 7=set CI .4 and wiggle 8=set CI .3 and wiggle 9=set CI .2 and wiggle 10=set CI .1 and Shake sidechains 11=set CI .08 and Shake sidechains 12=set CI .05 and Shake sidechains 13=set CI .03 and Shake sidechains 14=set CI .01 and Shake sidechains 15=Shake sidechains 16=Shake sidechains 17=mutate ]]-- gainbefore=0 gainafter=0 beforescore=0 afterscore=0 startingscore=0 rbscore=0 qsb4score=0 qsaftscore=0 round=0 function evolve() operation=math.random(10) if(operation<=6) then pos=math.random(table.getn(opcodes)) opcodes[pos]=math.random(9) end if(operation>6 and operation<=7) then table.remove(opcodes, math.random(table.getn(opcodes))) end if(operation>7) then table.insert(opcodes, math.random(table.getn(opcodes)+1), math.random(18)) end -- print(table.concat(opcodes, ", ")) -- Finished updating opcodes print("Round "..round, "Score "..beforescore) print("Executing New Round "..round+1) round=round+1 save.Quicksave(85) beforescore=opcodeExec(opcodes) print("New round score "..current.GetScore()) afterscore=current.GetScore() save.Quicksave(86) if(afterscore>=rbscore) then rbscore=current.GetScore() recentbest.Save() print("New Best Score "..rbscore) end if(afterscore>=qsb4score) then save.Quicksave(85) qsb4score=current.GetScore() print("New Quicksave Score "..qsb4score) end if(afterscore>beforescore) then print("Fuze is Evolving") opcodes_old=opcodes end if(afterscore==beforescore) then print("Fuze is Stabolizing") opcodes_old=opcodes end if(afterscore<beforescore) then print("Fuze is De-Evolving") opcodes=opcodes_old end if(afterscore<qsb4score) then save.Quickload(85) qsb4score=current.GetScore() print("Re-Evolving the Fuze") end if(afterscore<rbscore-allowloss) then recentbest.Restore() rbscore=current.GetScore() print("Re-Evolving the Fuze") end end function evolverFuzes() print("Creating dialog") local dlg = dialog.CreateDialog("Start sequence prompt") dlg.label=dialog.AddLabel("Start sequence:") dlg.button=dialog.AddButton("OK", 1) dlg.tbox=dialog.AddTextbox("startSeq", "9 1 3 1 6 1 1 1 1") dialog.Show(dlg) local opString=dlg.tbox.value print(opString) for opCode in string.gmatch(opString, "[0-9]*") do print("inserting "..opCode) table.insert(opcodes,tonumber(opCode)) end print("Starting Score "..current.GetScore()) startingscore=current.GetScore() print("Quicksave Starting Score") save.Quicksave(84) print("Quicksave Before Score "..current.GetScore()) qsb4score=current.GetScore() save.Quicksave(85) print("Recent Best Score "..current.GetScore()) recentbest.Save() --rbscore=current.GetScore() print("Starting round"..round+1) round=round+1 beforescore=opcodeExec(opcodes) print("Round "..round, "Score "..current.GetScore()) print("Quicksave After Score "..current.GetScore()) save.Quicksave(86) qsaftscore=current.GetScore() afterscore=current.GetScore() opcodes_old=opcodes while(true) do evolve() end end function opcodeExec(inCodes) print("executing "..table.concat(inCodes,",")) local scorein=current.GetScore() for i, opcodeE in ipairs(inCodes) do -- print("got "..opcodeE) if(opcodeE==1) then -- print("CI 1.0") behavior.SetClashImportance(1.0) structure.WiggleAll(5) end if(opcodeE==2) then -- print("CI 1.0") behavior.SetClashImportance(0.9) structure.WiggleAll(5) end if(opcodeE==3) then -- print("CI 1.0") behavior.SetClashImportance(0.8) structure.WiggleAll(5) end if(opcodeE==4) then -- print("CI 1.0") behavior.SetClashImportance(0.7) structure.WiggleAll(5) end if(opcodeE==5) then -- print("CI 1.0") behavior.SetClashImportance(0.6) structure.WiggleAll(5) end if(opcodeE==6) then -- print("CI 1.0") behavior.SetClashImportance(0.5) structure.WiggleAll(3) end if(opcodeE==7) then -- print("CI 1.0") behavior.SetClashImportance(0.4) structure.WiggleAll(3) end if(opcodeE==8) then -- print("CI 1.0") behavior.SetClashImportance(0.3) structure.WiggleAll(1) end if(opcodeE==9) then -- print("CI 1.0") behavior.SetClashImportance(0.2) structure.WiggleAll(1) end if(opcodeE==10) then -- print("CI 1.0") behavior.SetClashImportance(0.1) structure.ShakeSidechainsAll(1) end if(opcodeE==11) then -- print("CI 1.0") behavior.SetClashImportance(0.08) structure.ShakeSidechainsAll(1) end if(opcodeE==12) then -- print("CI 1.0") behavior.SetClashImportance(0.05) structure.ShakeSidechainsAll(1) end if(opcodeE==13) then -- print("CI 1.0") behavior.SetClashImportance(0.03) structure.ShakeSidechainsAll(1) end if(opcodeE==14) then -- print("CI 1.0") behavior.SetClashImportance(0.01) structure.ShakeSidechainsAll(1) end if(opcodeE==15) then -- print("CI 1.0") structure.ShakeSidechainsAll(1) end if(opcodeE==16) then -- print("CI 1.0") structure.ShakeSidechainsAll(1) end if(opcodeE==17) then -- print("CI 1.0") structure.MutateSidechainsAll(1) end end return current.GetScore() end evolverFuzes() --end of script

Comments


amayhew Lv 1

below are the opcode choices but i like the defaults

–[[ Opcodes
1=set CI 1 and wiggle
2=set CI .9 and wiggle
3=set CI .8 and wiggle
4=set CI .7 and wiggle
5=set CI .6 and wiggle
6=set CI .5 and wiggle
7=set CI .4 and wiggle
8=set CI .3 and wiggle
9=set CI .2 and wiggle
10=set CI .1 and Shake sidechains
11=set CI .08 and Shake sidechains
12=set CI .05 and Shake sidechains
13=set CI .03 and Shake sidechains
14=set CI .01 and Shake sidechains
15=Shake sidechains
16=Shake sidechains
17=mutate
]]–