In[]:=
Adapt2DCAMax[initRule_Integer,{nColors_Integer,neig_,init_},maxIters_Integer,lossFn_,mutateFn_]:=Block[{lossFun=lossFn[{nColors,neig,init}],mutateFun=mutateFn[{nColors,neig}]},NestWhileList[Block[{currentRule=#[[1]],currentLoss=#[[2]]},Block[{mutatedRule=mutateFun[currentRule],newLoss},newLoss=lossFun[mutatedRule];If[newLoss!=Infinity&&newLoss>=currentLoss,{mutatedRule,newLoss},#]]]&,{initRule,lossFun[initRule]},Last[#]>0&,1,maxIters]]
In[]:=
Mutate2DCARule[{nColors_Integer,neig_}][rule_Integer]:=Block[{digits,pos},digits=IntegerDigits[rule,nColors,nColors^neig];pos=RandomInteger[{1,Length[digits]-1}];FromDigits[ReplacePart[digits,pos->Mod[digits[[pos]]+RandomInteger[{1,nColors-1}],nColors]],nColors]]
In[]:=
LifetimeValueProtected[nSteps_Integer][{nColors_Integer,neig_,init_}][rule_Integer]:=If[Total[Flatten[CellularAutomaton[<|"RuleNumber"->rule,"Neighborhood"->neig,"Dimension"->2,"Colors"->nColors|>,{init,0},{{30}}]]]>40,Infinity,Lifetime[CellularAutomaton[<|"RuleNumber"->rule,"Neighborhood"->neig,"Dimension"->2,"Colors"->nColors|>,{init,0},nSteps]]]
In[]:=
Lifetime[states_List]:=If[#==0,Infinity,Length[states]-#+1]&[LengthWhile[Reverse[states],Union[Flatten[#]]==={0}&]]
In[]:=
data2dca=(SeedRandom[654851541515+190];Adapt2DCAMax[0,{2,9,CrossMatrix[1]},5000,LifetimeValueProtected[500],Mutate2DCARule]);
In[]:=
data2dca=(SeedRandom[654851541515+190];Adapt2DCAMax[0,{2,9,CrossMatrix[1]},10000,LifetimeValueProtected[500],Mutate2DCARule]);
In[]:=
{First[#],Length[#]}&/@SplitBy[data2dca,Last]
Out[]=
{{{0,2},64},{{1675976041289120464735641167525176039273480091559263613068978198240535682063930763457910716263850439702469348493080818290759600369797852380448427492773888,3},803},{{231572054635167956514789791782988119452522379569110293767759166793446106264520467488838688813947315306149768741821719745917451188553897570295785889529984,5},416},{{853788359016821837880911615146124214586282204661307033842240439951556793272369380080502051063422331907873404953876354753231495550612886842461023166922880,6},68},{{944625151293497636619925344785955087918694546794598159181802857872679330675291179293764384022792869169136322779704430538164847294021036488151260862742688,8},87},{{10218140443702053276162947079046836919390376560385431154466777797099189000180178721405098585304389697239416755542103540548884974119313668974328265201811616,14},38},{{10224687221899736908396033047736941327069317972707488893488871848521829933999577300833236555500235350854344768457184985351089130400703365599961047928275104,16},105},{{10224481111475910617878368146341983158704351225398226348605243138787478895153792298664021437708791073933476135174934113296067575431777324645341969231511712,51},6},{{10224481114597849704604902125296296550437813125434379282332376710844414306519771815754324806044297652737243724726361854644194057415318687746802160142254240,95},23},{{10224481116158723985577608035349306065853825747016924885219799510046908109390766701286408298994514344909852070545890798184208121861344781226569195248025760,147},91},{{10224482714542759068464318227926054309756627133998554897497199719792225422560118061391743684442019354396879061591595805652051005977695058979358021406294176,149},41},{{3520578749571460518677305728823131246016944223702358138643395804874961827595862611515734607550037308928509140771084096088077094093166945477213091868573856,165},431},{{3514031968355668234937279349429476047712433977869834510549551283859612773428695108427941817956223355762031014639276186855179913022478815735755784822325408,168},376},{{4350383268673513555546738357453748196614095238736875701114314426356893669235572694076130050413960348643884368706270110467872060368031942689135314392449184,185},1765},{{4350383268673513555546732812114359954984453038951859747914119035982938510598149872610462581132103855484670791799815258512532540707084545120050495384322208,223},687}}
In[]:=
#[[1,2]]&/@%
Out[]=
{2,3,5,6,8,14,16,51,95,147,149,165,168,185,223}
In[]:=
{First[#],Length[#]}&/@SplitBy[data2dca,Last]
Out[]=
{{{0,2},64},{{1675976041289120464735641167525176039273480091559263613068978198240535682063930763457910716263850439702469348493080818290759600369797852380448427492773888,3},803},{{231572054635167956514789791782988119452522379569110293767759166793446106264520467488838688813947315306149768741821719745917451188553897570295785889529984,5},416},{{853788359016821837880911615146124214586282204661307033842240439951556793272369380080502051063422331907873404953876354753231495550612886842461023166922880,6},68},{{944625151293497636619925344785955087918694546794598159181802857872679330675291179293764384022792869169136322779704430538164847294021036488151260862742688,8},87},{{10218140443702053276162947079046836919390376560385431154466777797099189000180178721405098585304389697239416755542103540548884974119313668974328265201811616,14},38},{{10224687221899736908396033047736941327069317972707488893488871848521829933999577300833236555500235350854344768457184985351089130400703365599961047928275104,16},105},{{10224481111475910617878368146341983158704351225398226348605243138787478895153792298664021437708791073933476135174934113296067575431777324645341969231511712,51},6},{{10224481114597849704604902125296296550437813125434379282332376710844414306519771815754324806044297652737243724726361854644194057415318687746802160142254240,95},23},{{10224481116158723985577608035349306065853825747016924885219799510046908109390766701286408298994514344909852070545890798184208121861344781226569195248025760,147},91},{{10224482714542759068464318227926054309756627133998554897497199719792225422560118061391743684442019354396879061591595805652051005977695058979358021406294176,149},41},{{3520578749571460518677305728823131246016944223702358138643395804874961827595862611515734607550037308928509140771084096088077094093166945477213091868573856,165},431},{{3514031968355668234937279349429476047712433977869834510549551283859612773428695108427941817956223355762031014639276186855179913022478815735755784822325408,168},1028},{{3512395273051720164002278299920450489766121470105083002238774562955789691309997612910217516128706245997348756808708709909342386391141501329185793187643552,198},337},{{3518942054264463865173636718150647097025834865226711516444044884802471063434422809931292878949959317882877588798878061563937572249061936201543145276702880,206},978},{{4356930048325001908739017164847713865096712076139437101211305092661884415421404894114555020729361477966644372387414564821654365747661782370771995262582944,286},5485}}
In[]:=
#[[1,2]]&/@%
Out[]=
{2,3,5,6,8,14,16,51,95,147,149,165,168,198,206,286}
In[]:=
allrules[[190]]
Out[]=
{{{0,2},64},{{1675976041289120464735641167525176039273480091559263613068978198240535682063930763457910716263850439702469348493080818290759600369797852380448427492773888,3},803},{{231572054635167956514789791782988119452522379569110293767759166793446106264520467488838688813947315306149768741821719745917451188553897570295785889529984,5},416},{{853788359016821837880911615146124214586282204661307033842240439951556793272369380080502051063422331907873404953876354753231495550612886842461023166922880,6},68},{{944625151293497636619925344785955087918694546794598159181802857872679330675291179293764384022792869169136322779704430538164847294021036488151260862742688,8},87},{{10218140443702053276162947079046836919390376560385431154466777797099189000180178721405098585304389697239416755542103540548884974119313668974328265201811616,14},38},{{10224687221899736908396033047736941327069317972707488893488871848521829933999577300833236555500235350854344768457184985351089130400703365599961047928275104,16},105},{{10224481111475910617878368146341983158704351225398226348605243138787478895153792298664021437708791073933476135174934113296067575431777324645341969231511712,51},6},{{10224481114597849704604902125296296550437813125434379282332376710844414306519771815754324806044297652737243724726361854644194057415318687746802160142254240,95},23},{{10224481116158723985577608035349306065853825747016924885219799510046908109390766701286408298994514344909852070545890798184208121861344781226569195248025760,147},91},{{10224482714542759068464318227926054309756627133998554897497199719792225422560118061391743684442019354396879061591595805652051005977695058979358021406294176,149},41},{{3520578749571460518677305728823131246016944223702358138643395804874961827595862611515734607550037308928509140771084096088077094093166945477213091868573856,165},431},{{3514031968355668234937279349429476047712433977869834510549551283859612773428695108427941817956223355762031014639276186855179913022478815735755784822325408,168},1242},{{4352019963977080553666334339350900859512310783599258869552596448083420322282487776136368305147875295705465558119926191236353974208330577974919245844316320,237},6586}}
In[]:=
Out[]=
{{{0,2},64},{{1675976041289120464735641167525176039273480091559263613068978198240535682063930763457910716263850439702469348493080818290759600369797852380448427492773888,3},803},{{231572054635167956514789791782988119452522379569110293767759166793446106264520467488838688813947315306149768741821719745917451188553897570295785889529984,5},416},{{853788359016821837880911615146124214586282204661307033842240439951556793272369380080502051063422331907873404953876354753231495550612886842461023166922880,6},68},{{944625151293497636619925344785955087918694546794598159181802857872679330675291179293764384022792869169136322779704430538164847294021036488151260862742688,8},87},{{10218140443702053276162947079046836919390376560385431154466777797099189000180178721405098585304389697239416755542103540548884974119313668974328265201811616,14},38},{{10224687221899736908396033047736941327069317972707488893488871848521829933999577300833236555500235350854344768457184985351089130400703365599961047928275104,16},105},{{10224481111475910617878368146341983158704351225398226348605243138787478895153792298664021437708791073933476135174934113296067575431777324645341969231511712,51},6},{{10224481114597849704604902125296296550437813125434379282332376710844414306519771815754324806044297652737243724726361854644194057415318687746802160142254240,95},23},{{10224481116158723985577608035349306065853825747016924885219799510046908109390766701286408298994514344909852070545890798184208121861344781226569195248025760,147},91},{{10224482714542759068464318227926054309756627133998554897497199719792225422560118061391743684442019354396879061591595805652051005977695058979358021406294176,149},41},{{3520578749571460518677305728823131246016944223702358138643395804874961827595862611515734607550037308928509140771084096088077094093166945477213091868573856,165},431},{{3514031968355668234937279349429476047712433977869834510549551283859612773428695108427941817956223355762031014639276186855179913022478815735755784822325408,168},1242},{{4352019963977080553666334339350900859512310783599258869552596448083420322282487776136368305147875295705465558119926191236353974208330577974919245844316320,237},6586}}
Earlier
Earlier
Well, at least the rules come out the same.
It seems that only the initial lifetime is different, 1 vs 2 (1 is correct for the null rule)
It seems that only the initial lifetime is different, 1 vs 2 (1 is correct for the null rule)
Old (note the minus 1)
Old (note the minus 1)
New (minus 1 removed)
New (minus 1 removed)