Implement the method step.

This commit is contained in:
Sergiu Ivanov 2022-09-02 16:32:52 +02:00
parent bba44c2887
commit 983380b063
2 changed files with 27 additions and 18 deletions

View file

@ -10,7 +10,8 @@
(super-new) (super-new)
(: step (-> State (Listof State))) (: step (-> State (Listof State)))
(define/abstract/error (step st)) (define/public (step st)
(map (inst cdr Modality State) (step/annotated st)))
(: step/annotated (-> State (Listof (Pairof Modality State)))) (: step/annotated (-> State (Listof (Pairof Modality State))))
(define/abstract/error (step/annotated st)) (define/abstract/error (step/annotated st))

View file

@ -529,24 +529,32 @@
(cons m (update network s m)))))) (cons m (update network s m))))))
(module+ test (module+ test
(test-case "dynamics%" (let* ([n1 : (Network Boolean)
(define n1 : (Network Boolean) (forms->boolean-network (hash 'x '(not y)
(forms->boolean-network (hash 'x '(not y) 'y 'x
'y 'x 'z '(and y z)))]
'z '(and y z)))) [syn : Mode '((x y z))]
(define syn : Mode '((x y z))) [asyn : Mode '((x) (y) (z))]
(define asyn : Mode '((x) (y) (z))) [dyn-syn (new (inst dynamics% Boolean) [network n1] [mode syn])]
(define dyn-syn (new (inst dynamics% Boolean) [network n1] [mode syn])) [dyn-asyn (new (inst dynamics% Boolean) [network n1] [mode asyn])]
(define dyn-asyn (new (inst dynamics% Boolean) [network n1] [mode asyn])) [s1 (hash 'x #f 'y #f 'z #f)])
(test-case "dynamics%"
(check-equal? (send dyn-syn step/annotated s1)
'(((x y z) . #hash((x . #t) (y . #f) (z . #f)))))
(check-equal? (send dyn-asyn step/annotated s1)
'(((x) . #hash((x . #t) (y . #f) (z . #f)))
((y) . #hash((x . #f) (y . #f) (z . #f)))
((z) . #hash((x . #f) (y . #f) (z . #f))))))
(define s1 (hash 'x #f 'y #f 'z #f)) (test-case "dynamics%:step"
(check-equal? (send dyn-syn step/annotated s1) (check-equal? (send dyn-syn step s1)
'(((x y z) . #hash((x . #t) (y . #f) (z . #f))))) '(#hash((x . #t) (y . #f) (z . #f))))
(check-equal? (send dyn-asyn step/annotated s1) (check-equal? (send dyn-asyn step s1)
'(((x) . #hash((x . #t) (y . #f) (z . #f))) '(#hash((x . #t) (y . #f) (z . #f))
((y) . #hash((x . #f) (y . #f) (z . #f))) #hash((x . #f) (y . #f) (z . #f))
((z) . #hash((x . #f) (y . #f) (z . #f))))) #hash((x . #f) (y . #f) (z . #f)))))
)) )
)
) )
(require 'typed) (require 'typed)