diff options
author | henriquelalves <henriquelalves@gmail.com> | 2024-05-26 14:39:55 +0300 |
---|---|---|
committer | henriquelalves <henriquelalves@gmail.com> | 2024-05-26 14:39:55 +0300 |
commit | 56a3d75bbbd80512f76817a05eebaabdcaf37ae2 (patch) | |
tree | f6e3b87c484ebe3df51d6e43d9e76b4ded9efb01 /scripts/gol.scm | |
parent | 0a89a84956311f17648bb443e429dab25d35f0cc (diff) | |
download | gamejam-slgj-2024-56a3d75bbbd80512f76817a05eebaabdcaf37ae2.tar.gz gamejam-slgj-2024-56a3d75bbbd80512f76817a05eebaabdcaf37ae2.tar.bz2 gamejam-slgj-2024-56a3d75bbbd80512f76817a05eebaabdcaf37ae2.zip |
Update for SLGJ 2024
Diffstat (limited to 'scripts/gol.scm')
-rw-r--r-- | scripts/gol.scm | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/scripts/gol.scm b/scripts/gol.scm index 7e10d2d..e0732a6 100644 --- a/scripts/gol.scm +++ b/scripts/gol.scm @@ -3,12 +3,6 @@ (define neighbors '((-1 . -1) (0 . -1) (1 . -1) (-1 . 0) (1 . 0) (-1 . 1) (0 . 1) (1 . 1))) -(set! (current-cells '(1 . 1)) #t) -(set! (current-cells '(2 . 1)) #t) -(set! (current-cells '(3 . 1)) #t) -(set! (current-cells '(3 . 0)) #t) -(set! (current-cells '(2 . -1)) #t) - (define sum-cells (lambda (c1 c2) (cons (+ (car c1) (car c2)) (+ (cdr c1) (cdr c2))))) @@ -37,8 +31,10 @@ (define list-neighbors (lambda (c) (map (lambda (n) - (sum-cells c n)) - neighbors))) + (sum-cells c n) + ) + neighbors) + )) (define sum-live-cells (lambda (lat n) @@ -76,3 +72,26 @@ ) ) ) + +(define (clear-cells) + (set! current-cells (make-hash-table)) + ) + +(define (toggle-cell c) + (if (current-cells c) + (set! (current-cells c) #f) + (set! (current-cells c) #t) + ) + ) + +(define (set-cells-array arr) + (map (lambda (c) + (set! (current-cells c) #t) + ) + arr + ) + ) + +(define (get-cells-list) + (hash-table-keys current-cells) + ) |