-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaze-ops.lisp
36 lines (32 loc) · 1.19 KB
/
maze-ops.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;;; THIS FILE AUTOGENERATED
;;; It has a dependency on #'mappend
(defun make-maze-op (here there)
"Make an operator to move between two places."
(op `(move from ,here to ,there)
:preconds `((at ,here))
:add-list `((at ,there))
:del-list `((at ,here))))
(defun make-maze-ops (pair)
"Make maze ops in both directions."
(list (make-maze-op (first pair) (second pair))
(make-maze-op (second pair) (first pair))))
(defparameter *maze-ops*
(mapcar #'convert-op
(mappend
#'make-maze-ops
'((1 2) (2 3) (3 4) (4 9) (9 14) (9 8) (8 7) (7 12) (12 13)
(12 11) (11 6) (11 16) (16 17) (17 22) (21 22) (22 23)
(23 18) (23 24) (24 19) (19 20) (20 15) (15 10) (10 5) (20 25)))))
(defun find-path (start end)
"Search a maze for a path from start to end."
(let ((results (gps `((at ,start))
`((at ,end)))))
(unless (null results)
(cons start
(mapcar #'destination
(remove '(start)
results
:test #'equal))))))
(defun destination (action)
"Find the Y in '(executing (move from X to Y))"
(fifth (second action)))