From a8528ce04a4e9a33a1095c9ed087d809e2fc668a Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 8 Jul 2018 05:13:25 +0000 Subject: net: snakes.rkt: Fix snake-colliding? * net/ricketyspace/ror/six/snakes.rkt (snake-colliding?): Update function. --- net/ricketyspace/ror/six/snakes.rkt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3