Implement the method step.
This commit is contained in:
parent
bba44c2887
commit
983380b063
2 changed files with 27 additions and 18 deletions
|
@ -10,7 +10,8 @@
|
|||
(super-new)
|
||||
|
||||
(: 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))))
|
||||
(define/abstract/error (step/annotated st))
|
||||
|
|
42
networks.rkt
42
networks.rkt
|
@ -529,24 +529,32 @@
|
|||
(cons m (update network s m))))))
|
||||
|
||||
(module+ test
|
||||
(test-case "dynamics%"
|
||||
(define n1 : (Network Boolean)
|
||||
(forms->boolean-network (hash 'x '(not y)
|
||||
'y 'x
|
||||
'z '(and y z))))
|
||||
(define syn : Mode '((x y z)))
|
||||
(define asyn : Mode '((x) (y) (z)))
|
||||
(define dyn-syn (new (inst dynamics% Boolean) [network n1] [mode syn]))
|
||||
(define dyn-asyn (new (inst dynamics% Boolean) [network n1] [mode asyn]))
|
||||
(let* ([n1 : (Network Boolean)
|
||||
(forms->boolean-network (hash 'x '(not y)
|
||||
'y 'x
|
||||
'z '(and y z)))]
|
||||
[syn : Mode '((x y z))]
|
||||
[asyn : Mode '((x) (y) (z))]
|
||||
[dyn-syn (new (inst dynamics% Boolean) [network n1] [mode syn])]
|
||||
[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))
|
||||
(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)))))
|
||||
))
|
||||
(test-case "dynamics%:step"
|
||||
(check-equal? (send dyn-syn step s1)
|
||||
'(#hash((x . #t) (y . #f) (z . #f))))
|
||||
(check-equal? (send dyn-asyn step s1)
|
||||
'(#hash((x . #t) (y . #f) (z . #f))
|
||||
#hash((x . #f) (y . #f) (z . #f))
|
||||
#hash((x . #f) (y . #f) (z . #f)))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(require 'typed)
|
||||
|
|
Loading…
Reference in a new issue