diff --git a/csys.lisp b/asys.lisp similarity index 69% rename from csys.lisp rename to asys.lisp index 7db5d52..6590d96 100644 --- a/csys.lisp +++ b/asys.lisp @@ -1,15 +1,15 @@ -;;;; decons/csys - cybernetic communication systems +;;;; decons/asys - asynchronous actor systems -(defpackage :decons/csys +(defpackage :decons/asys (:use :common-lisp) (:local-nicknames (:actor :scopes/core/actor) (:util :scopes/util)) (:export #:neuron #:synapse - #:forward + #:forward #:cumulate #:set-content #:inhibit)) -(in-package :decons/csys) +(in-package :decons/asys) (defun neuron (proc &key state syns env) (actor:create @@ -22,9 +22,16 @@ ;;;; simple default / example neuron processors (defun forward (msg state syns env) + (format t "*** forward ~a ~a~%" msg state) (dolist (s syns) (funcall s msg))) +(defun cumulate (msg state syns env) + (setf state (+ state msg)) + (if (/= 0 state) + (forward state state syns env)) + (lambda (msg) (cumulate msg state syns env))) + ;;;; publish/subscribe - pubsub service ;;;; helpers for operations on complex messages (with content and customer slots) diff --git a/decons.asd b/decons.asd index 918212c..b1d4627 100644 --- a/decons.asd +++ b/decons.asd @@ -5,10 +5,10 @@ :license "MIT" :version "0.0.1" :homepage "https://www.cyberconcepts.org" - :description "Deconstruction as a method for implementing machine intelligence." + :description "Deconstruction as a method for implementing machine un-intelligence." :depends-on (:alexandria :scopes-core :scopes/test) - :components ((:file "csys" :depends-on ("mlx")) + :components ((:file "asys" :depends-on ("mlx")) (:file "mlx" :depends-on ("recurse")) (:file "recurse") (:file "xplore")) @@ -18,6 +18,6 @@ (defsystem :decons/test :depends-on (:decons) :components ((:file "test-decons") - (:file "test-csys" :depends-on ("test-decons"))) + (:file "test-asys" :depends-on ("test-decons"))) :perform (test-op (o c) (symbol-call :decons/test-decons :run))) diff --git a/test-asys.lisp b/test-asys.lisp new file mode 100644 index 0000000..7c89886 --- /dev/null +++ b/test-asys.lisp @@ -0,0 +1,33 @@ +;;;; decons/test-asys - tests for the asys (asynchronous actor systems) package + +(in-package :decons/test-decons) + +(defun probe (msg state syns env) + (let ((t:*test-suite* env)) + (== (actor:content msg) (pop state)) + (lambda (msg) (probe msg state syns env)) + )) + +(defun test-asys () + (async:init) + (test-neuron-basics) + (async:finish)) + +(deftest test-neuron-basics () + (let* ((prb (asys:neuron #'probe :env t:*test-suite* :state '(43 44 9 13))) + ;(syn (asys:synapse prb (asys:set-content #'1+))) + (syn1 (asys:synapse prb #'1+)) + ;(syn (asys:synapse prb (asys:inhibit))) + (fw (asys:neuron #'asys:forward :syns (list syn1))) + (syn2 (asys:synapse fw #'1+)) + (cum (asys:neuron #'asys:cumulate :state 0 :syns (list syn2)))) + (actor:send fw 42) + (actor:send fw 43) + (actor:send cum 7) + (actor:send cum 4) + (sleep 0.1) + (actor:stop prb) + (actor:stop fw) + (actor:stop cum) + (sleep 0.1) + )) diff --git a/test-csys.lisp b/test-csys.lisp deleted file mode 100644 index a6fbc47..0000000 --- a/test-csys.lisp +++ /dev/null @@ -1,25 +0,0 @@ -;;;; decons/test-csys - tests for the csys (cybernetic ommunication systems) package - -(in-package :decons/test-decons) - -(defun probe (msg state syns env) - (let ((t:*test-suite* env)) - (== (actor:content msg) (pop state)) - (lambda (msg) (probe msg state syns env)) - )) - -(defun test-csys () - (test-neuron-basics)) - -(deftest test-neuron-basics () - (let* ((prb (csys:neuron #'probe :env t:*test-suite* :state '(43 44))) - ;(syn (csys:synapse prb (csys:set-content #'1+))) - (syn (csys:synapse prb #'1+)) - ;(syn (csys:synapse prb (csys:inhibit))) - (fw (csys:neuron #'csys:forward :syns (list syn)))) - (actor:send fw 42) - (actor:send fw 43) - (sleep 0.1) - (actor:stop prb) - (actor:stop fw) - )) diff --git a/test-decons.lisp b/test-decons.lisp index d509c08..ace4797 100644 --- a/test-decons.lisp +++ b/test-decons.lisp @@ -3,7 +3,8 @@ (defpackage :decons/test-decons (:use :common-lisp) (:local-nicknames (:actor :scopes/core/actor) - (:csys :decons/csys) + (:async :scopes/util/async) + (:asys :decons/asys) (:mlx :decons/mlx) (:r :decons/recurse) (:xplore :decons/xplore) @@ -19,7 +20,7 @@ (test-recursive) (test-line) (test-quad) - (test-csys) + (test-asys) (t:show-result))) (deftest test-xplore ()