chiark / gitweb /
Comments, licensing, etc
[bedbugs.git] / src / make-ruletable.cpp
index 3ef66147ade87e8078746dfa87f5b0f25538e10f..805e5b7ac463c23cda27182b13d040032f876480 100644 (file)
@@ -1,5 +1,8 @@
                         /*** /
 
+[This file is part of Bedbugs. All I've done is made it implement
+the Conway transition function. Original copyright notice follows:]
+
 This file is part of Golly, a Game of Life Simulator.
 Copyright (C) 2008 Andrew Trevorrow and Tomas Rokicki.
 
@@ -103,18 +106,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 +653,15 @@ 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;
+   // Bedbugs: FIXME: output would probably be more efficient if we used
+   // this, but also complicated
+   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";
+   // Bedbugs: we need these because they will be munged into real
+   // transitions:
+   const bool remove_stasis_transitions = false;
 
    vector<rule> rules;
    time_t t1,t2;