Loading ...
Sorry, an error occurred while loading the content.

question about CLIPS

Expand Messages
  • Alberto Vera
    hello I copied this example of a book about CLIPS This program has blocks and the objective is to put the block C over the block E Does anybody know when it
    Message 1 of 3 , Sep 10, 2002
    • 0 Attachment

      hello
      I copied this example of a book about CLIPS
      This program has "blocks" and the objective is to put the block C over the block E
      Does anybody know when it stop? The objective is (objetivo (poner C)(encima-de E)) but i don't
      understand when it stop.
      Could you help me, please?

      Thanks a lot


      it's the program:

      //start
      (deftemplate objetivo(slot poner)(slot encima-de))
      (deffacts estado-inicial
         (pila A B C)
         (pila D E F)
         (objetivo (poner C)(encima-de E))
         (pila)
      )

      (defrule mover-directamente
         ?objetivo <-(objetivo (poner ?bloque1)(encima-de ?bloque2))
         ?pila-1 <- (pila ?bloque1 $?resto1)
         ?pila-2 <- (pila ?bloque2 $?resto2)
         =>
         (retract ?objetivo ?pila-1 ?pila-2)
         (assert (pila $?resto1))
         (assert (pila ?bloque1 ?bloque2 $?resto2))
         (printout t ?bloque1 " puesto encima de " ?bloque2 "." crlf)
      )

      (defrule poner-en-el-piso
         ?objetivo <- (objetivo (poner ?bloque1) (encima-de piso))
         ?pila-1 <-(pila ?bloque1 $?resto)
         =>
         (retract ?objetivo ?pila-1)
         (assert (pila ?bloque1))
         (assert (pila $?resto))
         (printout t ?bloque1 " puesto en el piso " crlf)
      )

      (defrule despejar-bloque-superior
         (objetivo (poner ?bloque1))
         (pila ?arriba $? ?bloque1 $?)
         =>
         (assert (objetivo (poner ?arriba)(encima-de piso)))
      )

      (defrule despejar-bloque-inferior
         (objetivo (encima-de ?bloque1))
         (pila ?arriba $? ?bloque1 $?)
         =>
         (assert (objetivo (poner ?arriba)(encima-de piso)))
      )
      //end


      Yahoo! Messenger
      Nueva versión: Webcam, voz, y mucho más ¡Gratis!
    • Serguei Mokhov
      ... From: Alberto Vera Sent: September 10, 2002 11:37 AM ... Which book exactly, if you don t mind me asking? ... When
      Message 2 of 3 , Sep 10, 2002
      • 0 Attachment
        ----- Original Message -----
        From: "Alberto Vera" <artificialintelligenceperu@...>
        Sent: September 10, 2002 11:37 AM

        > hello
        > I copied this example of a book about CLIPS

        Which book exactly, if you don't mind me asking?

        > This program has "blocks" and the objective is to put the block C over the block E
        > Does anybody know when it stop?

        When the objective is met. ;)

        > The objective is (objetivo (poner C)(encima-de E)) but i don't
        > understand when it stop.

        Did you try to run it? :)
        It stops when the facts base doesn't have facts that cause any of
        the rules to fire anymore, i.e. there are no more matched rules
        on the agenda. (If you don't know what I'm talking about, ask)

        In your case when the objective is gone, it stops.

        Here is the sample printout of with options (watch rules) and
        (watch facts) set. An ==> means a fact is added to a facts base,
        and an <== means, the fact is retracted from there. The rules
        are placed onto agenda when their left-hand-side (LHS) matches the facts in
        the facts base, the order they fire in (in case several rules
        matched at a time) is determined by rules' priorities and/or a
        conflict-resolution policy.

        CLIPS> (watch facts)
        CLIPS> (watch rules)
        CLIPS> (load blocks.clp)
        Defining deftemplate: objetivo
        Defining deffacts: estado-inicial
        Defining defrule: mover-directamente +j+j+j
        Defining defrule: poner-en-el-piso +j+j
        Defining defrule: despejar-bloque-superior =j+j
        Defining defrule: despejar-bloque-inferior =j+j
        TRUE
        CLIPS> (reset)
        ==> f-0 (initial-fact)
        ==> f-1 (pila A B C)
        ==> f-2 (pila D E F)
        ==> f-3 (objetivo (poner C) (encima-de E))
        ==> f-4 (pila)
        CLIPS> (run)
        FIRE 1 despejar-bloque-superior: f-3,f-1
        ==> f-5 (objetivo (poner A) (encima-de piso))
        FIRE 2 poner-en-el-piso: f-5,f-1
        <== f-5 (objetivo (poner A) (encima-de piso))
        <== f-1 (pila A B C)
        ==> f-6 (pila A)
        ==> f-7 (pila B C)
        A puesto en el piso
        FIRE 3 despejar-bloque-superior: f-3,f-7
        ==> f-8 (objetivo (poner B) (encima-de piso))
        FIRE 4 poner-en-el-piso: f-8,f-7
        <== f-8 (objetivo (poner B) (encima-de piso))
        <== f-7 (pila B C)
        ==> f-9 (pila B)
        ==> f-10 (pila C)
        B puesto en el piso
        FIRE 5 despejar-bloque-inferior: f-3,f-2
        ==> f-11 (objetivo (poner D) (encima-de piso))
        FIRE 6 poner-en-el-piso: f-11,f-2
        <== f-11 (objetivo (poner D) (encima-de piso))
        <== f-2 (pila D E F)
        ==> f-12 (pila D)
        ==> f-13 (pila E F)
        D puesto en el piso
        FIRE 7 mover-directamente: f-3,f-10,f-13
        <== f-3 (objetivo (poner C) (encima-de E))
        <== f-10 (pila C)
        <== f-13 (pila E F)
        ==> f-14 (pila C E F)
        C puesto encima de E.
        CLIPS> (facts)
        f-0 (initial-fact)
        f-4 (pila)
        f-6 (pila A)
        f-9 (pila B)
        f-12 (pila D)
        f-14 (pila C E F)
        For a total of 6 facts.
        CLIPS>
      • Alberto Vera
        Thank you very much for your help. The book s title in Spanish is: Sistemas Expertos. Principios y Programacion I hope this title in English might be: Expert
        Message 3 of 3 , Sep 11, 2002
        • 0 Attachment

          Thank you very much for your help.

          The book's title in Spanish is: Sistemas Expertos. Principios y Programacion

          I hope this title in English might be: Expert Systems. Principles and Programming

          Author: Joseph Giarratano and Gary Riley

          Third Edition

           it was published in English by PWS Publishing Company and its ISBN: 0-534-95053-1

          Best Regards

            Serguei Mokhov <mokhov@...> escribió:

          ----- Original Message -----
          From: "Alberto Vera" <artificialintelligenceperu@...>
          Sent: September 10, 2002 11:37 AM

          > hello
          > I copied this example of a book about CLIPS

          Which book exactly, if you don't mind me asking?


          Yahoo! Messenger
          Nueva versión: Webcam, voz, y mucho más ¡Gratis!

        Your message has been successfully submitted and would be delivered to recipients shortly.