Why did I think I needed this again?
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 26 Aug 2012 04:21:18 +0000 (00:21 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 26 Aug 2012 04:21:18 +0000 (00:21 -0400)
004/life.awk

index 5116adc..714f209 100755 (executable)
@@ -69,24 +69,15 @@ function new_state(state, live_neighbors) {
 }
 
 
-function ensure_negative(n) {
-    if (n < 0) {
-        return n
-    } else {
-        return -n
-    }
-}
-
-
 function new_generation(x, n, board) {
-    offsets["N" ] = ensure_negative(x    );
-    offsets["NE"] = ensure_negative(x - 1);
-    offsets["E" ] =                     1 ;
-    offsets["SE"] =                 x + 1 ;
-    offsets["S" ] =                 x     ;
-    offsets["SW"] =                 x - 1 ;
-    offsets["W" ] =                   - 1 ;
-    offsets["NW"] = ensure_negative(x + 1);
+    offsets["N" ] =  - x     ;
+    offsets["NE"] =  -(x - 1);
+    offsets["E" ] =        1 ;
+    offsets["SE"] =    x + 1 ;
+    offsets["S" ] =    x     ;
+    offsets["SW"] =    x - 1 ;
+    offsets["W" ] =      - 1 ;
+    offsets["NW"] =  -(x + 1);
 
     new_board = "";
 
This page took 0.029619 seconds and 4 git commands to generate.