i=0;evolved=Module[{depth=depthSetting,cut=12,initRule=31(*RandomInteger[{0,Integer[]}]*)(*0*),initCond={{1}},ru,fitness,data},SeedRandom[1];evo=NestList[CompoundExpression[(*Incrementthecounter:*)i++,(*Mutatetheruleinputasthefirstargument:*)ru=mutateRule[First[#]],(*TeststhefitnessoftheCAuptothenumberofstepsdefinedbycut:*)fitness=testFitness[ru,cut,initCond],If[fitness<=Last[#],{ru,fitness},#]]&,{{initRule,2,{1,1}},∞},depth];evo=Rest[First/@SplitBy[evo,Last]];Map[CompoundExpression[data=CellularAutomaton[First[#],{initCond,0},{{{cut}}}],ArrayPlot[data,ColorRules->{0White,1Black},ImageSize->{Automatic,26Sqrt[Length[data]+1]},Mesh->True,MeshStyle->Opacity[.1]]]&,evo]];%//If[Length[#]>0,ListAnimate[#],#]&