-
Notifications
You must be signed in to change notification settings - Fork 11
Sensorimotor Interface
There are three central functions for interacting with OpenNARS v2.x.y defined in the narjure.sensorimotor namespace:
1. Narsese Input
nars-input-narsese allows entering a Narsese statement into the system as input task. More about the Narsese format can be read here: https://github.com/opennars/opennars/wiki/Input-Output-Format
2. Operator Registration
nars-register-operation allows to register a Clojure function which can be used by the system by calling an operation. Example:
(nars-register-operation 'op_up (fn [args operationgoal] (do (reset! direction 1) true))
Feedback: The last line indicates success, some operators might not work in all circumstances and the system will take this information into account.
Call: In order to call this operation, the system has to derive the operation goal <(*,{SELF}) --> ^op_up>!
The function will then be invoked with args='[* [ext-set SELF]]
and operationgoal being the operation goal itself (the operationgoal argument exists mainly for debugging purposes).
Additionally operators can depend on args, these are of the form
'[* arg1 arg2 ...]
Also there are abbrevations for operations that do not depend on arguments, allowing the system to have a simpler representation of the operation-goal. If the operator name starts with self_op
such as self_op_up
then it can be called directly by the goal self_op_up!
This is basically just an abbrevation of <(*,{SELF}) --> ^op_up>!
the system can deal with more effectively since it is structurally simpler.
2. Answer Handler
Some applications may communicate with NARS through Narsese and ask questions to the system.
In order to programmatically react to answers the system gives, there is a function called
nars-register-answer-handler in the sensorimotor interface.
Example:
(nars-register-answer-handler (fn [question answer] (println (str "the solution to " question " is " answer))))