Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tutorials:beginner:designators [2016/01/22 15:45] – [Creating an action designator] gkazhoya | tutorials:beginner:designators [2016/03/04 14:09] – gkazhoya | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Creating action designators for the turtlesim | + | ====== Creating action designators for the TurtleSim |
**Description: | **Description: | ||
Line 22: | Line 22: | ||
<code lisp> | <code lisp> | ||
- | (defparameter spy-location (make-designator | + | (defparameter spy-location (make-designator |
</ | </ | ||
Line 80: | Line 80: | ||
<code lisp> | <code lisp> | ||
- | TUT> (defparameter my-desig (make-designator | + | TUT> (defparameter my-desig (make-designator |
MY-DESIG | MY-DESIG | ||
TUT> (desig-prop-value my-desig :radius) | TUT> (desig-prop-value my-desig :radius) | ||
Line 129: | Line 129: | ||
(desig-prop ?desig (:shape :square)) | (desig-prop ?desig (:shape :square)) | ||
(desig-prop ?desig (:radius ?radius)) | (desig-prop ?desig (:radius ?radius)) | ||
- | (lisp-fun make-turtle-shape :radius ?radius :edges 4 ?action)) | + | (lisp-fun make-turtle-shape :radius ?radius :edges 4 ?action)) |
;; pentagon | ;; pentagon | ||
Line 136: | Line 136: | ||
(desig-prop ?desig (:shape :pentagon)) | (desig-prop ?desig (:shape :pentagon)) | ||
(desig-prop ?desig (:radius ?radius)) | (desig-prop ?desig (:radius ?radius)) | ||
- | (lisp-fun make-turtle-shape :radius ?radius :edges 5 ?action)) | + | (lisp-fun make-turtle-shape :radius ?radius :edges 5 ?action)) |
;; hexagon | ;; hexagon | ||
Line 143: | Line 143: | ||
(desig-prop ?desig (:shape :hexagon)) | (desig-prop ?desig (:shape :hexagon)) | ||
(desig-prop ?desig (:radius ?radius)) | (desig-prop ?desig (:radius ?radius)) | ||
- | (lisp-fun make-turtle-shape :radius ?radius :edges 6 ?action))) | + | (lisp-fun make-turtle-shape :radius ?radius :edges 6 ?action))) |
</ | </ | ||
Line 175: | Line 175: | ||
Prolog' | Prolog' | ||
- | For the example rule we've selected, Prolog looks at the designator and asks "does it contain a key-value pair that is (:type : | + | For the example rule we've selected, Prolog looks at the designator and asks "does it contain a key-value pair that is '' |
+ | |||
+ | If all of the above body rules are true (or can be executed sucessfully) then the head is itself evaluated, and what it does is glue the newly created ''? | ||
- | If all of the above body rules are true (or can be executed sucessfully) then the head is itself run, and what it does is glue the newly created ?action, the object containing the concrete values, to the designator ?desig. Or in more concrete terms, it defines what the value of the action-desig predicate is if applied to ? | + | If in any step of the inference Prolog stumbles upon '' |
- | For this tutorial, the inference is very simple: in fact, it is just a conditional switch based on the shape parameter which translates a name like ' | + | For this tutorial, the inference is very simple: in fact, it is just a conditional switch based on the shape parameter which translates a name like '' |
- | Reload the tutorial package in roslisp_repl. This will also load the newly defined inference rules. | + | Reload the tutorial package in '' |
- | Let's try to create, then reference a designator in the repl command line again: | + | Let's try to create, then reference a designator in the REPL command line again: |
<code lisp> | <code lisp> | ||
- | TUT> (defparameter | + | TUT> (defparameter |
- | MYDESIG | + | MY-DESIG-2 |
- | TUT> (reference | + | TUT> (reference |
- | (SHAPE # | + | (DRAW-SHAPE # |
</ | </ | ||