summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-07-08 05:13:25 +0000
committerrsiddharth <s@ricketyspace.net>2018-07-08 05:13:25 +0000
commita8528ce04a4e9a33a1095c9ed087d809e2fc668a (patch)
treed77ae2daa540c45d5090129d3df09c246c1a92f9
parent7e50ad75ebf7b9d9046a4f0a00b8e3f05b9c82ba (diff)
net: snakes.rkt: Fix snake-colliding?
* net/ricketyspace/ror/six/snakes.rkt (snake-colliding?): Update function.
-rw-r--r--net/ricketyspace/ror/six/snakes.rkt6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/ricketyspace/ror/six/snakes.rkt b/net/ricketyspace/ror/six/snakes.rkt
index e76e5df..dae3468 100644
--- a/net/ricketyspace/ror/six/snakes.rkt
+++ b/net/ricketyspace/ror/six/snakes.rkt
@@ -338,7 +338,11 @@
[else (obstacle-colliding? snake (rest obstacles))]))
(define (snake-colliding? snake snake-other)
- (cons? (member (snake-head snake) (snake-segs snake-other))))
+ (define (head-in-other sn other)
+ (cond [(empty? other) #f]
+ [(posn=? sn (first other)) #t]
+ [else (head-in-other sn (rest other))]))
+ (head-in-other (snake-head snake) (snake-segs snake-other)))
;; aux
(define (posn=? p1 p2)