next up previous
Next: 19 座標系,空間の記述 Up: 18 積み木の問題 Previous: 18 積み木の問題

18.1 3つの積み木の場合の縦型・横型探索



(defun init-blockworld nil
  (setq s1 (instance blockworld-node
                    :init :name "s1"
                    :state
                    '((a on table) (b on table)
                      (c on table))))
  (setq s2 (instance blockworld-node
                    :init :name "s2"
                    :state
                    '((a on table) (b on c)
                      (c on table))))
  (setq s3 (instance blockworld-node
                    :init :name "s3"
                    :state
                    '((a on table) (b on a)
                      (c on table))))
  (setq s4 (instance blockworld-node
                    :init :name "s4"
                    :state
                    '((a on c) (b on table)
                      (c on table))))
  (setq s5 (instance blockworld-node
                    :init :name "s5"
                    :state
                    '((a on b) (b on table)
                      (c on table))))
  (setq s6 (instance blockworld-node
                    :init :name "s6"
                    :state
                    '((a on table) (b on table)
                      (c on b))))
  (setq s7 (instance blockworld-node
                    :init :name "s7"
                    :state
                    '((a on table) (b on table)
                      (c on a))))
  (setq s8 (instance blockworld-node
                    :init :name "s8"
                    :state
                    '((a on b) (b on c)
                      (c on table))))
  (setq s9 (instance blockworld-node
                    :init :name "s9"
                    :state
                    '((a on table) (b on a)
                      (c on b))))
  (setq s10 (instance blockworld-node
                    :init :name "s10"
                    :state
                    '((a on c) (b on a)
                      (c on table))))
  (setq s11 (instance blockworld-node
                    :init :name "s11"
                    :state
                    '((a on b) (b on table)
                      (c on a))))
  (setq s12 (instance blockworld-node
                    :init :name "s12"
                    :state
                    '((a on c) (b on table)
                      (c on b))))
  (setq s13 (instance blockworld-node
                    :init :name "s13"
                    :state
                    '((a on table) (b on c)
                      (c on a))))
  (setq *blockworld-graph*
        (instance
         graph
         :init
         :nodes
         (list
          s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13)
         ))
  
  (dolist (path
           (list (list s1 s2)
                 (list s1 s3)
                 (list s1 s4)
                 (list s1 s5)
                 (list s1 s6)
                 (list s1 s7)
                 (list s2 s8)
                 (list s2 s3)
                 (list s3 s9)
                 (list s4 s10)
                 (list s5 s11)
                 (list s6 s12)
                 (list s6 s7)
                 (list s7 s13)))
          (let ((n1 (car path))
                (n2 (cadr path)))
            (send n1  :add-neighbor n2)
            ))
  )

(defun blockworld-test nil
  (init-blockworld)
  (setq dp (send *blockworld-graph* :find-route
                 "s8" "s13" :depth-first))
  (setq bp (send *blockworld-graph* :find-route
                 "s8" "s13" :breadth-first))
  nil)

eus$ (blockworld-test)
route length from s8 to s13 is 6 in :depth-first method.
  route path is (s8 s2 s3 s1 s7 s13).
route length from s8 to s13 is 5 in :breadth-first method.
  route path is (s8 s2 s1 s7 s13).
nil


generated through LaTeX2HTML. M.Inaba 平成18年5月7日