Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (: enemy-adj-pawns : Board Player Loc -> (Listof Loc))
- (define (enemy-adj-pawns b p l)
- (local
- {(define opp-player (switch-player p))
- (: with-bounds : (Listof Integer) -> (Listof Loc))
- (define (with-bounds c-dirs)
- (match* (c-dirs l p)
- [('() _ _) '()]
- [((cons hd tl) (Loc row col) 'Black)
- (match (board-ref b (Loc row (+ col hd)))
- [(Some (Piece 'Pawn 'White))
- (cons (Loc row (+ col hd)) (with-bounds tl))]
- [_ (with-bounds tl)])]
- [((cons hd tl) (Loc row col) 'White)
- (match (board-ref b (Loc row (+ col hd)))
- [(Some (Piece 'Pawn 'Black))
- (cons (Loc row (+ col hd)) (with-bounds tl))]
- [_ (with-bounds tl)])]))}
- (cond
- [(zero? (Loc-col l)) (with-bounds (list 1))]
- [(= (sub1 (length (list-ref b 0))) (Loc-col l)) (with-bounds (list -1))]
- [else (with-bounds (list -1 1))])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement