Code
--JET 3.5, 2/10/2013 multilingual and more efficient
--Based on Total lws 1.0.4., WalkeR, LuckyLWS , Precise LWS and now also Acid Tweeker and others from multiwalk
--Best for joining evolver competition, or for very end of game to get the latest points
--do total LWS with different options then Lucky then Precise untill smallest gains.
--Most gains are optained in the beginning, so stop when you have enough, unless you are on the final sprint
--Bruno Kestemont 10 Jun 2013. Thanks to Jean-Bob
--added idealize function for PreciseLWS and Lucky LWS 19/7/2013. Not sure it's usefull (removed 25/8/13)
--new Stanley version with pentamers
--GRRR Had to change other by density
--to do: Lucky LWS is not very efficient on end puzzles
--2/10/13 raccourcit menu principal si deja fait. Imprime skipthis au bon moment
--16/10/13 a verifier: print module pas catholique
--3.2.2 nc adapted
--3.3 added Worm and adapted wiggle sequence
--3.4 intelligent filter management 01/09/2014
--3.4.1 Added notes and replaced QuickShake
--3.4.2 added maximo in at: should speed up
--3.5.0 added howmany and other SD-multiwalk functions
--3.5.1 fixed iFilterSettings
--3.5.2 fixed score(true) & added filterB in target 30/4/2015
--3.5.3 fixed test filter effect
--3.6 with dialog for only dessert, now skipping 2 twice a failing recipe
--Documentation en FR pour edition a la fin
---------------------------------------------------------------------------------------
--Start Generic JET parameters and functions
recipeName="JET 3.6"
FirstJET=true
historic=recipeName
global_ci=1
JETgain=0 --gain depuis le debut
gainRecipe=0 --gain de chaque recette
firstGain=0 --gain premiere recette
interuptor=false
comptetour=1
nextskip="" -- will be asigned a function name with no gain
oldskip="" -- in order to be able to retain 2 functions to skip
skipthis=false
lwsTable={} -- pour WalkeR
sphere_worst=false -- for AT, include worst segments in sphere or not
sphere_worst_value=0 -- for AT Intervient dans SelectSphere() pour decider a partir de quel score selectionner le segment voisi
save.Quicksave(9) --pour initialiser l'antepenultieme solution
save.Quicksave(10) --pour initialiser la version evoluable
save.Quicksave(11) --pour initialiser la version actuelle
saveNote1=structure.GetNote(1)
note1libre=true
OriginalFilterSetting = behavior.GetSlowFiltersDisabled() -- new BK 8/4/2013
bigLw=25 -- long wiggle pour New Chapter 26/02/2014
--Note: other calculated parameters are to be found in Stanley function section or elsewere bellow.
--end generic JET parameters and functions
-- Stanley V1.2, by B. Kestemont 19/06/2013
-- To find puzzle properties and targets
-- properties based on Tvdl 14-12-2012, autonomous enhanced version (BK 25/1/2012)
-- Targets by B. Kestemont
----------------------------------------------------------
--start generic Stanley variables section-------------------------
segCnt=structure.GetCount()
--segCnt=segCnt-1 -- for lingard puzzles only! sera initialise par seglock
flagligand=false
segCnt2=segCnt -- cas de ligands
while structure.GetSecondaryStructure(segCnt2)=="M" do segCnt2=segCnt2-1 flagligand=true end
segStart=1 --start from (Default option for JET)
segEnd=segCnt2 --end seg: nil=end of protein (Default option for JET) -- duplicat a verifier
badpuzzle={'713'} -- list of not implemented puzzles - to be edited on each bug
NOTIMPLEMENTED=false
WORKON={{1,segCnt2}}
normal= (current.GetExplorationMultiplier() == 0)
Cyslist={}
savebridges=false --default no bridgechecking
nrofbridges=0
HASMUTABLE=false
HASOTHER=false
OTHERWEIGHT=0
PROBABLESYM=false
PROBABLEFILTER=false
SEPSIS=false
ELECTRON=false
sym= 1 --Options: 1 normal; 2 dimer; 3 trimer; 4 tetramer (dimer of dimer) etc.
FREEDESIGN=false
timeLeft=os.difftime(puzzle.GetExpirationTime(),os.time())/86400 -- en jours
startTime=os.time() -- en secondes?
pprankrel=0.015*timeLeft/8 --pts per rank relative to score. Actuellement calibr sur 670 a 8 jours de la fin
groupscore=10*(800-scoreboard.GetGroupScore())
grouprank=scoreboard.GetGroupRank()
absbestscore=10*(800-absolutebest.GetScore()) -- changed BK 16/10/2013
flaglocked=false
lang="en"
uo={energy = false} -- a duplicate on Ebola but it's needed here before score computing
StartMultiplier=current.GetExplorationMultiplier() -- New BK 16/10/2013 for exploration puzzles
multiplier=StartMultiplier
if normal then multiplier=1 end -- case of normal puzzle
--end generic Stanley variables section--------------------------
--Start merged Stanley and recipe functions
function checkbadpuzzle()
if NOTIMPLEMENTED then
print("WARNING ! Puzzle not implemented")
end
end
function setlanguage()-- New BK 10/4/13
local player=user.GetPlayerName()
local group=user.GetGroupName()
if group=="L'Alliance Francophone" or player=="marie_s" or player=="bruno.kestemont" or player=="roukess" then
lang="fr"
else
lang="en"
end
return lang
end
function multilingual(lang)-- New BK 10/4/13, 25/8/13 WARNING: TO BE EDITTED FOR EACH RECIPE
if lang=="fr" then
-- translation table. do NOT replace %-letter combos
i18={
intro={
title="Stanley explorer 1.2 par BK",
exploration="Exploration du puzzle:"
},
ask={
ok="OK",
cancel="Annuler",
logCancel= "Action annule",
options={OnlyDessert= "Rien que le dessert svp (fin de jeu)"
},
},
stanley={
unlocked="-Libre: ",
bridges=" ponts;",
currenttarget="Objectif actuel: ",
cysteins=" cystides;",
distance2target="Distance l'objectif = ",
endstanley="Fin du module d'exploration Stanley",
to=" to ",
thereare="-Il y a ",
nolock="-pas de lock; ",
ligands="-ligands: ",
nobridge="-pas de pont;",
nobridgepossible="-pas de possibilit de pont;",
noligand="-pas de ligand;",
sepsis="Sepsis",
electron="Electron Density",
freedesign="-probablement free design;",
lookingtarget="Recherche d'un objectif",
maybe=" -peut-tre ",
nofreedesign="-pas free design;",
nomutable="-pas mutable;",
otherscore="-autres scores d'un poids suppplmentaire de ",
explorationpuzzle="Puzzle d'exploration",
nootherscore="-pas d'autre score;",
mutable="-mutable;",
mutables=" mutables;",
setoftargets="Jeu de cibles: ",
sym="-symtrique",
symdescr="-la destription parle de symtrique ...",
contacts="-contacts",
topscore="Top score estim: ",
nosym=" ... pas symtrique",
dimer=" ... dimre",
trimer=" ... trimre",
tetramer=" ... tetramre ou dimre de dimre",
pentamer=" ... pentamre"
},
recipe={
is3="tat du script restaur.",
m3a="Traitement des paramtres initiaux termin.",
m3b="Parcours systmatique de la protine.",
lw1="Rtablissement du meilleur score.",
lw2="Rtablissement de la structure secondaire.",
lw3="Rtablissement des bandes.",
lw4="Sauvegarde de l'tat du script dans note 1",
de1="Arrt utilisateur.",
de2="Erreur inattendue dtecte.",
de3="Ligne d'erreur : %i.",
de4="Message d'erreur : %s."
},
jet={
intro1="Join Evolver Team ("..recipeName..")",
intro2="Score de DEPART= ",
intro3="1 nuit de travail PC. Bonne nuit ",
signature="Signature dans note du segment 1",
running1="",
running2=" en cours ",
skipping="Saute ",
runningdessert="PETIT DESSERT n ",
maindishes="PLAT PRINCIPAL",
nogain="... ne gagna plus rien en ",
gain1="... gagna ",
gain2=" points en ",
tweak1="1) Tweak, remuer chaines latrales",
tweak2="2) Tweak around, remuer chaines latrales",
tweak3="3) Manipulateur brutal des chaines latrales",
tweakgain1="Gain Tweak: ",
tweakgain2="Gain Tweak around: ",
tweakgain3="Gain manipulateur: ",
tweakgain3nil=". Ignor si <0",
score="Score actuel ",
gainT=". >>>>Gain JET= ",
gainin="<<<< en ",
gaining="(gain en cours: ",
timeleft="Temps restant: ",
hours=" heures.",
maygain="Peut encore gagner ",
cleaning="Nettoyage",
restorestructure="Rtablissement de la structure secondaire",
savingbest="Enregistrement du meilleur rsultat",
undosave="Enregistrement de solution voluable dans Undo ou Slot 9",
alreadydone=" a dja te utilise.",
middlegame="Interruption de JET pour milieu de partie",
stopnow="Inutile d'insister avec JET maintenant",
suggestEbola="Je vous conseille de lancer Ebola",
interrupt="Interruption de JET, perte anormale",
signalerror="Merci de signaler ce bug a l'auteur"
}
}
else
i18={
intro={
title="Stanley explorer 1.2 by BK",
exploration="Puzzle exploration:"
},
ask={
ok="OK",
cancel="Cancel",
logCancel= "Action cancelled",
options={OnlyDessert="Only Dessert please (end game)"
},
},
stanley={
unlocked="-Unlocked: ",
to=" to ",
bridges=" bridges;",
currenttarget="Current target: ",
cysteins=" cysteins;",
distance2target="Distance to target = ",
endstanley="End of Stanley exploration module",
thereare="-There are ",
nolock="-no lock; ",
ligands="-ligands: ",
nobridge="-no bridge;",
nobridgepossible="-no possibility of bridge;",
noligand="-no ligand;",
sepsis="Sepsis",
electron="Electron Density",
freedesign="-probable free design;",
lookingtarget="Looking for a target",
maybe=" -may be ",
nofreedesign="-not free design;",
nomutable="-no mutable;",
mutable="-mutable;",
mutables=" mutables;",
otherscore="-other scores; additional weight of ",
explorationpuzzle="Exploration puzzle",
nootherscore="-no other score;",
setoftargets="Set of targets: ",
sym="-symmetric",
symdescr="-description says symmetric ...",
contacts="-contacts",
topscore="Estimated top score: ",
nosym=" ... not symmetric",
dimer=" ... Dimer",
trimer=" ... Trimer",
tetramer=" ... Tetramer or dimer of dimer",
pentamer=" ... Pentamer"
},
recipe={
is3="Script state loaded.",
m3a="Initial parameters treatment completed.",
m3b="Whole protein walking.",
lw1="Loading Highscore...",
lw2="Loading secondary structure...",
lw3="Loading bands...",
lw4="Saving script state in note 1", -- added BK 21/3/13
de1="User stop.",
de2="unexpected error detected.",
de3="Error line: %i.",
de4="Error : %s."
},
jet={
intro1="Join Evolver Team ("..recipeName..")",
intro2="START Score= ",
intro3="1 night PC work. Good night ",
signature="Signature in segment 1 note",
running1="Running ",
running2="",
skipping="Skipping ",
runningdessert="Now running dessert n ",
maindishes="MAIN DISHES",
nogain="... no additional gain in ",
gain1="... gained another ",
gain2=" points in ",
tweak1="Pass 1: Sidechain tweak",
tweak2="Pass 2: Sidechain tweak around",
tweak3="Last chance: bruteforce sidechain manipulate",
tweakgain1="Tweak gain: ",
tweakgain2="Tweak around gain: ",
tweakgain3="Manipulate gain: ",
tweakgain3nil=". Ignored if <0" ,
score="Current score ",
gainT=". >>>>JET gain= ",
gainin="<<<< in ",
gaining="(gaining: ",
timeleft="Time left: ",
hours=" hours.",
maygain="May gain additional ",
cleaning="Cleaning",
restorestructure="Restoring secundary structure",
savingbest="Saving best result",
undosave="Saving evoluable solution in Undo or Slot 9",
alreadydone=" has already been used.",
middlegame="Interruption of JET for middle game",
stopnow="Do not loze more time with JET now",
suggestEbola="I suggest you run Ebola now",
interrupt="Interruption of JET, abnormal to loose points",
signalerror="Thanks to signal this to the author"
}
}
end
return
end
--end merged Stanley and recipes functions
--Start generic Stanley functions section------------------------
function round(x)--cut all afer 3-rd place
return x-x%0.001
end
function down(x)
return x-x%1
end
function p(fmt, ...) --NEW 17/5/13
if #arg==0 then print(fmt or '')
elseif arg==nil then print(fmt or '')-- added BK 23/3/13
elseif fmt==nil then print('')-- added BK 23/3/13
else print(string.format(fmt, unpack(arg))) end
end
function Score()--return score, exploration too
return uo.energy and current.GetEnergyScore() or current.GetScore()
end
function FilterBonus(pose) -- new BK 30/4/2015 (independent from score functions)
local pose=pose or current
local CurrentFilterSetting = behavior.GetFiltersDisabled()
behavior.SetSlowFiltersDisabled(false)
local TvdLscore=pose.GetEnergyScore()
behavior.SetSlowFiltersDisabled(true)
local TvdLscore2=pose.GetEnergyScore()
behavior.SetFiltersDisabled(CurrentFilterSetting)
local TvdLbonus=TvdLscore-TvdLscore2
return TvdLbonus
end
startingscore= Score() -- for recipes
maxScore= Score() -- for recipes
evolbase=down(startingscore)--initialise decimales pour cherchevol() in jet
filterB=FilterBonus() -- new
if filterB<0 then filterB=0 end
C8000=8000+filterB
--[[GetScore and GetGroupScore return the rosetta energy. To convert this to your score use this:
10 * (800 - Rosetta Energy) = Foldit Score
The rosetta energy is a negative number and lower is better]]--
--Trouver le score de reference en fonction des resultats de l'equipe
function TopScore() -- by B.Kestemont 7/2/2013, 16/10/2013
local TopScorevalue=C8000
if groupscore==nil then
if absbestscore==nil then TopScore=Score()+1000 -- BK 16/10/2013
else
if scoreboard.GetRank()<6 then
TopScorevalue=(absbestscore-C8000)*(1+0.039*scoreboard.GetRank())+C8000
else
TopScorevalue=(absbestscore-C8000)*(1+(0.010*(scoreboard.GetRank()-5)+0.039*5))+C8000
end
end
else
if grouprank<6 then
TopScorevalue=(groupscore-C8000)*(1+pprankrel*grouprank)+C8000
else
TopScorevalue=(groupscore-C8000)*(1+0.0038*(grouprank-5)+pprankrel*5)+C8000
end
end
if TopScorevalue<C8000+15*segCnt then TopScorevalue=C8000+17.94*segCnt end -- le minimum observe en fin de compet
return TopScorevalue
end
--end generic Stanley functions section------------------------
--Start generic JET function section
function note1free()
if #saveNote1>0 and saveNote1:find("Ebola") then
historic="JET 3.0 apres Ebola"
elseif #saveNote1>0 then
note1libre=false
end
end
function AllLoop()
local ok=false
-- First save structure !
for i=1, segCnt do
local ss=structure.GetSecondaryStructure(i)
if ss~="L" then
save.SaveSecondaryStructure()
ok=true
break
end
end
if ok then
selection.SelectAll()
structure.SetSecondaryStructureSelected("L")
end
end
function lw(minppi) -- for Total LWS, Precise LWS and Lucky LWS (includes filter optimization)
local gain=true
while gain do
local ss=Score()
WiggleAT(2,"lw")
--WiggleSimple(20,"lws")
--structure.LocalWiggleSelected(20)-- BK 01/02/2014 for NC
local g=Score()-ss
if g<minppi then gain=false end
if g<0 then recentbest.Restore() end
end
selection.DeselectAll() -- new to JET
freeze.UnfreezeAll() -- new to JET
end
function lwWorm(minppi) --translated to Lua2 26/02/2014 (Here: no filter management !)
local minppi=minppi or 0
local s=Score()
--do_local_wiggle(1)
structure.LocalWiggleSelected(1)
if Score()-s>0+minppi then
--do_local_wiggle(bigLw)
structure.LocalWiggleSelected(bigLw)
end
recentbest.Restore()
end
function wiggleBudies(s, minppi, buddies) -- for PreciseLWS and Lucky LWS
--p("Wigglin segment "..s)
selection.DeselectAll()
freeze.UnfreezeAll()
local sgs=Score()
if s+1<=segCnt then selection.Select(s+1)end
if s-1>=1 then selection.Select(s-1)end
freeze.FreezeSelected(true, true) -- geler debut ou fin de proteine
selection.DeselectAll()
selection.Select(s)
lw(minppi) -- only s
if buddies > 0 then --select buddies
for b=1, buddies do
selection.DeselectAll()
if s+b+1<=segCnt then selection.Select(s+b+1)end
if s-1>=1 then selection.Select(s-1)end
freeze.FreezeSelected(true, true)
selection.DeselectAll()
if s+b>segCnt then selection.SelectRange(s,segCnt)
else selection.SelectRange(s,s+b)
end
lw(minppi) -- on s to s+variable to end
if s+1<=segCnt then selection.Select(s+1)end
if s-b-1>=1 then selection.Select(s-b-1)end
freeze.FreezeSelected(true, true)
selection.DeselectAll()
if s-b<1 then selection.SelectRange(1,s)
else selection.SelectRange(s-b,s)
end
lw(minppi) -- on s to s-variable to begin
if s+b+1<=segCnt then selection.Select(s+b+1)end
if s-b-1>=1 then selection.Select(s-b-1)end
freeze.FreezeSelected(true, true)
selection.DeselectAll()
if s+b>segCnt then selection.SelectRange(s,segCnt)
else selection.SelectRange(s,s+b)end
if s-b<1 then selection.SelectRange(1,s)
else selection.SelectRange(s-b,s)end
lw(minppi) -- on s-variable to s+variable
end
end
sge=Score()
--p("Segment gain: "..sge-sgs)
end
--end generic JET function section
--------------------------------------------------------------
-- Module Stanley 1.2, by B. Kestemont 19/06/2013, 25/8/2013
-- To find puzzle properties and targets
-- properties based on Tvdl 14-12-2012
-- Autonomous enhanced version (BK 25/1/2013)
-- Targets by B. Kestemont
----------------------------------------------------------
--generic variables section merged to top -------------------------
--generic functions section merged to top------------------------
------------------------------------------------------
-- Segment set and list module
-- Notice that most functions assume that the sets are well formed
-- (=ordered and no overlaps)
-- 02-05-2012 TvdL Free to use for non commercial purposes
function SegmentListToSet(list) -- retirer doublons
local result={}
local f=0
local l=-1
table.sort(list)
for i=1,#list do
if list[i] ~= l+1 and list[i] ~= l then
-- note: duplicates are removed
if l>0 then result[#result+1]={f,l} end
f=list[i]
end
l=list[i]
end
if l>0 then result[#result+1]={f,l} end
--print("list to set")
--SegmentPrintSet(result) -- desactivated this print BK 17/6/13
return result
end
function SegmentSetToList(set) -- faire une liste a partir d'une zone
local result={}
for i=1,#set do
--print(set[i][1],set[i][2])
for k=set[i][1],set[i][2] do
result[#result+1]=k
end
end
return result
end
function SegmentCleanSet(set)
-- Makes it well formed
return SegmentListToSet(SegmentSetToList(set))
end
function SegmentInvertSet(set,maxseg)
-- Gives back all segments not in the set
-- maxseg is added for ligand
local result={}
if maxseg==nil then maxseg=structure.GetCount() end
if #set==0 then return {{1,maxseg}} end
if set[1][1] ~= 1 then result[1]={1,set[1][1]-1} end
for i=2,#set do
result[#result+1]={set[i-1][2]+1,set[i][1]-1}
end
if set[#set][2] ~= maxseg then result[#result+1]={set[#set][2]+1,maxseg} end
return result
end
function SegmentInList(s,list) -- verifier si segment est dans la liste
table.sort(list)
for i=1,#list do
if list[i]==s then return true
elseif list[i]>s then return false
end
end
return false
end
function SegmentInSet(set,s) --verifie si segment est dans la zone
for i=1,#set do
if s>=set[i][1] and s<=set[i][2] then return true
elseif s<set[i][1] then return false
end
end
return false
end
function SegmentJoinList(list1,list2) -- fusionner 2 listes de segments
local result=list1
if result == nil then return list2 end
for i=1,#list2 do result[#result+1]=list2[i] end
table.sort(result)
return result
end
function SegmentJoinSet(set1,set2) --fusionner (ajouter) 2 zones
return SegmentListToSet(SegmentJoinList(SegmentSetToList(set1),SegmentSetToList(set2)))
end
function SegmentCommList(list1,list2) -- chercher intersection de 2 listes
local result={}
table.sort(list1)
table.sort(list2)
if #list2==0 then return result end
local j=1
for i=1,#list1 do
while list2[j]<list1[i] do
j=j+1
if j>#list2 then return result end
end
if list1[i]==list2[j] then result[#result+1]=list1[i] end
end
return result
end
function SegmentCommSet(set1,set2) -- intersection de 2 zones
return SegmentListToSet(SegmentCommList(SegmentSetToList(set1),SegmentSetToList(set2)))
end
function SegmentSetMinus(set1,set2)
return SegmentCommSet(set1,SegmentInvertSet(set2))
end
function SegmentPrintSet(set)
print(SegmentSetToString(set))
end
function SegmentSetToString(set) -- pour pouvoir imprimer
local line = ""
for i=1,#set do
if i~=1 then line=line..", " end
line=line..set[i][1].."-"..set[i][2]
end
return line
end
function SegmentSetInSet(set,sub)
if sub==nil then return true end
-- Checks if sub is a proper subset of set
for i=1,#sub do
if not SegmentRangeInSet(set,sub[i]) then return false end
end
return true
end
function SegmentRangeInSet(set,range)--verifier si zone est dans suite
if range==nil or #range==0 then return true end
local b=range[1]
local e=range[2]
for i=1,#set do
if b>=set[i][1] and b<=set[i][2] then
return (e<=set[i][2])
elseif e<=set[i][1] then return false end
end
return false
end
function SegmentSetToBool(set) -- vrai ou faux pour chaque segment utilisable ou non
local result={}
for i=1,structure.GetCount() do
result[i]=SegmentInSet(set,i)
end
return result
end
--- End of Segment Set module
-- Module Find Segment Types
function FindMutablesList()
local result={}
for i=1,segCnt2 do if structure.IsMutable(i) then result[#result+1]=i end end
return result
end
function FindMutables()
return SegmentListToSet(FindMutablesList())
end
function FindFrozenList()
local result={}
for i=1,segCnt2 do if freeze.IsFrozen(i) then result[#result+1]=i end end
return result
end
function FindFrozen()
return SegmentListToSet(FindFrozenList())
end
function FindLockedList()
local result={}
for i=1,segCnt2 do if structure.IsLocked(i) then result[#result+1]=i end end
return result
end
function FindLocked()
return SegmentListToSet(FindLockedList())
end
function FindSelectedList()
local result={}
for i=1,segCnt do if selection.IsSelected(i) then result[#result+1]=i end end
return result
end
function FindSelected()
return SegmentListToSet(FindSelectedList())
end
function FindAAtypeList(aa)
local result={}
for i=1,segCnt2 do
if structure.GetSecondaryStructure(i)== aa then result[#result+1]=i end
end
return result
end
function FindAAtype(aa)
return SegmentListToSet(FindAAtypeList(aa))
end
function FindAminotype(at) --NOTE: only this one gives a list not a set
local result={}
for i=1,segCnt2 do
if structure.GetAminoAcid(i) == at then result[#result+1]=i end
end
return result
end
-- end Module Find Segment Types
-- Module to compute subscores
-- TvdL, 14-12-2012
function GetSubscore(types,seg1,seg2,pose)
local result=0
if type(types) == "table" then
for i=1,#types do result=result+GetSubscore(types[i],seg1,seg2,pose) end
else
if types==nil and seg1==nil and seg2==nil then return Score(pose) end
if seg1==nil then seg1=1 end
if seg2==nil then seg2=segCnt end --includes ligands!
if seg1>seg2 then seg1,seg2=seg2,seg1 end
if pose==nil then pose=current end
if types==nil then
for i=seg1,seg2 do result=result+pose.GetSegmentEnergyScore(i) end
else
for i=seg1,seg2 do result=result+pose.GetSegmentEnergySubscore(i,types) end
end --rappel: current.GetSegmentEnergySubscore(integer segmentIndex, string scorePart)
end
return result
end
-- End module to compute subscores
-------------------------------------------------------
-- Start of module for bridgechecking-------------------
function setCyslist()
Cyslist=FindAminotype("c")
nrofbridges=CountBridges()
end
function IsBridge(i)
return ''..current.GetSegmentEnergySubscore(i,'disulfides') ~= '-0'
end
function CountBridges()
local count = 0
for i = 1,#Cyslist do
if IsBridge(Cyslist[i]) then count = count + 1 end
end
return count
end
function BridgesBroken()
return savebridges == true and CountBridges() < nrofbridges
end
function Bridgesave()
if savebridges then PushPosition() end
end
function Bridgerestore()
if savebridges then
if BridgesBroken() then PopPosition() else ClrTopPosition() end
end
end
-- End module bridgechecking
---Start Module to find segment properties------------
function FindAminotype(at) --NOTE: only this one gives a list not a set
local result={}
for i=1,segCnt2 do
if structure.GetAminoAcid(i) == at then result[#result+1]=i end
end
return result
end
--Detect ligands (from Jean-Bob)
--[[
function DetectLigand()
local lastSeg=segEnd
while structure.GetSecondaryStructure(lastSeg)=="M" do
flagligand=true -- servira plus tard pour travailler sur ligands
lastSeg=lastSeg-1
end
indexligand={lastSeg,segEnd} --donne toujours 2??
if flagligand then p(i18.stanley.ligands..#indexligand) else
--p("-pas de ligand; ")
p(i18.stanley.noligand)
end
segEnd=lastSeg -- pour eviter bugs out of bound NEW 18/5/2013
end
]]--
function SetPuzzleProperties()
--p("Exploration du puzzle")
p(i18.intro.exploration)
--check if the puzzle has ligands and computes LastSeg
--DetectLigand()
--DetectLock()
-- Find out if the puzzle has mutables
local MutList=FindMutablesList()
HASMUTABLE= (#MutList>0)
if HASMUTABLE then
--p("-il y a "..#MutList.." mutables;")
p(i18.stanley.thereare..#MutList..i18.stanley.mutables)
else
--p("-pas de mutable;")
--p(i18.stanley.nomutable)
end
FREEDESIGN= (segCnt2/2 < #MutList)
if FREEDESIGN then
--p("-probablement free design;")
p(i18.stanley.freedesign)
else
--p("-pas free design")
--p(i18.stanley.nofreedesign)
end
-- Find out if the puzzle has possible bridges
setCyslist()
--p("- "..#Cyslist.." cystides;")
p(i18.stanley.thereare..#Cyslist..i18.stanley.cysteins)
if #Cyslist > 1 then
if nrofbridges > 0 then
--p(" -il y a "..nrofbridges.." ponts;")
p(" -there are "..nrofbridges.." bridges;")
p(i18.stanley.thereare..nrofbridges..i18.stanley.bridges)
savebridges=true
else
--p(" -pas de pont;")
p(i18.stanley.nobridge)
end
else
--p(" -pas de possibilite de pont;")
p(i18.stanley.nobridgepossible)
end
-- Find out is the puzzle has other scores and their weight if any (e.g. ED)
local othertot=GetSubscore("density")
local segtot=GetSubscore(nil,1,segCnt) -- attention sera nil si lock
HASOTHER= math.abs(othertot) > 0.0001
if normal and HASOTHER then
OTHERWEIGHT=(Score()-segtot-8000)/othertot -- c'est pas l'inverse?
--p("-autres scores; poids supplementaire de "..round(OTHERWEIGHT))
p(i18.stanley.otherscore..round(OTHERWEIGHT))
else
--p("-pas d'autre score;")
p(i18.stanley.nootherscore)
end
-- Check if the puzzle is a probable symmetry one
if normal and not HASOTHER then
PROBABLESYM=math.abs(Score()-segtot-C8000) > 2 -- c'est pas plutot diviser?
end
if not normal then p(i18.stanley.explorationpuzzle) end
end
--recherche du nombre probable de brins en fonction du score(appele par puzzleprop)
function SymetryFinder() -- by Bruno Kestemont 7/2/2013, 25/8/2013
local segMeanScore=(TopScore()/multiplier-C8000)/segCnt -- top score pour eviter les debuts de puzzle
-- taking (our) multiplier as a proxy or 1 if normal
if PROBABLESYM and normal then -- delete normal if sym exploration puzzles appears!
if segMeanScore<33.39 then sym=1
PROBABLESYM=false
elseif segMeanScore<85 then sym=2
elseif segMeanScore<132 then sym=3
elseif segMeanScore<197 then sym=4
else sym=5
end
else sym=1
end
return
end
--Extrait des infos
function puzzleprop() -- by Bruno Kestemont 25/8/2013
local descrTxt=puzzle.GetDescription()
--p(descrTxt)
local puzzletitle=puzzle.GetName()
--p(puzzletitle)
if #puzzletitle>0 then
for i=1,#badpuzzle do
if puzzletitle:find(i) then -- check if not bizarre puzzle
NOTIMPLEMENTED=true
end
end
if (puzzletitle:find("Sym") or puzzletitle:find("Symmetry") or puzzletitle:find("Symmetric")
or puzzletitle:find("Dimer") or puzzletitle:find("Trimer") or puzzletitle:find("Tetramer")
or puzzletitle:find("Pentamer")) then
PROBABLESYM=true
if puzzletitle:find("Dimer") and not puzzletitle:find("Dimer of Dimers") then sym=2
elseif puzzletitle:find("Trimer") or puzzletitle:find("Tetramer") then sym=3
elseif puzzletitle:find("Dimer of Dimers") or puzzletitle:find("Tetramer") then sym=4
elseif puzzletitle:find("Pentamer") then sym=5
else SymetryFinder()
end
end
end
if #descrTxt>0 and (descrTxt:find("Sym") or descrTxt:find("Symmetry") or descrTxt:find("Symmetric")
or descrTxt:find("sym") or descrTxt:find("symmetry") or descrTxt:find("symmetric")) then
PROBABLESYM=true
if (descrTxt:find("Dimer") or descrTxt:find("dimer"))
and not (descrTxt:find("Dimer of Dimers") or descrTxt:find("dimer of dimers")) then sym=2
elseif descrTxt:find("Trimer") or descrTxt:find("trimer") then sym=3
elseif (descrTxt:find("Dimer of Dimers") or descrTxt:find("Tetramer"))
and not (descrTxt:find("dimer of dimers") or descrTxt:find("tetramer"))then sym=4
elseif descrTxt:find("Pentamer") or descrTxt:find("pentamer") then sym=5
else SymetryFinder() -- may be duplicate but it's safe
end
end
--print resulting sym info
if PROBABLESYM then
p(i18.stanley.sym)
if sym==2 then
p(i18.stanley.dimer)
elseif sym==3 then
p(i18.stanley.trimer)
elseif sym==4 then
p(i18.stanley.tetramer)
elseif sym==5 then
p(i18.stanley.pentamer)
elseif sym>5 then
p("Terrible polymer")
end
else p(i18.stanley.nosym)
end
if #descrTxt>0 and (descrTxt:find("filter") or descrTxt:find("filters")) then
PROBABLEFILTER=true
end
if #puzzletitle>0 and puzzletitle:find("Sepsis") then -- new BK 17/6/2013
SEPSIS=true
--p("-Sepsis")
p(i18.stanley.sepsis)
end
if #puzzletitle>0 and puzzletitle:find("Electron Density") then -- for Electron Density
--p("-Electron Density")
ELECTRON=true
p(i18.stanley.electron)
end
if #puzzletitle>0 and puzzletitle:find("Contacts") then -- for Electron Density
--p("-Contacts")
CONTACT=true
p(i18.stanley.contacts)
end
if #descrTxt>0 and (descrTxt:find("Contacts") or descrTxt:find("Contact")) then
--p("-Contacts")
CONTACT=true
p(i18.stanley.contacts)
end
return
end
function fullsubscorelist() -- new BK 23/9/2013
subscorelist=puzzle.GetPuzzleSubscoreNames()
for i=1,#subscorelist do
print (subscorelist[i])
end
end
--fin d'extrait des infos
---End of Module to find segment properties------------
--Start module target settings
function TargetFinder(sym) -- by Bruno Kestemont 16/2/2013 -- Stanley V1.3 version, 30/4/2015
--sym= 1 --Options: 1 normal; 2 dimer; 3 trimer; 4 tetramer (dimer of dimer) etc.
--p("Recherche d'un objectif")
p(i18.stanley.lookingtarget)
local k=1 -- Option: k= 4 if symetric puzzle Dimer, k=6 for trimer, k=8 for tetramer
if sym > 1 then k=2*sym -- reassigning k in function of symetry
TargetMin= multiplier*(13.18*k*segCnt +C8000) -- based on 8000 + min score per segment
TargetLow= multiplier*(17.81*k*segCnt +C8000)
TargetMean= multiplier*(21.14*k*segCnt +C8000)
TargetHigh= multiplier*(24.46*k*segCnt +C8000)
TargetMax= multiplier*(24.65*k*segCnt +C8000)
else
TargetMin= multiplier*(14.03*k*segCnt +C8000)
TargetLow= multiplier*(19.05*k*segCnt +C8000)
TargetMean= multiplier*(22.87*k*segCnt +C8000)
TargetHigh= multiplier*(26.69*k*segCnt +C8000)
TargetMax= multiplier*(33.39*k*segCnt +C8000)
end
--p("Jeu de cibles: "..down(TargetMin)..", ".. down(TargetLow)..", ".. down(TargetMean)..", ".. down(TargetHigh)..", ".. down(TargetMax))
p(i18.stanley.setoftargets..down(TargetMin)..", ".. down(TargetLow)..", ".. down(TargetMean)..", ".. down(TargetHigh)..", ".. down(TargetMax))
return
end
function Dist2target(Target)
--p("Objectif actuel: "..down(Target))
p(i18.stanley.currenttarget..down(Target))
D2target=Target-Score()
relD2target=D2target/Target -- ratio, relative distance to target
--p("Distance a l'objectif = "..down(D2target).." ("..down(relD2target*100).." %)")
p(i18.stanley.distance2target..down(D2target).." ("..down(relD2target*100).." %)")
return
end
function TargetReset()
local topscore=TopScore()
--p("Top score estim: "..down(topscore))
p(i18.stanley.topscore..down(topscore))
if topscore>TargetMax then Dist2target(topscore+10) p("Il y a qque chose qui cloche")
elseif topscore>TargetHigh then Dist2target(TargetMax)
elseif topscore>TargetMean then Dist2target(TargetHigh)
elseif topscore>TargetLow then Dist2target(TargetMean)
elseif topscore>TargetMin then Dist2target(TargetLow)
else Dist2target(TargetMin)
end -- revoit les ambitions en fonction de la situation de l'equipe
end
-- section to compute segmentscore(part)s from tvdl
function getPartscore(ss,se,attr)
local s=0
if attr=='total' then
s=Score()
elseif attr==nil then --is only called from findWorst
for i=ss,se do
s=s+SegmentScores[i]
end
elseif attr=='loctotal' then --total segment scores
s=GetSubscore(nil,ss,se)
else
s=GetSubscore(attr,ss,se)
end
return s
end
-- Do not try to work on frozen or locked parts or ligands
WORKON=SegmentSetMinus(WORKON,FindFrozen())
WORKON=SegmentSetMinus(WORKON,FindLocked())
WORKON=SegmentSetMinus(WORKON,FindAAtype("M"))
WORKONbool={}
function InitWORKONbool()
WORKONbool=SegmentSetToBool(WORKON)
end
function MustWorkon(i,j) -- not used here in stanley
for k=i,j do if not WORKONbool[k] then return false end end
return true
end
SegmentScores={} --Optimalisation for fast worst search
lastSegScores=0
function GetSegmentScores()
if lastSegScores~=Score() then
lastSegScores=Score()
for i=1,segCnt2 do
if WORKONbool[i] then
if #scrPart==0 then
-- if nothing specified by user default is
-- segmentenergy - reference + extra other score
SegmentScores[i]=current.GetSegmentEnergyScore(i)
if not structure.IsMutable(i) then --ignore reference part but NOT for mutables)
SegmentScores[i]=SegmentScores[i]-current.GetSegmentEnergySubscore(i,'reference')
end
if math.abs(OTHERWEIGHT) > 0 then --the other component has extra weight
SegmentScores[i]=SegmentScores[i]+OTHERWEIGHT*current.GetSegmentEnergySubscore(i,'density')
end
else
SegmentScores[i]=GetSubscore(scrPart,i,i)
end
end
end
end
end
-- end section segmentscore(part)s
-- End of module Target settings
function Stanley()
p("------------------")
p(i18.intro.title)
InitWORKONbool() -- new 18/5/13
SetPuzzleProperties()
puzzleprop()
--SymetryFinder() --deja appele par puzzleprop
TargetFinder(sym)
TargetReset()
p(i18.stanley.endstanley)
p("------------------")
end
--END STANLEY MODULE
------------------------------------------------------------------
------------------------------------------------------------------
----------------------------------------------------------------------------------------
-- COOKBOOK -- Adapted recipes to V2 and JET
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--1. Precise LWS by rav3n_pl
--searches and wiggles worst segments
--some functions shared with Lucky LWS or WalkeR are not repeated
function PreciseLWS(howmany, buddies, minppi) -- wiggle les 5 pires segments
--local howmany = 5 --how many best
--local buddies = 4 -- how many segments aside should be wiggled too
--local minppi = 0.1 --minimum gain per wiggle iterations
local function getPartScore(segments)--using partial scoring -- une ligne de sous-scores
local attr = {'packing','backbone','density','bonding','sidechain','clashing'}--,'hiding','reference','disulfides'}
local score = 0
for i=1,#attr do
score = score + current.GetSegmentEnergySubscore(segments, attr[i])
end
return score
end
local function getworst() --fill score table -- un score partiel par segment
worst={}
for i=1, segCnt do
sc=getPartScore(i) -- somme des scores partiels du segment
worst[i]=sc
end
return worst -- une colonne de segments et leur score
end
local function wiggleworst(howmany, minppi, buddies)
behavior.SetClashImportance(1)
AllLoop()
freeze.UnfreezeAll()
selection.DeselectAll()
recentbest.Save()
sscore=Score()
worst=getworst()
for i=1, howmany do -- Wiggle des howmany pires segments
--p(howmany+1-i.." segments left to do.")
min=worst[1] -- score du segment 1
seg=1
for f=2,segCnt do
if min>worst[f] then
min=worst[f] -- le segment le pire est retenu
seg=f -- n du segment retenu (le pire)
end
end
wiggleBudies(seg, minppi, buddies) -- wiggle le pire segment et voisins
worst[seg]=9999--never again same one -- il est reclasse a la fin
end
local g=Score()-sscore
cherchevol() -- cherche la solution evoluable
--p("Precise LWS gain: ".. g.." pts")
save.LoadSecondaryStructure()
end
wiggleworst(howmany, minppi, buddies)
end
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--2. WalkeR v1.0
--Original version: WalkeR(segStart, segEnd, minLen, maxLen, minPpi)
--JET adapted version: WalkeR(minLen, maxLen, minPpi)
--[[
WalkeR v1.0
a randomatic LWS script
set from-to -- Disabled for JET
set min-max len of lws
set minimum points per iter
options at end
]]--
function seed()
local s=math.abs(Score())
s=s%0.001
s=1/s
while s<10000000 do s=s*10 end
s=s-s%1
math.randomseed(s)
end
function ShuffeleTable()
-- p("Mixing LWS table...")
local tl=#lwsTable
for i=1,tl do
local n=math.random(tl)
lwsTable[i],lwsTable[n]=lwsTable[n],lwsTable[i]
end
-- p("Mixing done.")
end
--lwsTable={}
function CreateTable(minLen, maxLen)
lwsTable={}
if segEnd==nil then segEnd=segCnt end
for sn=segStart, segEnd do
for l=minLen, maxLen do
if (sn+l-1)<=segEnd then
lwsTable[#lwsTable+1]={sn,l}
end
end
end
end
-- Main WalkeR call ----- Adapted for JET
function WalkeR(minLen, maxLen, minppi)
seed()
CreateTable(minLen, maxLen)
ShuffeleTable()
local sscore=Score()
--p("Starting WalkeR, Score="..round(sscore))
local tl=#lwsTable
for i=1, tl do
local sc=Score()
local s=lwsTable[i][1]
local l=lwsTable[i][2]
selection.DeselectAll()
selection.SelectRange(s,s+l-1)
lw(minppi)
--p("Iter "..i.."/"..tl.." ("..s..":"..l..") g: "..round(Score()-sc).." score: "..round(Score()))
end
local g=Score()-sscore
cherchevol() -- cherche la solution evoluable
--p("Total WalkeR gain: "..round(g))
end
---------------------------------------------
--Options for WalkeR
----------------------------------------------
--segStart=1 --start from (Default option for JET)
--segEnd=nil --end seg: nil=end of protein (Default option for JET)
--minLen=1 --minimum lws len
--maxLen=7 --segCntmum lws len
--minPpi=0.01 --minimum points gain per 2 wiggles, set 0.0001 in endgame :)
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--3. LuckyLWS
--[[
LuckyLWS
search and LWS best scoring segments
options at end
]]--
function LuckyLWS(howmany, buddies, minppi) -- JET version
local function getpoints()
t={}
-- p("LuckyLWS Searching best scoring segments.")
local ss=Score()
selection.DeselectAll()
freeze.UnfreezeAll()
for i=segStart, segEnd do --fill score table
save.Quicksave(4)
selection.DeselectAll()
selection.Select(i)
local scs=Score()
WiggleAT(2,"lw")
--WiggleSimple(20,"lws")
--structure.LocalWiggleSelected(25)
local g=Score()-scs
t[#t+1]={i,g}
if g<keepTest then save.Quickload(4) end
end
-- p("LuckyLWS gain: "..round(Score()-ss))
return t
end
local function Sort(tab,items) -- bubble sorting - lowest on top, only needed items
if items>#tab then items=#tab end
for x=1,items do
for y=x+1,#tab do
if tab[x][2]<tab[y][2] then
tab[x],tab[y]=tab[y],tab[x]
end
end
end
return tab
end
if segEnd==nil then segEnd=segCnt end
behavior.SetClashImportance(1)
freeze.UnfreezeAll()
AllLoop()
recentbest.Save()
sscore=Score()
besttable=getpoints()
besttable=Sort(besttable,howmany)
if howmany>#besttable then howmany=#besttable end
for i=1, howmany do
if besttable[i][2]>=LWSonly then
local seg=besttable[i][1]
recentbest.Save()
wiggleBudies(seg, minppi, buddies)
end
end
local g=Score()-sscore
cherchevol() -- cherche la solution evoluable
--p("LuckyLWS gain: ".. round(g))
save.LoadSecondaryStructure()
end
keepTest = 0.001 --keep test points only when gain is more than --JET default, was 0.005
LWSonly = 0.001 --do lws only if test more than--JET default, was 0.005
--howmany = 5 --how many best
--buddies = 4 -- how many segments aside should be wiggled too
--minppi = 0.1 --minimum gain per wiggle iterations
--segStart=1 --JET general default
--segEnd=nil --JET general default
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--4. Total lws
--totalLws(minlen,maxlen, minpp)
--minlen - minimum lenggh of sgmnts - if you have done lws by 1 and 2 you may want set it to 3
--maxlen - segCntmum lenght of sgments - more than 7 looks useless
--minppi - minimum gain per local wiggle iter
function totalLws(minlen,maxlen,minppi)
local function Freeze(start, len)
freeze.UnfreezeAll()
selection.DeselectAll()
for f=start, segCnt, len+1 do
if f<= segCnt then selection.Select(f) end
end
freeze.FreezeSelected(true, false)
end
local function wiggle(start,len,minppi)
if start>1 then
selection.DeselectAll()
selection.SelectRange(1,start-1)
lw(minppi)
end
for i=start, segCnt, len+1 do
selection.DeselectAll()
local ss = i+1
local es=i+len
if ss >= segCnt then ss=segCnt end
if es >= segCnt then es=segCnt end
selection.SelectRange(ss,es)
lw(minppi)
end
end
freeze.UnfreezeAll()
selection.DeselectAll()
behavior.SetClashImportance(1)
save.SaveSecondaryStructure()
AllLoop()
local ssc=Score()
--p("Starting Total LWS: "..ssc)
--p("Lenght: "..minlen.." to "..maxlen.." ;minimum ppi: "..minppi)
for l=minlen, maxlen do
for s=1, l+1 do
--p("Len: "..l.."..start point: "..s)
Freeze(s,l)
local sp=Score()
recentbest.Save()
wiggle(s,l,minppi)
local g=Score()-sp
GainAnother(g) --prints small gains
cherchevol() -- cherche la solution evoluable
end
end
--p("Total LWS gain: "..Score()-ssc)
save.LoadSecondaryStructure()
end
--minlen - minimum lenggh of sgmnts - if you have done lws by 1 and 2 you may want set it to 3
--maxlen - segCntmum lenght of sgments - more than 7 looks useless
--minppi - minimum gain per local wiggle iter
-------------------------------------------------------------
-------------------------------------------------------------
--5. Acid Tweaker v1.78 by Steven Pletsch
--modded by rav3n_pl;]
-- modded by BitSpawn, March 2012
-- and B.Kestemont, March 2013
-- v1.78: bug fixed with best score after rebuild
-- v2.00: LUAV2, thanks Timo
-- v2.1: bug fixed on rotamers, set default as in v1.78 by Bruno Kestemont
-- v2.2 Bug fixed on structure.WiggleAll (replaced by structure.WiggleSelected) by BK
-- here adapted version for JET!
-- 26/04/2015 added maximo
--START Archive in Notes, -- New 4/11/2014
function SelectNote(recipename)
store={}
store.label=recipename or "" -- edit here the recipe name
store.note_number=structure.GetCount()
for seg=structure.GetCount(),1,-1 do
if structure.GetNote(seg)~="" then break end
store.note_number=seg
end
print(string.format("Recording results in Note for segment %i",store.note_number))
store.starting_score=current.GetScore()
--structure.SetNote(store.note_number,string.format("(%s) %.3f + FSP",user.GetPlayerName(),store.starting_score))
end
SelectNote(recipeName) -- init with the recipe name here !!!
function WhriteNote(loop_nb) -- all inits are in SelectNote function
local loop_count= loop_nb or 1
structure.SetNote(store.note_number,string.format("(%s) %.3f + %s(%i) %.3f",user.GetPlayerName(),store.starting_score,store.label,loop_count,current.GetScore()))
end
--END Archive in Notes
--START quick save algorithm
function QuickShake()
--[[------------------------------------------------------------------------------------------------
-- Algorithm for faster shake
REFERENCES
1. N/A
Copyright (C) 2014 Seagat2011 <http://fold.it/port/user/1992490>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
$Id$
------------------------------------------------------------------------------------------------]]--
--[[
v1
- Inception
1.2
- Loops until nogain
]]--
local idx = 1
local idx2 = structure.GetCount ()
local hash = {}
local cs = current.GetScore ()
--print ( 'Quick Shake Algorithm v1.2 SG2011 - Current Score: '..cs )
local function New ( obj )
return obj -- pass-new-obj-by-value
end
local _gses = New ( current.GetSegmentEnergySubscore )
local function SmartShake ( iters )
local gain = true
while (gain) do
gain = false
for i=idx,idx2 do
local ci = _gses ( i,'clashing' )
if ci < _gses ( i,'hiding' ) and
ci < _gses ( i,'packing' ) and
ci < _gses ( i,'ideality' ) and
ci < _gses ( i,'sidechain') and
ci < _gses ( i,'bonding' ) and
ci < _gses ( i,'other' ) and
ci < _gses ( i,'reference') then
selection.Select ( i )
end -- test ci --
end -- loop --
if selection.GetCount () then
local css = current.GetScore ()
structure.ShakeSidechainsSelected ( iters )
selection.DeselectAll ()
if current.GetScore () > css then
gain = true
end -- test --
end -- test --
end -- loopf --
end
structure.SmartShake = SmartShake
structure.SmartShake ( 1 )
--print ( 'Done.' )
end
--END quick save algorithm
function ds(val)
if mutate==true then
if PROBABLEFILTER then behavior.SetSlowFiltersDisabled(OriginalFilterSetting) end -- new BK 8/4/2013, always back to user settings
structure.MutateSidechainsSelected(val+1)
else
--structure.ShakeSidechainsSelected(val)
QuickShake(1)
end
end
function CI(val)
global_ci=val
behavior.SetClashImportance(global_ci)
end
function WiggleSimple(val,how) -- with filter management
local val= val or 1 -- new 01/019/2014
local how= how or "wa"
if PROBABLEFILTER then behavior.SetSlowFiltersDisabled(true) end-- new BK 8/4/2013, always disable filter here
if how == "s" then ds(1)
elseif how == "wb" then structure.WiggleSelected(val, true, false) -- backbones
elseif how == "ws" then structure.WiggleSelected(val, false, true) -- sidechains
elseif how == "wa" then structure.WiggleSelected(val, true, true) -- all
elseif how== "lw" then structure.LocalWiggleSelected(val) -- new
end
if PROBABLEFILTER then behavior.SetSlowFiltersDisabled(OriginalFilterSetting) end -- new BK 8/4/2013, always back to user settings
end
function WiggleAT(ss, how, iters, minppi)
local valiter=2
local val=1
if fast==true then valiter=1 end
if how==nil then how="wa" end
if iters==nil then iters=6 end-- changed from 3 for NC 01/02/2014
if ((minppi==nil) or (minppi<0.01)) then
minppi=0.01
end
if global_ci==1.00 then val=valiter end
if iters>0 then
iters=iters-1
local sp=Score()
WiggleSimple(val,how)-- new function BK 8/4/2013 (includes filter management)
local ep = Score()
local ig=ep-sp
if how~="s" then
if ig > minppi then WiggleAT(ss, how, iters, minppi) end
end
end
end
function SelectSphere(sg, radius,nodeselect)
if nodeselect~=true then selection.DeselectAll() end
for i=1, segCnt do
if structure.GetDistance(sg,i)<radius then selection.Select(i) end
if sphere_worst==true then
if current.GetSegmentEnergyScore(i)<sphere_worst_value then selection.Select(i) end
end
end
end
function Fix(sg)
if fix_band==false then
return
end
-- selection.DeselectAll()
local nb=1
for i=1, segCnt do
dist=structure.GetDistance(sg,i)
if (dist<12 and dist>6) then
local cband=band.GetCount()
band.AddBetweenSegments(sg,i)
if cband<band.GetCount() then
band.SetGoalLength(nb, dist)
nb=nb+1
end
-- else if dist>12 then
-- selection.Select(i)
-- end
end
end
-- freeze.FreezeSelected(true,true)
-- selection.DeselectAll()
-- SelectSphere(sg,esfera)
WiggleSimple(5,"wa") -- 06/02/2014 all protein
band.DeleteAll()
-- freeze.UnfreezeAll()
end
function SaveBest() --adapted to JET
local sp=Score()
local g=sp-bestScore
if g>0 then
bestScore=sp
GainAnother(g)
cherchevol(g) -- cherche la solution evoluable
end
end
function usableAA(sn)
local usable=false
local sscore=current.GetSegmentEnergyScore(sn)
if sscore>minimo then
return usable -- donc false ici (true si score > minimo = 600)
end
if sscore<maximo then -- NEW BK 8/10/2013
return usable -- donc false ici (true si score < maximo)
end
if rebuild==true then
selection.DeselectAll()
selection.Select(sn)
structure.RebuildSelected(2)
usable=true
return usable
end
if #useThat>0 then
for i=1,#useThat do
if sn==useThat[i] then
usable=true
break
end
end
else
if #useOnly > 0 then
for i=1,#useOnly do
local ss=useOnly[i][1]
local se=useOnly[i][2]
for s=ss,se do
if s==sn then
usable=true
break
end
end
end
else
usable=true
if #doNotUse>0 then
for i=1,#doNotUse do
local ss=doNotUse[i][1]
local se=doNotUse[i][2]
for s=ss,se do
if s==sn then
usable=false
break
end
end
if usable==false then break end
end
end
if #skipAA>0 then
local aa=structure.GetAminoAcid(sn)
for i=1,#skipAA do
if aa==skipAA[i] then
usable=false
break
end
end
end
end
end
local se=segCnt
if segEnd~=nil then se=segEnd end
if sn<segStart or sn>se then usable=false end
return usable
end
function wiggle_out(ss)
CI(.6)
WiggleSimple(1,"wa") -- new function BK 8/4/2013
CI(1.)
WiggleAT(ss)
WiggleAT(ss,"s",1)
--selection.SelectAll()
CI(.6)
WiggleAT(ss)
CI(1.)
WiggleAT(ss)
recentbest.Restore()
SaveBest()
end
function getNear(seg)
if(Score() < g_total_score-1000) then
selection.Deselect(seg)
CI(.75)
WiggleSimple(1,"s") -- new function BK 8/4/2013
WiggleSimple(1,"ws") -- new function BK 8/4/2013
selection.Select(seg)
CI(1)
end
if(Score() < g_total_score-1000) then
if fix_band==true then
Fix(seg)
else
recentbest.Restore()
SaveBest()
return false
end
end
return true
end
function sidechain_tweak()
--p("Pass 1 of 3: Sidechain tweak")
p(i18.jet.tweak1)
for i=segStart, segEnd do
if usableAA(i) then
selection.DeselectAll()
selection.Select(i)
local ss=Score()
g_total_score = Score()
CI(0)
WiggleSimple(1,"s") -- new function BK 8/4/2013
CI(1.)
--p("Try sgmnt ", i)
SelectSphere(i, esfera)
if (getNear(i)==true) then
wiggle_out(ss)
end
end
end
end
function sidechain_tweak_around()
--p("Pass 2 of 3: Sidechain tweak around")
p(i18.jet.tweak2)
for i=segStart, segEnd do
if usableAA(i) then
selection.DeselectAll()
for n=1, segCnt do
g_score[n] = current.GetSegmentEnergyScore(n)
end
selection.Select(i)
local ss=Score()
g_total_score = Score()
CI(0)
WiggleSimple(1,"s") -- new function BK 8/4/2013
CI(1. )
-- p("Try sgmnt ".. i)
SelectSphere(i,esfera)
if(Score() > g_total_score - 30) then
wiggle_out(ss)
else
selection.DeselectAll()
for n=1, segCnt do
if(current.GetSegmentEnergyScore(n) < g_score[n] - 1) then
selection.Select(n)
end
end
selection.Deselect(i)
CI(0.1)
WiggleSimple(1,"s") -- new function BK 8/4/2013
SelectSphere(i,esfera,true)
CI(1.0)
if (getNear(i)==true) then
wiggle_out(ss)
end
end
end
end
end
-- essai d'amelioration JET 3:
function sidechain_manipulate() -- y a un bug, donne des scores negatifs !
--p("Dernire chance: manipulateur brutal des chaines latrales")
p(i18.jet.tweak3)
for i=segStart, segEnd do
if usableAA(i) then
selection.DeselectAll()
rotamers = rotamer.GetCount(i)
save.Quicksave(4)
if(rotamers > 1) then
local ss=Score()
--p("Sgmnt: ", i," rotamers: ",rotamers, " Score= ", ss)
for r=1, rotamers do
--p("Sgmnt: ", i," position: ",r, " Score= ", ss)
save.Quickload(4)
g_total_score = Score()
rotamer.SetRotamer(i,r)
CI(1.)
if(Score() > g_total_score - 30) then
SelectSphere(i,esfera)
wiggle_out(ss) -- ceci peut changer le nombre de rotamers
end
if rotamers > rotamer.GetCount(i) then break end --si nb de rotamer a change
end
end
end
recentbest.Restore()-- car les rotamers ont pu tout casser.
end
end
-- fin d'essai d'amelioration JET 3
useThat={ --only segments what have to be used OVERRIDES all below
--18,150,151,205,320,322,359,361,425,432,433 --382
}
useOnly={ --ranges what have to be used OVERRIDES BOTH LOWER OPTIONS
--{12,24},
--{66,66},
}
doNotUse={ --ranges that should be skipped
--{55,58},
--{12,33},
}
skipAA={ --aa codes to skip
'a',
'g',
}
--option to easy set start and end of AT work to
--segStart=1 -- general option --1st segment
--segEnd=nil --end of protein if nil
--sphere_worst=false -- include worst segments in sphere or not, added to general option
--sphere_worst_value=0 --added to general option . Intervient dans SelectSphere() pour decider a partir de quel score selectionner le segment voisin
function AcidTweeker(patience, buddies, risk) -- JET version by BK
--g_total_score = Score() -- recent best to compare to and see if score was improved --essayer de cacher-----
g_score = {} -- array of segment scores for comparisons (total for segment)
--segCnt=segCnt-1 -- uncomment for lingard puzzles only!
esfera=buddies
-- for patience =1 and precision = 1 , default values:
rebuild=false -- for very end in a puzzle, rebuild segment before tweak
fix_band=false -- for trying with the worst segments
fast=true
manipulate=false -- test rotamers
if patience < 2 then manipulate=false end -- no manipulate rotamers (default)
if patience == 2 then manipulate=true end -- fast manipulate for 2
if patience > 2 then fast=false end -- slow only for 3 and 5+
if patience == 4 then manipulate=true end -- slow manipulate for 4
if risk < 2 then fix_band=false end -- fix band only for 2
if risk == 2 then fix_band=true rebuild=false end -- fix band only for 2
if risk > 2 then fix_band=false rebuild=true end -- rebuild only for 3 and 5+
if risk == 4 then fix_band=true rebuild=true end -- rebuild and fix band for 4
-- JET default options
minimo=510 -- score for working with worst segments. Don't use, usually worst segs have no rotts
mutate=false -- Don't use, very bad results yet (TODO)
maximo=-10
-- segStart=1
-- segEnd=segCnt
ini_score=Score()
-- The original recipe started here
CI(1.00)
recentbest.Restore()
save.Quicksave(3)--in save 3 always best solution. Load in case of crash.
s1=Score()
sidechain_tweak()
s2=Score()
--p("Gain Tweak: "..round(s2-s1))
p(i18.jet.tweakgain1..round(s2-s1))
sidechain_tweak_around()
s3=Score()
-- p("Gain Tweek Around: "..round(s3-s2))
p(i18.jet.tweakgain2..round(s3-s2))
if manipulate==true then
sidechain_manipulate() -- y a un bug, donne des scores negatifs !
s4=Score()
if s4-s3 <0 then recentbest.Restore() end --against the bug !!!
-- p("Gain Manipulate: "..round(s4-s3).." (ignor si <0)")
p(i18.jet.tweakgain3..round(s4-s3)..i18.jet.tweakgain3nil)
end
selection.SelectAll() -- or 2 lines in one structure.WiggleAll(4,true,true)
--WiggleSimple(1) -- new function BK 8/4/2013
WiggleAT(4)
WiggleAT(2,"ws")
--WiggleSimple(1,"ws") -- new function BK 8/4/2013
selection.SelectAll()
WiggleAT(4)
--WiggleSimple(10,"wa") -- new function BK 8/4/2013
recentbest.Restore()
s5=Score()
--p("Total Acid Tweeker gain: "..s5-s1)
end
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
--5b. Worm LWS v2 & other SD_Multiwalk functions 26/4/2015
--adapted to longer version, translated to Lua 2
function Worm(power,reserve1,minppi) -- alternative wiggle strategy, no filter management
--if sEnd==nil then sEnd=segCount end
local power=power or 1
local reserve1=reserve1 or 1
local minppi=minppi or 0 -- ici, il vaut mieux laisser 0
local pattern={}
local patternS={2,5,11,3,13,4,7,1,6,2,8,5} --how many segments at once to LWS
local patternL={2,5,11,3,13,4,7,1,6,2,8,5,12,3,10,4,7,1,6,2,9,5,14,3,5,1,8,2,13,3,7} --how many segments at once to LWS
if power ==1 then
pattern=patternS
else
pattern=patternL
end
AllLoop()
--reset_recent_best()
recentbest.Save()
--set_behavior_clash_importance(1)
CI(1.00)
--quicksave(3)
save.Quicksave(33)
local ss=Score()
for w=1,#pattern do
lenWorm=pattern[w]
local sw=Score()
--p("Starting Worm of len ",len,", score: ",round(Score()))
for s=segStart,segEnd-lenWorm+1 do
--deselect_all()
selection.DeselectAll()
selection.SelectRange(s,s+lenWorm-1)
--select_index_range(s,s+len-1)
lwWorm(minppi) -- no filter management !
end
--p("Pattern gain: ",round(Score()-sw))
--quicksave(3)
save.Quicksave(33)
end
selection.DeselectAll()
--load_structure()
save.LoadSecondaryStructure()
--p("Total Worm gain: ",round(Score()-ss))
end
function KrogWalkerV4(minseg, maxseg, threshold) -- used
--
print("Starting Krog walker V4...")
-- *** SET OPTIONS HERE ***
local minseg= minseg or 1
local maxseg= maxseg or 4
local threshold= threshold or 0.001
-- How many segments to wiggle. Starts at min, stop at max.
-- Krog recommends 1-4.
min_segs_to_wiggle = minseg -- 1
max_segs_to_wiggle = maxseg-- 4
-- How much the score must improve at each iteration to try that section again.
-- Krog recommends 0.01 for early, 0.001 mid and 0.0001 late - get all you can!
score_condition = threshold --0.001
-- If true, do a smoother, global wiggle - much slower but might squeeze extra points
should_global_wiggle = false
-- Set to true if you want it to run forever - good for overnighting
-- Krog recommends a SUPER low score condition if this is true.
should_run_forever = false
-- **********************************************************************
-- *** Dont edit below this line unless you know what you're doing :) ***
-- **********************************************************************
function wiggle_walk(section_size, score_thresh, global)
total_gain = 0;
recentbest.Restore()
behavior.SetClashImportance(1)
selection.DeselectAll()
freeze.UnfreezeAll()
segs = structure.GetCount()
for i = 1, section_size - 1 do
selection.Select(i)
end
for i = section_size, segs do
selection.Select(i)
gain = score_thresh
while gain >= score_thresh do
last_score = current.GetScore()
if global then
structure.LocalWiggleAll(40/section_size)
else
structure.LocalWiggleSelected(8)
recentbest.Restore()
end
gain = current.GetScore() - last_score
total_gain = total_gain + gain
--print("Section ", i - section_size + 1, "/", segs - section_size + 1, " Improvement: ", gain)
--print(" Total Improvement: ", total_gain)
end
selection.Deselect(i - section_size + 1)
end
end -- wiggle walk
run_condition = true
while run_condition do
run_condition = should_run_forever
for j = min_segs_to_wiggle, max_segs_to_wiggle do
wiggle_walk(j, score_condition, should_global_wiggle)
end
end
end -- Krog Walker
function M3wigglwSequence(sidechains_flag,max_iterations,threshold) -- used
--
print("starting M3 Wiggle sequence...")
-- Foldit Script "Wiggle Sequence"
-- 01-09-2010
-- V1.0
-- MooMooMan
-- If 1 then wiggle sidechains.
local sidechains_flag = sidechains_flag or 0
local threshold = threshold or 0.0001
-- If 1 then shake
shake_flag = 0
-- Set number of wiggle cycles per iteration
wiggle_cycles = 5
-- Set number of iterations to gain points.
local max_iterations = max_iterations or 10
-- Set termination threshold.
--threshold = 0.0001
-- Obtain the number of segments in the protein.
segments = structure.GetCount()
-- Maximum number of segments to wiggle.
max_wiggle = 5
-- Get the starting score.
initial_score = current.GetScore()
-- print a title.
--print("Wiggle Sequence")
-- Save the current structure in slot 10
save.Quicksave(10)
-- Reset the recent best so we can use crtl N
recentbest.Restore()
-- Loop for the wiggle length
for seq = 1, max_wiggle do
-- Loop for the selected segments.
for sel = 1, (segments-seq) do
--print("Seq ", seq, "/", max_wiggle, " : AA ", sel, "/", segments)
-- Make sure nothing is selected.
selection.DeselectAll()
-- Iterate over the segments we want to select.
for group = 0, seq do
selection.Select(sel + group)
end
-- Get the score before changing.
scoreBefore = current.GetScore()
scoreStart = current.GetScore()
scoreAfter = scoreBefore
-- Now wiggle those segments selected.
structure.LocalWiggleSelected(wiggle_cycles)
-- Shake if selected.
if (shake_flag == 1) then
structure.ShakeSidechainsSelected(1)
end
-- Wiggle sidechains if selected
if (sidechains_flag == 1) then
structure.WiggleAll(1,false,true)
end
-- Get score after operations.
scoreAfter = current.GetScore()
-- Check to see if we should iterate to get more points.
iteration_count = 0
while( ((scoreAfter - scoreBefore) > threshold) and (iteration_count < max_iterations)) do
--print ("Iterating... ", iteration_count, "/", max_iterations)
-- Reset the recent best structure..
recentbest.Restore()
-- Reset the before score.
scoreBefore = scoreAfter
-- Now wiggle those segments selected.
structure.LocalWiggleSelected(wiggle_cycles)
-- Score after operations.
scoreAfter = current.GetScore()
-- Test to see if we should keep the structure.
if( (scoreAfter - scoreBefore) > threshold) then
recentbest.Restore()
else
recentbest.Restore()
end
iteration_count = iteration_count + 1
end
-- Shake if selected.
if (shake_flag == 1) then
structure.ShakeSidechainsSelected(1)
end
-- Wiggle sidechains if selected
if (sidechains_flag == 1) then
structure.WiggleAll(1,false,true)
end
if ((current.GetScore() - scoreStart) > threshold) then
--print("Gain +", current.GetScore() - scoreStart)
end
recentbest.Restore()
end
end
end -- M3 wiggle sequence
function MoonWalker(threshold, par2, par3) -- used
print("Starting moon walker...")
-- step walker refresh. Original ideas from Datstandin.
-- updated by smith92clone 31May2010
-- Perform a local wiggle /w campon for each segment, with 1, 2 and 3 segments selected
-- If a wiggle increases in points, backup one segment and wiggle again. Could run a long time.
g_segments = structure.GetCount()
function reset_protein()
behavior.SetClashImportance(1)
selection.DeselectAll()
freeze.UnfreezeAll()
end -- reset protein
function get_protein_score(segment_count)
return current.GetScore()
end -- get protein score
function wiggle_it_out(wiggle_params)
selection.DeselectAll()
selection.SelectAll()
structure.WiggleAll(wiggle_params.sideChain_count, false, true)
structure.ShakeSidechainsSelected(wiggle_params.shake)
structure.LocalWiggleAll(wiggle_params.all_count)
recentbest.Restore()
end --wiggle it out
function do_the_local_wiggle_campon(first,last,wiggle_params)
selection.DeselectAll()
if last > g_segments then
last = g_segments
end
selection.SelectRange(first,last)
local end_score = get_protein_score()
local points_increased = false
local beginning_score = end_score
repeat
start_score = end_score
structure.LocalWiggleSelected(wiggle_params.local_wiggle)
recentbest.Restore()
end_score = get_protein_score()
--print(" start ",start_score," end ", end_score)
until end_score < start_score + wiggle_params.local_tolerance
if beginning_score + wiggle_params.local_tolerance < end_score then
points_increased = true
end
--recentbest.Restore()
return points_increased
end --do_the_local_wiggle_campon
function step_wiggle(start,finish,wiggle_params)
local i
local reset
local rewiggle_increment = 1 -- points
local rewiggle_score = get_protein_score() + rewiggle_increment
i = start
while i <= finish do
local j
local saved_changed
local points_changed = false
for j = 1,3 do
--print("seg:",i," of ",finish," wiggle Length: ",j)
saved_changed = do_the_local_wiggle_campon(i,i+j-1,wiggle_params)
if saved_changed then
points_changed = true
end
end
if points_changed then
reset = i - 1 -- we want to go back to the previous segment
if reset < start then
reset = start
end
for j=1,3 do
--print("retry seg:",reset," of ",finish," wiggle Length: ",j)
do_the_local_wiggle_campon(reset,reset+j-1,wiggle_params)
end
reset = reset + 1
if reset <= i then
-- let's not get ahead of ourselves. Only really an issue when we are retrying 1
for j=1,3 do
--print("retry seg:",reset," of ",finish," wiggle Length: ",j)
do_the_local_wiggle_campon(reset,reset+j-1,wiggle_params)
end
end
end
local new_score = get_protein_score()
if new_score > rewiggle_score then
wiggle_it_out(wiggle_params)
rewiggle_score = new_score + rewiggle_increment
end
i = i + 1
end
end -- step wiggle
reset_protein()
recentbest.Restore()
wiggle_params = {}
wiggle_params.local_wiggle = 12
wiggle_params.local_tolerance = threshold
wiggle_params.sideChain_count = 15
wiggle_params.shake = 5
wiggle_params.all_count = 15
step_wiggle(1,g_segments,wiggle_params)
end -- moon walker
function PiWalkerCamponV2(threshold, par2, par3)
--
print("Starting pi walker campon V2...")
-- rewrite of pi_walker_campon
-- author srssmith92 6June2010
-- (LF/TAB converted)
g_segments = structure.GetCount()
function mynextmode(number,maximum)
number = number + 1
if number > maximum then
number = 1
end
return number
end -- mynextmode
function get_protein_score(segment_count)
return current.GetScore()
end --get protein score
function rotate_pattern(pattern_list)
local last = #pattern_list
local i
if last > 1 then
local pattern_save = pattern_list[1]
for i = 1, last do
pattern_list[i] = pattern_list[i+1]
end
pattern_list[last] = pattern_save
end
return pattern_list
end -- rotate pattern
function unfreeze_protein()
freeze.UnfreezeAll()
end -- unfreeze protein
function freeze_segments(start_index,pattern_list)
unfreeze_protein()
local pattern_length = #pattern_list
local current_segment = start_index
local current_pattern = 1
selection.DeselectAll()
while current_segment < g_segments do
selection.Select(current_segment)
current_segment = current_segment + pattern_list[current_pattern]
current_pattern = mynextmode(current_pattern,pattern_length)
end
freeze.FreezeSelected(true,true)
end -- freeze segments
function do_the_local_wiggle_campon(first,last,wiggle_params)
selection.DeselectAll()
selection.SelectRange(first,last)
local end_score = get_protein_score()
local points_increased = false
local beginning_score = end_score
repeat
start_score = end_score
structure.LocalWiggleSelected(wiggle_params.local_wiggle)
recentbest.Restore()
end_score = get_protein_score()
--print(" start ",start_score," end ", end_score)
until end_score < start_score + wiggle_params.local_campon_tolerance
if beginning_score + wiggle_params.local_campon_tolerance < end_score then
points_increased = true
end
--recentbest.Restore()
return points_increased
end -- do the local wiggle campon
function do_a_local_wiggle(current_pattern, current_segment, end_segment, last_current_segment, last_end_segment, pattern_list, wiggle_params)
local saved_changed
saved_changed = do_the_local_wiggle_campon(current_segment, end_segment, wiggle_params)
if saved_changed then
-- now back up the pattern list
if last_current_segment ~= nil then
--print("retry segs: ", last_current_segment, " to ", last_end_segment)
do_the_local_wiggle_campon(last_current_segment, last_end_segment, wiggle_params)
--print("retry segs: ", current_segment, " to ", end_segment)
do_the_local_wiggle_campon(current_segment, end_segment, wiggle_params)
end
end
last_current_segment = current_segment
last_end_segment = end_segment
current_segment = end_segment + 2
end_segment = current_segment + pattern_list[current_pattern] - 2
current_pattern = mynextmode(current_pattern,pattern_length)
return current_pattern, current_segment, end_segment, last_current_segment, last_end_segment
end -- do a local wiggle
function local_wiggle_segments(first_frozen_segment,pattern_list,wiggle_params)
local current_segment = 0
local current_pattern = 1
local end_segment
local pattern_length = #pattern_list
local last_current_segment, last_end_segment
if first_frozen_segment == 1 then
current_segment = 2
end_segment = current_segment + pattern_list[1]-2
current_pattern = mynextmode(current_pattern,pattern_length)
else
current_segment = 1
end_segment = first_frozen_segment - 1
end
local saved_changed
repeat
--print("segs: ", current_segment, " to ", end_segment)
current_pattern, current_segment, end_segment, last_current_segment, last_end_segment = do_a_local_wiggle(current_pattern, current_segment, end_segment, last_current_segment, last_end_segment, pattern_list, wiggle_params)
until end_segment > g_segments
if current_segment <= g_segments then
--print("last segs: ", current_segment, " to ", end_segment)
do_a_local_wiggle(current_pattern, current_segment, g_segments, last_current_segment, last_end_segment, pattern_list, wiggle_params)
end
end -- local wiggle segments
function freeze_wiggle(pattern_list, wiggle_params)
local i
for i = 1,pattern_list[1] do
freeze_segments(i, pattern_list)
recentbest.Restore()
local_wiggle_segments(i, pattern_list, wiggle_params)
end
end -- freeze wiggle
function verify_pattern_list(pattern_list, maximum)
if pattern_list == nil or maximum == nil then
return false
end
local result = true
pattern_length = # pattern_list
local count = 0
for count = 1, pattern_length do
if pattern_list[count] == 1 or pattern_list[count] > maximum then
result = false
break
end
end
return result
end --verify pattern list
pattern_list = {2,3,3,4} -- distance between frozen segments. Change this to what you want. Experiment 2,2,3,3,4,4, whatever
pattern_length = #pattern_list
pattern_list_ok = verify_pattern_list(pattern_list,g_segments)
wiggle_params = {}
wiggle_params.local_wiggle = 12
wiggle_params.local_campon_tolerance = threshold
if pattern_list_ok then
for pattern_count = 1, pattern_length do
freeze_wiggle(pattern_list, wiggle_params)
end
unfreeze_protein()
else
--print("Pattern list contains a 1, or an element greater than ", g_segments, " quitting")
end
end --pi walker campon
function Power_Walker_fn(g_startSeg, par2, par3) -- used --param not used
print("Starting Power Walker...")
g_segments = structure.GetCount() --total number of segments in puzzle, last seg
g_total_score = 0 -- recent best to compare to and see if score was improved
local g_startSeg=g_startSeg or 1 -- segment to start with
local par2=par2 or 0
local par3=par3 or 0
----------------------------- Begin walk_it() -------------------------------
-- Global Variable Dependencies: g_total_score
-- Function Dependencies: last_seg(), next_seg()
function walk_it(seg,step,time)
selection.DeselectAll()
selection.SelectRange(seg, (seg+step))
g_total_score = current.GetScore()
structure.LocalWiggleSelected(time)
recentbest.Restore()
if((current.GetScore() - g_total_score) >= 0.05)then
last_seg(seg, step,time)
else
next_seg(seg, step,time)
end
end
----------------------------- Begin next_seg() -------------------------------
-- Global Variable Dependencies: N/A
-- Function Dependencies: walk_it()
function next_seg(seg, step,time)
if((seg + step) == g_segments)then
return nil
else
if(step == 1)then
step = 2
else
step = 1
seg = seg + 1
end
end
walk_it(seg, step,time)
end
----------------------------- Begin last_seg() -------------------------------
-- Global Variable Dependencies: N/A
-- Function Dependencies: N/A
function last_seg(seg, step,time)
if(step == 2)then
step = 1
else
seg = seg - 1
end
if(seg == 0)then
seg = 1
end
walk_it(seg, step,time)
end
---------------------------- Begin end_it_all() ----------------------------------
function end_it_all()
print (finished)
end
--------------------------- Script Execution Begin -----------------------------
g_total_score = current.GetScore()
selection.DeselectAll()
freeze.UnfreezeAll()
recentbest.Restore()
walk_it(g_startSeg,1,5)
behavior.SetClashImportance(0.8)
selection.SelectAll()
structure.LocalWiggleAll(1)
behavior.SetClashImportance(1.)
structure.LocalWiggleAll(5)
walk_it(g_startSeg,1,10)
behavior.SetClashImportance(0.8)
selection.SelectAll()
structure.LocalWiggleAll(1)
behavior.SetClashImportance(1.)
structure.LocalWiggleAll(5)
walk_it(g_startSeg,1,20)
behavior.SetClashImportance(0.8)
selection.SelectAll()
structure.LocalWiggleAll(1)
behavior.SetClashImportance(1.)
structure.LocalWiggleAll(5)
walk_it(g_startSeg,1,30)
end -- Power_Walker_fn
function s_ws_wa_whatever(par1, par2, par3) -- used -- par not used
print("Starting s_ws_wa_whatever...")
selection.SelectAll()
i=0
while true do
behavior.SetClashImportance(1)
i=i+1
ss=current.GetScore()
--print("Iter ",i," start at score ",ss)
structure.ShakeSidechainsSelected(1)
structure.WiggleAll(1,false,true)
structure.LocalWiggleAll(1)
behavior.SetClashImportance(0.2)
structure.MutateSidechainsSelected(1)
behavior.SetClashImportance(1)
structure.LocalWiggleAll(2)
gain=current.GetScore()-ss
--print("Gain: ",gain)
if gain<0.1 then break end
end
end -- s_ws_wa_whatever
function SdHowMany(startNum, howmany, par3)
--startNum is the HH to start with
--howmany is the highest HH to execute. Range is from 2 to numSegs/2
print("Starting SdHowmany from ", startNum, " to ", howmany, " ...")
--[[
SdWalkAllHH version 1.0
Roughly LUA HH2 through HH?? executed consecutively
This code is based on a LUA version of the Helix Hula scripts.
]]--
function HH(h,segFirst,segLast) --this is based on a LUA version of the HelixHula code
for g=0,h-1 do --for each starting position
--print(' Beginning with position ',g+1)
recentbest.Restore()
for j=segFirst+g,segLast,h do --do a local wiggle on each of the segments
k=j-h+1
m=j+h-1
if k<1 then k=1 end
if m>segLast then m=segLast end
selection.SelectRange(k,m)
structure.LocalWiggleSelected(3)
selection.DeselectAll()
recentbest.Restore()
end
end
selection.SelectAll() --reset all segments to a loop
structure.SetSecondaryStructureSelected('L')
selection.DeselectAll()
structure.ShakeSidechainsSelected(1) --shake and wiggle it out
structure.LocalWiggleAll(5)
structure.ShakeSidechainsSelected(1)
structure.LocalWiggleAll(25)
end --HH
function SdWalkAllHH(sn, hm)
--sn is the starting HH. hm is the highest HH to execute. Range is from 2 to numSegs/2
behavior.SetClashImportance(1)
freeze.UnfreezeAll()
band.DeleteAll()
selection.SelectAll() --set everything to a loop
structure.SetSecondaryStructureSelected('L')
selection.DeselectAll()
recentbest.Restore()
scoreStart=current.GetScore()
--print('Starting at score ', scoreStart)
segF=1 --the first segment number to be processed
segL=structure.GetCount() --the last segment number to be processed
for hhn=sn,hm do --main loop, each iteration is roughly one HH
--print('Executing HH',hhn)
HH(hhn,segF,segL)
recentbest.Restore()
--print('Score at end of HH', hhn, ' is ', current.GetScore())
end
--print('Score improved by: ', current.GetScore() - scoreStart)
--print('And all done!')
end -- SdWalkAllHH
SdWalkAllHH(startNum, howmany)
end -- SdHowMany
function Stabilize_fn(par1, par2, par3)
print("Starting Stabilize 3.0.7...")
segCount=structure.GetCount()
function Score()
return current.GetScore()
end
function Round(x)--cut all afer 3-rd place
return x-x%0.001
end
function Down(x)--cut all afer comma
return x-x%1
end
function SelectSphere(sg, radius)
selection.DeselectAll()
for i=1, segCount do
if structure.GetDistance(sg,i)<radius then selection.Select(i) end
end
end
function PartialScoreTable() --fill score table
local scr={}
for i=1, segCount do
scr[i]=current.GetSegmentEnergyScore(i)--get partial scores
end
return scr
end
function GetWorst(sctbl)
local min=sctbl[1]
local wrst=1
for x=2, #sctbl do
if sctbl[x]<min then
wrst=x
min=sctbl[x]
end
end
sctbl[wrst]=99999
return wrst
end
function Gibaj(jak, iters, minppi) --score conditioned recursive wiggle/shake
if jak==nil then jak="wa" end
if iters==nil then iters=6 end
if minppi==nil then minppi=0.4 end
if iters>0 then
iters=iters-1
local sp=Score()
if jak == "s" then structure.ShakeSidechainsSelected(1)
elseif jak == "wb" then structure.WiggleAll(1,true, false)
elseif jak == "ws" then structure.WiggleAll(1,false,true)
elseif jak == "wa" then structure.LocalWiggleAll(1)
end
local ep = Score()
local ig=ep-sp
if ig > minppi then Gibaj(jak, iters, minppi) end
end
end
function wss(minppi)
repeat
local ss=Score()
structure.WiggleAll(1,false,true)
structure.ShakeSidechainsSelected(1)
g=Score()-ss
until g<minppi
end
function wig(mingain) --score conditioned local wiggle,
repeat --wiggles selected segments
local ss=Score()
structure.LocalWiggleSelected(2)
local wg=Score()-ss
if wg<0 then
recentbest.Restore()
end
until wg<mingain
end
function StabilizeWorstSphere(sgmnts)
sgmnts=Down(sgmnts)
recentbest.Restore()
sctbl=PartialScoreTable()
for i=1, sgmnts do
local found=flase
local wrst=0
wrst=GetWorst(sctbl)
--P(sgmnts+1-i," more spheres to fix. Now fixing: ",wrst)
selection.DeselectAll()
selection.Select(wrst)
wig(20)
SelectSphere(wrst,11)
wss(1)
wig(20)
end
end
function Stabilize(maxLoops)
behavior.SetClashImportance(1)
local sstart= Score()
--P("Starting score: ",Round(sstart))
for iters = 1, maxLoops do
local ss=Score()
selection.SelectAll()
wss(2)
StabilizeWorstSphere(segCount/20)
local gain=Score()-ss
--P("WSS LWS loop ",iters," gain: ",Round(gain))
if gain<200 then break end
end
selection.SelectAll()
repeat
local ss=Score()
wss(2)
Gibaj()
local g=Score()-ss
until g<20
send=Score()
--P("Total improved by: ", Round(send-sstart), " points.")
--P("End score: ", Round(send))
end
maxLoops=10
Stabilize(maxLoops)
end -- Stabilize_fn
function walker_1point1_fn(minlen,maxlen,minppi)
print("Starting Walker 1.1...")
segCount = structure.GetCount()
function Score()
return current.GetScore()
end
bestScore=Score()
function round(x)--cut all afer 3-rd place
return x-x%0.001
end
function SelectSphere(sg, radius,nodeselect)
if nodeselect~=true then selection.DeselectAll() end
for i=1, segCount do
if structure.GetDistance(sg,i)<radius then selection.Select(i) end
end
end
function Gibaj(jak, iters, minppi) --score conditioned recursive wiggle/shake
if jak==nil then jak="wa" end
if iters==nil then iters=6 end
if minppi==nil then minppi=0.04 end
if iters>0 then
iters=iters-1
local sp=Score()
if jak == "s" then structure.ShakeSidechainsSelected(1)
elseif jak == "wb" then structure.WiggleAll(1,true, false)
elseif jak == "ws" then structure.WiggleAll(1,false,true)
elseif jak == "wa" then structure.LocalWiggleAll(1)
end
local ep = Score()
local ig=ep-sp
if ig > minppi then Gibaj(jak, iters, minppi) end
end
end
function wig(mingain) --score conditioned local wiggle,
repeat --wiggles selected segments
local ss=Score()
structure.LocalWiggleSelected(2)
local se=Score()
local wg=se-ss
if wg<0 then
recentbest.Restore()
end
until wg<mingain
end
function wsw(minppi)
behavior.SetClashImportance(1)
local nows=false
repeat
local ss=Score()
if nows==false then structure.WiggleAll(1,false,true) end
if shake==true then structure.ShakeSidechainsSelected(1) end
local shs=Score()
structure.WiggleAll(2, false, true)
local ws=Score()
local g=ws-ss
nows=true
if ws-shs<minppi/10 then break end
until g<minppi
end
function test()
local gain = Score() - bestScore
if gain > 0 then
--print("Improved by: ", round(gain))
bestScore = Score()
save.Quicksave(3)
elseif gain<0 then
save.Quickload(3)
end
end
function Walker()
local ss=Score()
if endS==nil then endS=segCount end
recentbest.Restore()
save.Quicksave(3)
behavior.SetClashImportance(1)
--print("Walker started.")
for l=minlen,maxlen do
for i=startS, endS-l do
--print("Sgmnt ",i," len: ",l)
selection.DeselectAll()
selection.SelectRange(i,i+l-1)
if doWSW then wsw(minppi) end
wig(minppi)
test()
end
end
--print("Totoal improved by: ",round(Score()-ss))
end
local minppi=minppi or 0.0002
startS=1 --start segment to walk
endS=nil --end segment to walk -nil=end of protein
local minlen=minlen or 1
local maxlen=maxlen or 13
doWSW=true --false --set to true if it have to shake/wiggle sidechains too
local shake=false
Walker()
end -- walker_1-1_fn
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
--6. JET (Join Evolver team) by Bruno.kestemont helped by Jean-Bob
--A combination of various LWS recipes
--Starting from most efficient to slowest for night run
------------------------
--JET call and safety function
------------
function JET(funcName, func, param1, param2, param3)
if nextskip==funcName or oldskip== funcName then
p(i18.jet.skipping..funcName)
oldskip=nextskip -- will be skipped a second time
nextskip="" -- 2 skips is enough
skipthis=true
end -- saute une recette non gagnante 2 fois
if interuptor==false and skipthis==false then --pour interrompre en debut de puzzle, JET ne jouant qu'un role initial
local startRecTime=os.time() -- en secondes entieres
CI(1)
--p(funcName.." (".. param1..", ".. param2..", ".. param3..") en cours ...")
p(i18.jet.running1..funcName.." (".. param1..", ".. param2..", ".. param3..")"..i18.jet.running2.."...")
save.SaveSecondaryStructure()
recentbest.Save()
bestScore=Score() -- necessaire pour savebest()
func(param1, param2, param3)
local score=Score()
local RecTime=(os.time()-startRecTime)/60 -- en minutes
if score<=maxScore then
--p("... ne gagna plus rien en "..RecTime.." minutes")
p(i18.jet.nogain..RecTime.." minutes")
recentbest.Restore()
nextskip=funcName -- NEW 20/6/2013 to skip this function twice
elseif score>maxScore then
if score<maxScore +0.001 then -- NEW 19/7/2013 to skip this function twice
nextskip=funcName
end
gainRecipe=score-maxScore
maxScore= score
save.Quicksave(3)
--print("... gagna ".. round(gainRecipe).." points en "..down(RecTime).." minutes")
p(i18.jet.gain1..round(gainRecipe)..i18.jet.gain2..down(RecTime).." minutes")
end
save.LoadSecondaryStructure()
JETgain=maxScore-startingscore
JETtime=(os.time()-startTime)/60 -- en minutes
--p("Score actuel ".. round(score)..". >>>>Gain JET = ".. round(JETgain).."<<<< en "..down(JETtime).."'")
p(i18.jet.score.. round(score)..i18.jet.gainT.. round(JETgain)..i18.jet.gainin..down(JETtime).."'")
testinterupt(JETgain)
forecastGain()
comptetour=comptetour+1
end
skipthis=false
end
--------------------------------------------------------------
--Documentation FR
--[[ 1.PreciseLWS(howmany, buddies, minppi)
-- >Cherche et secoue les pires segments
-- howmany = combien de pires segments
-- buddies = nombre de segments adjascents
-- minppi = gain minimum par iteration LWS
-- usage = (5,4,0.1) -- les valeurs par defaut les plus efficaces ]]--
--[[2.WalkeR(minLen, maxLen, minPpi)
-- >Secoue des segments adjascents dans un ordre aleatoire
-- minLen= longueur minimum pour LWS
-- maxLen= longueur segCntmum pour LWS
-- minPpi= gain minimum par iteration (boucle sarrete quand gain plus petit)
-- usage = (1,7,0.1) -- les valeurs par defaut les plus efficaces ]]--
--[[3. LuckyLWS(howmany, buddies, minppi)
-- >Cherche et secoue les meilleurs segments, apres un test
-- howmany = combien de meilleurs segments
-- buddies = nombre de segments adjascents
-- minppi = gain minimum par iteration LWS
-- usage = (5,4,0.1) -- les valeurs par defaut les plus efficaces ]]--
--[[4. totalLws(minlen,maxlen, minppi)
-- minlen= longueur minimum pour LWS
-- maxlen= longueur segCntmum pour LWS
-- minppi = gain minimum par iteration (boucle sarrete quand gain plus petit)
-- usage = (1,7,0.1) -- les valeurs par defaut les plus efficaces ]]--
--[[5. AcidTweeker(patience, buddies, risk)
-- patience=rapide si petit-- 1=rapide; 2=bruteforce rapide ; 3= lent ; 4=bruteforce lent
-- buddies = nombre de segments adjascents
-- risk=faible si petit -- 1=defaut; 2=bandes ; 3= rebuild ; 4=bandes et rebuild
--usage= (1, 8, 3) -- les valeurs par defaut les plus efficaces ]]--
--[[5b. Worm(power,reserve1,minppi)
-- power = normal ou long 1 ou 2
--reserve1= reserve au cas ou
--minppi= minppi
--usage= (1) ]]--
-- KrogWalkerV4(minseg, maxseg, threshold) -- 1,4,0.0001
-- SdHowMany(startNum, howmany,anythingelse) -- 2,4,(0, not used)
-- M3wigglwSequence(sidechains_flag,max_iterations,threshold) -- 0,10,0.0001
-- Power_Walker_fn(g_startSeg, par2, par3) -- 1,0,0
-- s_ws_wa_whatever(par1, par2, par3) -- 0,0,0
-- MoonWalker(threshold, par2, par3) -- 0.0001,0,0
-- PiWalkerCamponV2(threshold, par2, par3) -- 0.0001,0,0
-- Stabilize_fn() -- 0,0,00
-- walker_1point1_fn -- 1,13,0.002
--[[6. JET(func, param1, param2, param3)
-- func = est le nom dune des fonctions ci-dessus -- par example AcidTweeker
-- param1= le premier parametre de la fonction appelee
-- param2= le deuxieme parametre de la fonction appelee
-- param3= le dernier parametre de la fonction appelee
--usage= ("Total LWS".. totalLws, 1, 7,0.1) -- les valeurs les plus efficaces ]]--
----Start module several steps to be saved--------------
function cherchevol() --identifie les passages d'unite
local score=Score() --evolbase est le down du depart
local passeUnite=score-evolbase --incrementer jusque passage de la prochaine unite
if passeUnite<1 then --avant de passer la premiere unite
save.Quicksave(11) --mise a jour jusqu'au plus haut decimal possible
else
evolbase=down(score) --eliminer les decimales du futur evoluable
JETevolver() -- cascade sur base du dernier slot 11 sauve juste en-dessous de l'unite ou sauve en cas de grands gains
end
end
function JETevolver()
--print("Sauvegarde pour partage evoluable")
save.Quickload(10) --reprendre l'avant derniere version
save.Quicksave(9) --en faire l'antepenultienne version, celle a recuperer
save.Quickload(11) --reprendre la version au plus haut decimal possible
save.Quicksave(10) --la sauver en 10 -- donc la 10 sera l'avant derniere version
recentbest.Restore() --reprendre la toute derniere version pour continuer
end
----Stop module several steps to be saved--------------
----Start module print significant gains--------------
function GainAnother(g) --prints small gains
if g>relD2target then
--p("(gain en cours: ".. g..")")
p(i18.jet.gaining..g..")")
end
end
function forecastGain()
if JETgain>0 and comptetour>1 and comptetour<30 then
--local lncount=math.log (32-comptetour)
--local pentegain=JETgain/(JETgain-gainRecipe)-1 --increment relatif
--local espoirdegain=pentegain*lncount -- au pif: a fignoler !
local gainparminute=JETgain/JETtime
local tempsrestant=JETtime/comptetour*(32-comptetour)
local espoirdegain=gainparminute/0.479*0.00005*tempsrestant
--p("Temps restant: "..down(tempsrestant/60).." heures.".. "Peut encore gagner "..round(espoirdegain).." pts.")
p(i18.jet.timeleft..down(tempsrestant/60)..i18.jet.hours.. i18.jet.maygain..round(espoirdegain).." pts.")
end
end
----Stop module print significant gains--------------
function nettoyage()
--p("Nettoyage")
--p(i18.jet.cleaning)
selection.DeselectAll()
freeze.UnfreezeAll()
band.DeleteAll()
--p("Rtablissement de la structure secondaire")
--p(i18.jet.restorestructure)
save.LoadSecondaryStructure()
CI(1)
behavior.SetSlowFiltersDisabled(OriginalFilterSetting)
end
--Start Finale elegante pour laisser quelque chose d'evoluable
function elegantfinal()
--p("Enregistrement du meilleur rsultat")
p(i18.jet.savingbest)
recentbest.Restore()
if note1libre and comptetour>10 then
--p("Signature dans Note du segment 1")
p(i18.jet.signature)
structure.SetNote(1,historic)
end
save.Quicksave(3)
save.Quickload(9) -- ici, ne rien mettre dans la note1
nettoyage()
recentbest.Save()
--p("Enregistrement de solution voluable dans Undo ou Slot 9")
p(i18.jet.undosave)
save.Quickload(3)
WhriteNote() -- new 8/11/2014
nettoyage()
p(i18.jet.cleaning)
p(i18.jet.restorestructure)
end
--Stop fin de Finale elegante pour laisser quelque chose d'evoluable
----Start module error and cancel management ---------adapted from Jean-Bob, Ebola
function alreadydone()
if #saveNote1>0 and saveNote1:find(recipeName) then
--p(recipeName.." a dja te utilise.")
p(recipeName..i18.jet.alreadydone)
FirstJET=false
end
end
function testinterupt(gain)
if gain>20 and timeLeft> 96 then
if gain > 100* relD2target then
interuptor=true -- interrompt JET
TargetReset()
--p("Interruption de JET pour milieu de partie")
--p("Inutile d'insister avec JET maintenant")
--p("Je vous conseille de lancer Ebola")
p(i18.jet.middlegame)
p(i18.jet.stopnow)
p(i18.jet.suggestEbola)
end
elseif gain<0 then
interuptor=true -- interrompt JET
--p("Interruption de JET, perte anormale")
--p("Merci de signaler ce bug a l'auteur")
p(i18.jet.interrupt)
p(i18.jet.signalerror)
end
end
function DumpErr(err) -- Based on Jean-Bob
start,stop,line,msg=err:find(":(%d+):%s()")
err=err:sub(msg,#err)
p("---")
if err:find("Cancelled")~=nil then
--p("Arrt utilisateur.")
p(i18.recipe.de1)
else
--p("Erreur inattendue dtecte.")
--p("Ligne d'erreur : "..line)
--p("Message d'erreur : "..err)
p(i18.recipe.de2)
p(i18.recipe.de3..line)
p(i18.recipe.de4..err)
if note1libre then
--p("Sauvegarde de l'tat du script")
p(i18.recipe.lw4)
structure.SetNote(1,err)
end
end
elegantfinal()
end
----Stop module error and cancel management ---------
--Start filter management initialization -- New 01/09/2014
-- Reason: filters are some times important. I only check if they are slow before to desactivate
function iFilterSettings() -- new version 28/4/2015
print ("testing filter effect")
--save.Quicksave(23)
behavior.SetSlowFiltersDisabled(true)
local tempfilter=PROBABLEFILTER -- boolean, normally should be true here
local thisStartTime=os.time() -- en secondes?
--PROBABLEFILTER=true
--WiggleSimple()
--timeNeededFiltered=os.difftime(thisStartTime,os.time()) -- en sec
--save.Quickload(23)
--thisStartTime=os.time()
--PROBABLEFILTER=false
behavior.SetSlowFiltersDisabled(false)
--WiggleSimple()
--timeNeededNotFiltered=os.difftime(thisStartTime,os.time()) -- en sec
timeloss=os.difftime(os.time(),thisStartTime) -- en sec
--local timeloss=timeNeededFiltered-timeNeededNotFiltered
print ("Time loss by filtering: ",timeloss)
if timeloss<0.01 then
PROBABLEFILTER=false -- desactivate filter settings if filters are not altering time too much
else
PROBABLEFILTER=tempfilter
print ("Filters wil be disabled during wiggling")
end
behavior.SetSlowFiltersDisabled(OriginalFilterSetting)
--save.Quickload(23)
end
--Stop filter management initialization
--initializing in case of very start of the puzzle
function startingmenu()
if maxScore < TargetMean then
p("############################")
p("ENTREE")
if maxScore < 0 then
JET("Lucky LWS", LuckyLWS, 5, 4, 500)
JET("Total LWS", totalLws, 1, 7, 300)
end
if maxScore < 2000 then
JET("Lucky LWS", LuckyLWS, 5, 4, 300)
JET("Total LWS", totalLws, 1, 7, 200)
JET("Precise LWS", PreciseLWS, 5, 4, 100)
end
if maxScore < 8000 then JET("Total LWS", totalLws, 1, 7, 3) end
if maxScore < TargetMin then JET("Total LWS", totalLws, 1, 7, 1) end
JET("Total LWS", totalLws, 1, 7, 0.3)
end
end
--end section very start of the puzzle
-- starting the cooking menu
function cookingmenu()
p("############################")
p(i18.jet.maindishes)
JET("Total LWS", totalLws, 1, 7, 0.1)-- 1 a 7 segments
JET("WalkeR", WalkeR, 1, 7, 0.1) -- 1 a 7 segments
JET("Worm LWS", Worm,1,1,0.1) -- worm normal 26/02/2014
JET("Total LWS", totalLws, 3, 7, 0.1)
if segCnt > 13 then JET("Total LWS", totalLws, 8, 12, 0.1) end
JET("Total LWS", totalLws, 6, 7, 0.1)
if FirstJET and maxScore < TargetMin then -- sinon passer plus vite au dessert
JET("AcidTweeker", AcidTweeker, 1, 8, 1)
JET("Total LWS", totalLws, 4, 7, 0.1)
JET("Total LWS", totalLws, 2, 7, 0.1)
JET("Precise LWS", PreciseLWS, 5, 4, 0.01) -- 5 pires segments, 4 adjascents
JET("Total LWS", totalLws, 5, 7, 0.1)
JET("Lucky LWS", LuckyLWS, 5, 4, 0.01) -- 5 meilleurs segments, 4 adjascents
JET("Total LWS", totalLws, 1, 7, 0.01)
JET("Total LWS", totalLws, 3, 7, 0.01)
JET("AcidTweeker", AcidTweeker, 1, 8, 1)
end
if segCnt > 11 then JET("Total LWS", totalLws, 6, 10, 0.01) end
JET("Total LWS", totalLws, 4, 7, 0.01)
JET("WalkeR", WalkeR, 1, 7, 0.01)
JET("Worm LWS", Worm,1,1,0.01) -- worm normal 26/02/2014
JET("Total LWS", totalLws, 2, 7, 0.01)
JET("Total LWS", totalLws, 5, 7, 0.01)
if segCnt > 16 then
JET("Precise LWS", PreciseLWS, 9, 3, 0.01)
JET("Total LWS", totalLws, 8, 12, 0.01)
JET("Worm LWS", Worm,2,1,0.01) -- worm long 26/02/2014
end
if segCnt > 15 then JET("Lucky LWS", LuckyLWS, 5, 5, 0.1) end
JET("AcidTweeker", AcidTweeker, 1, 8, 3) -- le plus efficace, options 1.78
JET("WalkeR", WalkeR, 1, 7, 0.001)
if segCnt > 13 then JET("Total LWS", totalLws, 1, 12, 1) end
JET("Total LWS", totalLws, 1, 7, 0.01)
JET("AcidTweeker", AcidTweeker, 2, 6, 4) -- plus lent
end -- fin de cookingmenu
--Pour patienter jusqua la fin de la nuit
function dessert()
for i=1, 20 do -- NEW 20/6/2013, we rely on skipthis to avoid uneffective runnings
p("###############################")
p(i18.jet.runningdessert..i.."/20")
JET("SdHowMany", SdHowMany, 2, 4, 0)
JET("AcidTweeker", AcidTweeker, 3, 9, 3)
if segCnt > 13 then JET("Total LWS", totalLws, 1, 12, 1) end
JET("KrogWalkerV4", KrogWalkerV4, 1, 4, 0.0001)
JET("SdHowMany", SdHowMany, 26, 32, 0)
JET("AcidTweeker", AcidTweeker, 4, 8, 5)
JET("Total LWS", totalLws, 1, 7, 0.01)
if segCnt > 20 then JET("Precise LWS", PreciseLWS, 10, 4, 0.001) end
JET("Worm LWS", Worm,2,1,0) -- worm long 26/02/2014
if segCnt > 26 then JET("Total LWS", totalLws, 8, 25, 0.01) end
JET("M3wigglwSequence", M3wigglwSequence, 0, 10, 0.0001)
JET("walker_1point1_fn", walker_1point1_fn, 1, 13, 0.002)
JET("SdHowMany", SdHowMany, 5, 7, 0)
JET("Lucky LWS", LuckyLWS, 5, 4, 0.001)
JET("Power_Walker_fn", Power_Walker_fn, 1, 0, 0)
JET("Total LWS", totalLws, 1, 7, 0.001)
JET("AcidTweeker", AcidTweeker, 1, 8, 3)
JET("s_ws_wa_whatever", s_ws_wa_whatever, 0,0,0)
JET("WalkeR", WalkeR, 1, 7, 0.001)
JET("Total LWS", totalLws, 3, 7, 0.001)
JET("AcidTweeker", AcidTweeker, 4, 8, 5)
JET("MoonWalker", MoonWalker, 1, 7, 0.0001)
JET("Total LWS", totalLws, 3, 7, 0.001)
JET("Stabilize_fn", Stabilize_fn, 0,0,0)
JET("PiWalkerCamponV2", PiWalkerCamponV2, 3, 7, 0.001)
end
end
--fin du petit extra
OnlyDessert= false
function GetParams()
dlg = dialog.CreateDialog(recipeName)
dlg.OnlyDessert = dialog.AddCheckbox(i18.ask.options.OnlyDessert,OnlyDessert)
dlg.ok = dialog.AddButton("OK", 1)
dlg.cancel = dialog.AddButton(i18.ask.cancel, 0)
if dialog.Show(dlg) > 0 then
OnlyDessert=dlg.OnlyDessert.value
return true
else
print(i18.ask.logCancel)
return false
end
end
---M A I N ------------------------
function MAINjet()
checkbadpuzzle()
setlanguage()
multilingual(lang)
--SNIP de base ----
--p("Join Evolver Team 3.0 par BK")
p(i18.jet.intro1)
--p("Score de DEPART= ".. round(Score()))
p(i18.jet.intro2..round(Score()))
print("Bonus= "..round(filterB))
if GetParams() then
--p("1 nuit de travail PC. Bonne nuit " .. user.GetPlayerName() .."!")
p(i18.jet.intro3 .. user.GetPlayerName() .."!")
recentbest.Save() -- New BK 19/7/2013
Stanley()
note1free()
alreadydone()
if PROBABLEFILTER then iFilterSettings() end -- New 01/09/2014
if not OnlyDessert then
startingmenu()
cookingmenu()
end
dessert()
elegantfinal()
end
end
xpcall(MAINjet, DumpErr)