WOLFRAM NOTEBOOK

In[]:=
RuleArrayLifetime=FunctionCompile[Function[{Typed[ruleArray,"PackedArray"::["MachineInteger",2]]},Module[{i,state,states,newState,raHeight=Length[ruleArray],raWidth=Length[ruleArray[[1]]],loss},state=ConstantArray[0,raWidth];state[[Quotient[raWidth,2]]]=1;i=1;While[Total[state]>0&&i<=raHeight,state=Table[Module[{left,center,right,raElement,input},left=If[j==1,state[[-1]],state[[j-1]]];center=state[[j]];right=If[j==raWidth,state[[1]],state[[j+1]]];raElement=ruleArray[[i,j]];input=BitOr[BitShiftLeft[left,2],BitShiftLeft[center,1],right];BitShiftRight[BitAnd[raElement,BitShiftLeft[1,input]],input]],{j,raWidth}];++i;];i]]];
In[]:=
ICAEvolveList[{rulearray_,r_},init_]:=FoldList[Boole[MapThread[BooleanFunction[#1,2r+1]@@#2&,{#2,Partition[#,2r+1,1,2r]}]]&,init,rulearray]
In[]:=
ICAEvolvePlot[{ruleindices_,r_},init_,rulelist_]:=ArrayPlot[Transpose[Transpose[{ICAEvolveList[{Map[rulelist[[#]]&,ruleindices,{2}],r},init],Prepend[ruleindices,Table[1,Length[First[ruleindices]]]]},1<->3]],ColorRules->{{1,1}->Darker[Red,.7],{0,1}->Lighter[Red,.7],{1,2}->Darker[Blue,.7],{0,2}->Lighter[Blue,.7]}]
In[]:=
mutateRuleArray[ruleArray_,nRules_]:=Module[{raHeight,raWidth,i,j,val,newVal},{raHeight,raWidth}=Dimensions[ruleArray];i=RandomInteger[{1,raHeight}];j=RandomInteger[{1,raWidth}];val=ruleArray[[i,j]];newVal=Mod[val-1+RandomInteger[{1,nRules-1}],nRules]+1;ReplacePart[ruleArray,{i,j}->newVal]]
In[]:=
lossvalue[life_,tmax_]:=If[life-1>=tmax,Infinity,Abs[tmax-life+1]]
In[]:=
AdaptRuleArray[ruleArray_List,rules_List,nIters_Integer]:=With[{actrules=MapThread[Rule,{Range[Length[rules]],rules}]},NestList[Module[{m=mutateRuleArray[#[[1]],Length[rules]],lo},lo=lossvalue[RuleArrayLifetime[m/.actrules],Length[m]];If[lo<=#[[2]],{m,lo},#]]&,{ruleArray,Infinity},nIters]]
Note: this is just picking a “random different rule” (but it’s always flipping when there are only 2 rules):
In[]:=
localmutateRuleArray[ruleArray_,nRules_,{i_,j_}]:=Module[{raHeight,raWidth,val,newVal},{raHeight,raWidth}=Dimensions[ruleArray];val=ruleArray[[i,j]];newVal=Mod[val-1+RandomInteger[{1,nRules-1}],nRules]+1;ReplacePart[ruleArray,{i,j}->newVal]]
In[]:=
RuleArrayLifetime[RandomChoice[{184,232},{64,33}]]
Out[]=
3
In[]:=
RuleArrayLifetime[RandomChoice[{30,30},{64,33}]]
Out[]=
65
In[]:=
res=(SeedRandom[234234];AdaptRuleArray[Table[1,64,32],{184,232},10000]);
In[]:=
ListLinePlot[Last/@res]
Out[]=
2000
4000
6000
8000
10000
1
2
3
4
5
6
In[]:=
Labeled[ICAEvolvePlot[{First[#],1},CenterArray[1,32],{184,232}],Last[#]]&/@(First/@SplitBy[res,Last])
Out[]=
,
6
,
4
,
3
,
1
In[]:=
res=(SeedRandom[234234];AdaptRuleArray[Table[1,64,32],{4,146},10000]);
In[]:=
ListLinePlot[Last/@res]
Out[]=
2000
4000
6000
8000
10000
10
20
30
40
We want the case where we look at all steps, not just advancement steps

Sensitivity Analysis

The isolated dots later on give infinite losses... (the “gatekeepers of percolation”)

Rule Pairs

A contracter and an expander

Tasks to Try

Reversing bits

Coalescing to a blob of bits

Doubling the number of bits

(Pinned to the left)
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.