next up previous
Next: 11.4 goal-searchの定義 Up: 11 積木問題の状態空間の生成 Previous: 11.2 node-equalの定義

11.3 next-statesの定義

以上の手続きを組み合わせることで,現在の状態を与えると,可能な次の 状態を作り出す手続きnext-blocks-statesを考える.
> s
((a on table) (b on c) (c on table) (d on a))

> (next-blocks-states s)
(((b on table) (a on table) (c on table) (d on a))
 ((b on d) (a on table) (c on table) (d on a))
 ((d on table) (a on table) (b on c) (c on table))
 ((d on b) (a on table) (b on c) (c on table)))

> (next-blocks-states
       '((a on table) (b on c) (c on table)))
(((a on b) (b on c) (c on table))
 ((b on table) (a on table) (c on table))
 ((b on a) (a on table) (c on table)))

> (next-blocks-states
    '((a on table) (b on c) (c on table) (d on a)))
(((b on table) (a on table) (c on table) (d on a))
 ((b on d) (a on table) (c on table) (d on a))
 ((d on table) (a on table) (b on c) (c on table))
 ((d on b) (a on table) (b on c) (c on table)))
(defun next-blocks-states 
  (state)
  (let ((top-free
         (top-free-blocks state)))
        (node-remove
         state
         (mapcan
          #'(lambda (free-block)
              (possible-states
               free-block
               state
               (cons 'table
                     (remove free-block top-free))))
          top-free)))))

(defun next-states (state)
   (next-blocks-states state))


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