From: Siraaj Khandkar Date: Sun, 26 Aug 2012 04:21:18 +0000 (-0400) Subject: Why did I think I needed this again? X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=7b9dc10be1a563669998cb12fdcebb84f0f57a00;p=cellular-automata.git Why did I think I needed this again? --- diff --git a/004/life.awk b/004/life.awk index 5116adc..714f209 100755 --- a/004/life.awk +++ b/004/life.awk @@ -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 = "";