 |
Reinforcement Learning and
Artificial
Intelligence (RLAI)
|
tiny-crystal project part 4: virtual connections
|
Implement the basic virtual connection making names virtually-connect
and virtually-connect-from
. Implement these as scheme procedures that are called from the lookup
procedure you wrote in part 2. Brief descriptions of the
function of virtually-connect
can be found on page 3 of the
crystal vocabulary notes, and virtually-connect-from
is the same except that the starting vertex is specified, as in connect-from
. Remember that here in tiny crystal we are
using the fixed-length forms, as in:
(virtually-connect '(sum of squares ? x y)
'(+ (square (x))
(square (y))))
and
(
virtually-
connect-from (my-utilities) '(square ? x)
'(* (x) (x)))
You may want to also implement the short forms vconn
and vconn-from
.
Hints:
Convert virtually-
connect
s to virtually-
connect-from
s to that you only need to implement one of them.
Package the virtual part of a virtual connection up into a special kind of nonterminal vertex called a stub.
A stub is like the procedure structure ('procedure params body
environment) in the Q&D scheme interpreter in that it bundles
all of the information needed to execute at a later time when
the arguments or labels are available. In the crystal case we need to
bundle the name that will be called at the later time, the names of the
labels it uses (formal parameters), and the path in which the virtual
connection was made and should be called. The only thing missing,
to be provided when the vertex is accessed, is the actual labels when
the connection is realized. When these become available they can
be popped on the path and then the name called with respect to the extended path.
#|
testing - see main spec page
|#
Changes since Nov 15:
The text was corrected to indicate that stub vertices are nonterminal, not terminal.
You may be able to implement these crystal primitives just like the other scheme primitives, like + or display
. This is permitted.
It would be better if virtually-connect returned the stub vertex. Then
it could be used like a lambda. For example, (virtually-connect '(? x
y) (+ (x) (y))) would return the unnamed stub vertex that takes in two
numbers and returns their sum.