Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a blocksworld problem written in clips that must take a stack of blocks and rearrange it into a goal-stack of blocks. You will

I have a blocksworld problem written in clips that must take a "stack" of blocks and rearrange it into a "goal-stack" of blocks.

You will be given an initial configuration of blocks and a goal configuration. the solution should consist solely of defrules. It should behave like this.

CLIPS> (load newblocks.CLP)

[ stuff that shows things being loaded ] CLIPS> (reset) CLIPS> (assert (stack A B C) (stack D E F) (goal-stack D C B) (goal-stack A) (goal-stack F E)) CLIPS> (run) A moved on top of floor. B moved on top of floor. C moved on top of B. D moved on top of C. E moved on top of floor. F moved on top of E. CLIPS> (reset) CLIPS> (assert (stack A B C D E F) (goal-stack A B C D E F)) CLIPS> (run) CLIPS> (reset) CLIPS> (assert (stack A B C) (goal-stack A B) (goal-stack C)) CLIPS> (run) A moved on top of floor. B moved on top of floor. A moved on top of B. CLIPS>

(assert (stack A B C D E F G H I) (stack J K L M N O P Q R) (stack S T U V W X Y Z) (goal-stack I Q A R H) (goal-stack B X U S) (goal-stack T J Y Z C) (goal-stack D K W L) (goal-stack M G E P N) (goal-stack O F V))

/**************************************/

This is my code so far:

(defrule move-correct (declare (salience 11)) ?stack -> ?stack2 -> (goal-stack ?block ?block2 $?goal-bottom) => (retract ?stack ?stack2) (assert (stack ?block ?block2 ?bottom2)) (assert (stack $?bottom)) (printout t ?block " moved on top of " ?block2 crlf))

(defrule move-to-floor ?stack -> (goal-stack $?stuff ?goal-block $?stuff2) => (retract ?stack) (assert (stack ?top)) (assert (stack $?other ?goal-block $?bottom)) (printout t ?top " moved on top of floor" crlf))

Mine does not recognize that it needs to perform certain moves in order so I have this:

CLIPS> (assert (stack A B C) (goal-stack C A B)) CLIPS> (run) A moved on top of floor B moved on top of floor C moved on top of A CLIPS>

Which leaves my stacks like this: (stack B) (stack C A) so it clearly should have put "A on top of B" before "C on top of A"

How can I get it to recognize the highest priority. Our instructor told us that the solution was 2 rules and these were the names, so I know I'm close.

Thanks for the help!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

What is the shape of the exponential distribution?

Answered: 1 week ago