-- try to solve the monkey banana problem -- it has no intelligence, just random selection of operators |null> => set-up-initial-state |> the |locations> => at rel-kets[at] |> the |objects> => rel-kets[at] |> apply-go |*> #=> move |to> => pick-elt drop (the |locations> - at |monkey>) previously-at |monkey> => at |monkey> the |result> => go(at |monkey>, move |to>) process if(has-prefix["monkey moved "] the |result>, |go worked>, |go failed>) process |go worked> #=> the |plan> .=> |go(> _ previously-at |monkey> _ |, > _ move |to> _ |)> the |result> process |go failed> #=> the |result> apply-push |*> #=> push |object> => pick-elt drop (the |objects> - |monkey>) previously-at |monkey> => at |monkey> move |to> => pick-elt drop (the |locations> - at |monkey>) the |result> => push(push |object>, at |monkey>, move |to>) process if(has-prefix["monkey pushed "] the |result>, |push worked>, |push failed>) process |push worked> #=> the |plan> .=> |push(> _ push |object> _ |, > _ previously-at |monkey> _ |, > _ move |to> _|)> the |result> process |push failed> #=> the |result> apply-climb-on |*> #=> climb |object> => pick-elt drop (the |objects> - |monkey>) the |result> => climb-on(climb |object>) process if(has-prefix["monkey climbed "] the |result>, |climb-on worked>, |climb-on failed>) process |climb-on worked> #=> the |plan> .=> |climb-on(> _ climb |object> _ |)> the |result> process |climb-on failed> #=> the |result> apply-grab |*> #=> the-grab |object> => pick-elt drop (the |objects> - |monkey>) the |result> => grab(the-grab |object>) process if(has-prefix["monkey grabbed "] the |result>, |grab worked>, |grab failed>) process |grab worked> #=> the |plan> .=> |grab(> _ the-grab |object> _ |)> the |result> process |grab failed> #=> the |result> the-list-of |operators> => |op: apply-go> + |op: apply-push> + |op: apply-climb-on> + |op: apply-grab> not |yes> => |no> not |no> => |yes> drop-null |null> #=> |> drop-null |*> #=> |_self> reset |*> #=> the-list-of |operators> => |op: apply-go> + |op: apply-push> + |op: apply-climb-on> + |op: apply-grab> the-list-of |used operators> => |null> the-list-of |tried operators> => |null> the |plan> => |null> set-up-initial-state find-plan |*> #=> the |plan length> => show-many the |plan> the |operator> => pick-elt drop (the-list-of |operators> - the-list-of |used operators> - the-list-of |tried operators>) apply(the |operator>, |>) added-to-the |plan> => not is-equal(show-many the |plan>, the |plan length>) process if(added-to-the |plan>, |added to plan>, |didn't add to plan>) process |added to plan> #=> the-list-of |tried operators> => |null> the-list-of |used operators> +=> the |operator> process if(has-prefix["reached goal "] test-for-goal-state |>, |finished>, |not finished>) process |didn't add to plan> #=> the-list-of |tried operators> +=> the |operator> remaining-operator |count> => how-many drop (the-list-of |operators> - the-list-of |used operators> - the-list-of |tried operators>) process if(is-equal[0] remaining-operator |count>, |don't have remaining operators>, |have remaining operators>) process |don't have remaining operators> #=> print |here is the failed plan:> print smerge[" "] sdrop drop-null the |plan> print print |here are the tried operators:> print smerge[", "] sp2seq extract-value drop-null the-list-of |tried operators> process |have remaining operators> #=> find-plan process |finished> #=> print |here is the plan:> print smerge[" "] sdrop drop-null the |plan> the |final plan> => sdrop drop-null the |plan> is |finished> => |yes> process |not finished> #=> find-plan find-plan-wrapper |*> #=> process if(is |finished>, |wrapper finished>, |wrapper not finished>) process |wrapper finished> #=> |> process |wrapper not finished> #=> reset find-plan print |------------------------> max |attempts> => |100> find-final-plan |*> #=> is |finished> => |no> find-plan-wrapper range(|1>, max |attempts>) print print |Here is our plan:> smerge[" "] the |final plan>