chiark / gitweb /
Initial just-about-works completely shonky version
[bedbugs.git] / src / make-ruletable.cpp
index 3ef66147ade87e8078746dfa87f5b0f25538e10f..3c7c52b84a7c79867c77a3b4a3617d55945d51ca 100644 (file)
@@ -103,18 +103,22 @@ static const string symmetry_strings[] = {"none","rotate4","rotate8","reflect","
 // (for von Neumann neighbourhoods, just ignore the nw,se,sw,ne inputs)
 state slowcalc(state nw,state n,state ne,state w,state c,state e,state sw,state s,state se)
 {
-   // wireworld:
+   int neighbours = nw+n+ne+e+se+s+sw+w;
+   // Conway:
    switch (c) 
    {
-     case 0: return 0 ;
-     case 1: return 2 ;
-     case 2: return 3 ;
-     case 3:
-        if ((((1+(nw==1)+(n==1)+(ne==1)+(w==1)+(e==1)+(sw==1)+
-           (s==1)+(se==1))) | 1) == 3)
-           return 1 ;
-        else
-           return 3 ;
+     case 0:
+        if (neighbours == 3) {
+            return 1;
+        } else {
+            return 0;
+        }
+     case 1:
+        if (neighbours == 2 || neighbours == 3) {
+            return 1;
+        } else {
+            return 0;
+        }
      default:
         return 0 ; // should throw an error here
    }
@@ -646,11 +650,11 @@ bool is_correct(const vector<rule>&rules,int N,int neighbourhood_size)
 int main()
 {
    // parameters for use:
-   const int N_STATES = 4;
-   const TSymm symmetry = rotate8;
+   const int N_STATES = 2;
+   const TSymm symmetry = none;
    const int nhood_size = 9;
-   const string output_filename = "wireworld.table";
-   const bool remove_stasis_transitions = true;
+   const string output_filename = "life.table";
+   const bool remove_stasis_transitions = false;
 
    vector<rule> rules;
    time_t t1,t2;