001 #include <hcell/hcell.h>
002 #include <iostream>
003 using namespace std;
004
005
006 int main()
007 {
008 CArule1d rule1(1,18);
009 Lattice lat(50);
010 r250init(1234);
011 lat.PreciseSeed(0.5);
012 for(int j=1; j<20 ; j++)
013 {
014 Evolve(&lat, rule1,1 );
015 lat.Print();
016 }
017 return 0;
018 }
In the above program, in line 8 we construct an object of CArule1d type, which is a one-dimensional
cellular automaton rule of radius 1 and rule number 18. Line 9 constructs a lattice of 50 sites.
After initializing the pseudo-random generator in line 10, we construct random initial condition
such that exactly 50% of all sites are in state ``1'', while the remaining sites are in state ``0''.
The loop in lines 12-16 interates the rule 20 times and prints the lattice configuration each time.
The function Evolve(&lat, rule1,1) takes three arguments: the lattice, the rule, and the number
of iterations (1 in this example).