From: Christopher Allan Webber Date: Wed, 4 Jan 2017 22:53:55 +0000 (-0600) Subject: demos: Switch botherbotherbother demo over to use define-actor. X-Git-Tag: v0.4.0~20 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=b4d48459b192645cd9537830f9ddecbf138f11ec;p=8sync.git demos: Switch botherbotherbother demo over to use define-actor. * demos/actors/botherbotherbother.scm: Switch to use define-actor. --- diff --git a/demos/actors/botherbotherbother.scm b/demos/actors/botherbotherbother.scm index abccd4e..5ea9b1a 100755 --- a/demos/actors/botherbotherbother.scm +++ b/demos/actors/botherbotherbother.scm @@ -46,28 +46,25 @@ (format #f "~a-~a" student current-number)))) -(define-class () +(define-actor () + ((bother-professor + (lambda* (actor message #:key target) + "Go bother a professor" + (while (not (student-dead actor)) + (format #t "~a: Bother bother bother!\n" + (actor-id-actor actor)) + (<- target 'be-bothered + #:noise "Bother bother bother!\n")))) + + (be-lambda-consvardraed + (lambda (actor message) + "This kills the student." + (format #t "~a says: AAAAAAAHHHH!!! I'm dead!\n" + (actor-id-actor actor)) + (set! (student-dead actor) #t)))) (name #:init-keyword #:name) (dead #:init-value #f - #:accessor student-dead) - (actions #:allocation #:each-subclass - #:init-value - (build-actions - (bother-professor - (lambda* (actor message #:key target) - "Go bother a professor" - (while (not (student-dead actor)) - (format #t "~a: Bother bother bother!\n" - (actor-id-actor actor)) - (<- target 'be-bothered - #:noise "Bother bother bother!\n")))) - - (be-lambda-consvardraed - (lambda (actor message) - "This kills the student." - (format #t "~a says: AAAAAAAHHHH!!! I'm dead!\n" - (actor-id-actor actor)) - (set! (student-dead actor) #t)))))) + #:accessor student-dead)) (define complaints '("Hey!" "Stop that!" "Oof!")) @@ -95,16 +92,13 @@ ;; Otherwise, remove them from the list and carry on (hash-remove! whos-bothering (message-from message)))) -(define-class () +(define-actor () + ((be-bothered professor-be-bothered)) ;; This value checks whether any other actor is currently ;; bothering this same character. ;; We'll use a hash table as a fake set. (bothered-by #:init-thunk make-hash-table - #:getter professor-bothered-by) - (actions #:allocation #:each-subclass - #:init-value - (build-actions - (be-bothered professor-be-bothered)))) + #:getter professor-bothered-by)) (define num-students 10)