The nanoScheme language includes also a reduced set of bio-inspired primitives. They have
been designed in the same spirit of Tom Ray’s Tierran assembly language (Ray, 1991). That
is, the production of synthetic organisms based on a computer metaphor of organic life in
which CPU time is the “energy'” resource and memory is the “material” resource. This set
includes the following functions:
create – create a new execution environment.
reproduce - create a new nano-agent in the local environment.
terminate - kill the current nano-agent.
diffuse - diffuse a message to other nano-agents in the local environment.
send – send a message to a distant execution environment.
rule - define a behavior rule consisting of condition, action and priority
expressions.
engine - make an inference loop on a behavior rule base.
crossover - genetic programming crossover operator.
mutate - genetic programming mutate operator and random code generator.
random - return a random real number.
time - return the current real time.
stress - return a “stress” value based on the current available memory and
computing resources.
plugin - dynamically load a new package of dedicated primitive functions.
message – hook function invoked when the nano-agent receives a message.
l ifepulse - hook function for implementing periodic behaviors.
Since all code, behavior rules, and messages are basically S-expressions (i.e. lisp
expressions), the use of genetic programming is natural in this environment (Koza, 1992). As
an example, the next code illustrates the use of the mutate primitive:
(mutate '(/ y 2) '((+ 2) (- 2)) ' ( 2 3) 3) (/ y (+ (- 2)))
|
|
The mutate function applies a mutation on a Scheme program expression (first argument). It
creates a randomly generated program with a maximum depth (last argument). Functions
and terminals are randomly chosen in two lists (arguments 2 and 3). The generated program
replaces a randomly chosen “node site” in the expression. If the first argument is the empty
list, then the mutate operator returns a new random expression.
Note that the remote execution of code on distant nano-agents is a natural feature of the
nanoScheme language by simply diffusing or sending messages containing S-expressions.
These expressions are then evaluated by all nano-agents. This approach enables an easy
implementation of distributed algorithms on nano-agents.