X-Git-Url: https://jxself.org/git/?p=8sync.git;a=blobdiff_plain;f=demos%2Factors%2Frobotscanner.scm;h=5dd5d5e13d6fb484daa14a0602db410a69c778f5;hp=1fd3c88b96ad7b5d0c81b38dbce05b6096d8d372;hb=84a19e7d4cb97e00a64191e1ecfcf984ffae52d1;hpb=67e7474e551af5991ba4c5e3d686785a1aaa1d42 diff --git a/demos/actors/robotscanner.scm b/demos/actors/robotscanner.scm index 1fd3c88..5dd5d5e 100644 --- a/demos/actors/robotscanner.scm +++ b/demos/actors/robotscanner.scm @@ -47,62 +47,62 @@ (5 0) (2 1))) -(define-simple-actor - (init-world - (lambda (actor message) - ;; Porting mostly straight up from super-imperative XUDD code. - (define previous-room #f) - (define first-room #f) - - ;; Set up all rooms - (for-each - (match-lambda - ((clean-droids infected-droids) - ;; Create this room - (define room (create-actor* actor "room")) - (define* (init-droid #:key infected) - (define droid (create-actor* actor "droid" - #:infected infected - #:room room)) - (<-wait droid 'register-with-room)) - - ;; Link rooms. - ;; Couldn't this just be folded into the warehouse room init? - ;; I guess it stress tests more the message sending process - (when previous-room - (<- previous-room 'set-next-room - #:id room) - (<- room 'set-previous-room - #:id previous-room)) - - ;; Set up clean droids in the room - (for-each - (lambda _ - (init-droid #:infected #f)) - (iota clean-droids)) - - ;; Set up infected droids in the room - (for-each - (lambda _ - (init-droid #:infected #t)) - (iota clean-droids)) - - (set! previous-room room) - (if (not first-room) - (set! first-room room)))) - room-structure) - - ;; Add security robot - (let ((security-robot - (create-actor actor ))) - (<- security-robot 'begin-mission - #:starting-room first-room - #:overseer (actor-id actor))))) - - (transmission - (lambda* (actor message #:key text) - (display text) - (newline)))) +(define-actor () + ((init-world + (lambda (actor message) + ;; Porting mostly straight up from super-imperative XUDD code. + (define previous-room #f) + (define first-room #f) + + ;; Set up all rooms + (for-each + (match-lambda + ((clean-droids infected-droids) + ;; Create this room + (define room (create-actor* actor "room")) + (define* (init-droid #:key infected) + (define droid (create-actor* actor "droid" + #:infected infected + #:room room)) + (<-wait droid 'register-with-room)) + + ;; Link rooms. + ;; Couldn't this just be folded into the warehouse room init? + ;; I guess it stress tests more the message sending process + (when previous-room + (<- previous-room 'set-next-room + #:id room) + (<- room 'set-previous-room + #:id previous-room)) + + ;; Set up clean droids in the room + (for-each + (lambda _ + (init-droid #:infected #f)) + (iota clean-droids)) + + ;; Set up infected droids in the room + (for-each + (lambda _ + (init-droid #:infected #t)) + (iota clean-droids)) + + (set! previous-room room) + (if (not first-room) + (set! first-room room)))) + room-structure) + + ;; Add security robot + (let ((security-robot + (create-actor actor ))) + (<- security-robot 'begin-mission + #:starting-room first-room + #:overseer (actor-id actor))))) + + (transmission + (lambda* (actor message #:key text) + (display text) + (newline))))) ;;; A room full of robots. @@ -206,8 +206,8 @@ ;;; Security robot... designed to seek out and destroy infected droids. -(define-simple-actor - (begin-mission security-robot-begin-mission)) +(define-actor () + ((begin-mission security-robot-begin-mission))) (define* (security-robot-begin-mission actor message #:key starting-room overseer)