csys/program/gene, work in progress: start with generic generative, genetic program
This commit is contained in:
parent
98cd349133
commit
5c02e8c19f
4 changed files with 42 additions and 5 deletions
|
|
@ -76,6 +76,7 @@
|
||||||
:default (csys:no-op :no-forward t)))
|
:default (csys:no-op :no-forward t)))
|
||||||
|
|
||||||
(defun cell-created (msg scope)
|
(defun cell-created (msg scope)
|
||||||
|
(util:lgw "debug" msg scope)
|
||||||
(let* ((data (shape:data msg))
|
(let* ((data (shape:data msg))
|
||||||
(addr (getf data :addr))
|
(addr (getf data :addr))
|
||||||
(new (getf data :new)))
|
(new (getf data :new)))
|
||||||
|
|
@ -99,10 +100,12 @@
|
||||||
(head (shape:head msg))
|
(head (shape:head msg))
|
||||||
(data (shape:data msg))
|
(data (shape:data msg))
|
||||||
(dom (car head))
|
(dom (car head))
|
||||||
|
(cat (getf data :cat))
|
||||||
(spc (getf (spaces scope) dom)))
|
(spc (getf (spaces scope) dom)))
|
||||||
(unless addr
|
(unless addr
|
||||||
(setf addr (gethash rcvr (cells scope))))
|
(setf addr (gethash rcvr (cells scope))))
|
||||||
(util:plist-add data :loc (car (space:free-loc-at spc (caddr addr))))
|
;(util:plist-add data :loc (car (space:free-loc-at spc (caddr addr))))
|
||||||
|
(util:plist-add data :addr (list dom cat (car (space:free-loc-at spc (caddr addr)))))
|
||||||
(csys:send-message rcvr head data))
|
(csys:send-message rcvr head data))
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
|
@ -118,7 +121,7 @@
|
||||||
(forward (message:create head :data data :customer cust) scope)
|
(forward (message:create head :data data :customer cust) scope)
|
||||||
(let ((rcvrs (find-cells-near scope tgt)))
|
(let ((rcvrs (find-cells-near scope tgt)))
|
||||||
(dolist (rcvr rcvrs)
|
(dolist (rcvr rcvrs)
|
||||||
(actor:send rcvr (message:create head :data data))))))
|
(csys:send-message rcvr head data)))))
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
;;;; public shortcuts
|
;;;; public shortcuts
|
||||||
|
|
@ -130,8 +133,8 @@
|
||||||
(let ((head (cons domain (cons :value cat-loc))))
|
(let ((head (cons domain (cons :value cat-loc))))
|
||||||
(send-message head `(:value ,val) :env env)))
|
(send-message head `(:value ,val) :env env)))
|
||||||
|
|
||||||
(defun send-create (rcvr &key (domain "csys:*domain*") (env *env*) cat connect op)
|
(defun send-create (rcvr &key (domain csys:*domain*) (env *env*) cat connect op)
|
||||||
(let ((head (cons domain :create))
|
(let ((head (list domain :create))
|
||||||
data)
|
data)
|
||||||
(when (listp rcvr)
|
(when (listp rcvr)
|
||||||
(setf head (append head (cdr rcvr)))
|
(setf head (append head (cdr rcvr)))
|
||||||
|
|
|
||||||
24
csys/program/gene.lisp
Normal file
24
csys/program/gene.lisp
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
;;;; cl-scopes/csys/program/gene - generative / genetic programs
|
||||||
|
|
||||||
|
(defpackage :scopes/csys/program/gene
|
||||||
|
(:use :common-lisp)
|
||||||
|
(:local-nicknames (:actor :scopes/core/actor)
|
||||||
|
(:csys :scopes/csys)
|
||||||
|
(:environ :scopes/csys/environ)
|
||||||
|
(:message :scopes/core/message)
|
||||||
|
(:util :scopes/util))
|
||||||
|
(:export #:prog-g0))
|
||||||
|
|
||||||
|
(in-package :scopes/csys/program/gene)
|
||||||
|
|
||||||
|
;;;; gene-0: zero-only network for explicit messages and interactive testing
|
||||||
|
|
||||||
|
(defun prog-g0 ()
|
||||||
|
(let ((val-action (csys:value-add)))
|
||||||
|
(csys:make-program
|
||||||
|
(list '(:c00 :initial) (csys:std-proc :value val-action)
|
||||||
|
'(:e00 :initial) (csys:eff-proc)
|
||||||
|
':default (csys:std-proc)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
:components ((:file "csys/csys")
|
:components ((:file "csys/csys")
|
||||||
(:file "csys/environ" :depends-on ("csys/csys" "csys/space"))
|
(:file "csys/environ" :depends-on ("csys/csys" "csys/space"))
|
||||||
(:file "csys/program/basic" :depends-on ("csys/csys" "csys/environ"))
|
(:file "csys/program/basic" :depends-on ("csys/csys" "csys/environ"))
|
||||||
|
(:file "csys/program/gene" :depends-on ("csys/csys" "csys/environ"))
|
||||||
(:file "csys/space"))
|
(:file "csys/space"))
|
||||||
:long-description "scopes/csys: Concurrent cybernetic communication systems."
|
:long-description "scopes/csys: Concurrent cybernetic communication systems."
|
||||||
:in-order-to ((test-op (test-op "scopes-csys/test"))))
|
:in-order-to ((test-op (test-op "scopes-csys/test"))))
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
(:csys :scopes/csys)
|
(:csys :scopes/csys)
|
||||||
(:environ :scopes/csys/environ)
|
(:environ :scopes/csys/environ)
|
||||||
|
(:gene :scopes/csys/program/gene)
|
||||||
(:logging :scopes/logging)
|
(:logging :scopes/logging)
|
||||||
(:message :scopes/core/message)
|
(:message :scopes/core/message)
|
||||||
(:shape :scopes/shape)
|
(:shape :scopes/shape)
|
||||||
|
|
@ -55,7 +56,8 @@
|
||||||
(test-space)
|
(test-space)
|
||||||
(test-basic-0)
|
(test-basic-0)
|
||||||
(test-basic-1)
|
(test-basic-1)
|
||||||
(test-basic-2))
|
(test-basic-2)
|
||||||
|
(test-gene-0))
|
||||||
(sleep 0.02)
|
(sleep 0.02)
|
||||||
(tc:check-expected)
|
(tc:check-expected)
|
||||||
(t:show-result))))
|
(t:show-result))))
|
||||||
|
|
@ -124,3 +126,10 @@
|
||||||
(environ:send-value '(:s02 #(1 0)) 2)
|
(environ:send-value '(:s02 #(1 0)) 2)
|
||||||
(teardown)))
|
(teardown)))
|
||||||
|
|
||||||
|
(deftest test-gene-0 ()
|
||||||
|
(let ((environ:*env* (setup (list (gene:prog-g0))))
|
||||||
|
(rcvr (tc:receiver t:*test-suite*)))
|
||||||
|
(environ:send-create '(:csys :c00 #(0 0)) :cat :e01 :connect :succ)
|
||||||
|
(sleep 0.01) (print (tc:collected rcvr))
|
||||||
|
(teardown)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue