;;;; -*- Scheme -*- ;; ;; "find" example for HLSIM ;; ;; David DeRoure June 12 1997, revised Sep 11 1997 ;; dder@martigny.ai.mit.edu ;; ;; This is the simulation setup for find2.scm. See the HLSIM documentation ;; for further details. (load-option 'hlsim) ;; If you are using this example for the very first time, you need some ;; compiled files available to load. If you do not have these, you can ;; generate them with the following: ;(cf "util1d") ; normal compilation (scm -> bin -> com) (cps "find2") ; gunk compilation (scm -> bin), generates find2.bin (cbf "find2") ; gunk compilation (bin -> com), generates find2.com ;; If you have the compiled files, start from here (load "util1d") ;; borrowed temporarily from next distribution (define (make-static-projected-PNM-colour-sensor image-file) (let ((pnm #F)) (define (initializer dev sim) dev sim ; ignored (set! pnm (read-pnm image-file))) (define (action dev sim index time) dev time ; ignored (let ((x (vector-ref (simulation.x sim) index)) (y (vector-ref (simulation.y sim) index))) (if (or (<= x 0) (<= y 0) (>= x 1) (>= y 1)) 0.0 (let ((px (truncate->exact (* x (pnm.width pnm)))) (py (truncate->exact (* (- 1 y) (pnm.height pnm))))) (pnm.get-rgb pnm px py))))) (make-io-device initializer action))) ;; Make the simulation ;; Go from here to run different simulations. (set! *store-size* 50) ;; The mean neighborhood density is just under n * pi * r^2 ;; e.g. for a quick simulation try 1000 procs, radius 0.05, n pi r^2 = 7.9 ;(define sim (make-sim/1 1000 0.05)) (define sim (make-sim/1 3000 0.05)) ;; e.g. for a large simulation try 10000 procs, radius 0.02, n pi r^2 = 12.6 ; (define sim) ; (define sim (make-sim/1 10000 0.02)) (simulation.set! sim 'source-processors (list (simulation.find-processor-nearest sim 0.0 0.0) (simulation.find-processor-nearest sim 0.0 0.5) (simulation.find-processor-nearest sim 0.0 1.0))) (simulation.set! sim 'destination-processors (list (simulation.find-processor-nearest sim 1.0 0.0) (simulation.find-processor-nearest sim 1.0 0.5) (simulation.find-processor-nearest sim 1.0 1.0))) (simulation.define-device sim 'light-sensor (make-static-projected-PNM-colour-sensor "mask1.ppm")) (simulation.display! sim #T) (simulation.load sim 'init "find2") (simulation.run sim) ;; end of find2s.scm