home
/
code
/
cellular-automata.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
11f0def
)
Why did I think I needed this again?
author
Siraaj Khandkar
<siraaj@khandkar.net>
Sun, 26 Aug 2012 04:21:18 +0000
(
00:21
-0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Sun, 26 Aug 2012 04:21:18 +0000
(
00:21
-0400)
004/life.awk
patch
|
blob
|
blame
|
history
diff --git
a/004/life.awk
b/004/life.awk
index
5116adc
..
714f209
100755
(executable)
--- 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) {
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 = "";
new_board = "";
This page took
0.018692 seconds
and
4
git commands to generate.