;;;; -*- Scheme -*- ;; ;; Copyright (c) 1997 Massachusetts Institute of Technology ;; ;; This material was developed by the Amorphous Computing project at the ;; Massachusetts Institute of Technology Artificial Intelligence ;; Laboratory. Permission to copy this software, to redistribute it, and ;; to use it for any purpose is granted, subject to the following ;; restrictions and understandings. ;; ;; 1. Any copy made of this software must include this copyright notice ;; in full. ;; ;; 2. Users of this software agree to make their best efforts (a) to ;; return to the MIT Amorphous Computing project any improvements or ;; extensions that they make, so that these may be included in future ;; releases; and (b) to inform MIT of noteworthy uses of this software. ;; ;; 3. All materials developed as a consequence of the use of this ;; software shall duly acknowledge such use, in accordance with the usual ;; standards of acknowledging credit in academic research. ;; ;; 4. MIT has made no warrantee or representation that the operation of ;; this software will be error-free, and MIT is under no obligation to ;; provide any services, by way of maintenance, update, or otherwise. ;; ;; 5. In conjunction with products arising from the use of this material, ;; there shall be no use of the name of the Massachusetts Institute of ;; Technology nor of any adaptation thereof in any advertising, ;; promotional, or sales literature without prior written consent from ;; MIT in each case. ;; Simulation creation and display for club5 (declare (usual-integrations)) (define (make-sim/1 n r) (let ((x (make-initialized-vector n (lambda (i) i (random 1.0)))) (y (make-initialized-vector n (lambda (i) i (random 1.0)))) (z (make-vector n 0.0))) (let ((neighbours (point-neighbours x y z r))) (let ((sim (%make-simulation))) (do ((i 0 (+ i 1))) ((= i n)) (simulation.add-processor sim)) (set-simulation.x! sim x) (set-simulation.y! sim y) (set-simulation.z! sim z) (set-simulation.neighbours! sim neighbours) sim)))) (define (simulation.display! sim flag) (define (make-display) (let ((g (make-graphics-device))) (graphics-operation g 'set-foreground-color "white") (graphics-operation g 'set-background-color "black") (graphics-set-coordinate-limits g -.01 -.01 1.01 1.01) (graphics-clear g) g)) (set-simulation.display! sim (cond ((not flag) #F) ((graphics-device? flag) flag) (else (make-display))))) (define (%color-me sim i color) (define d 0.007) (define colors '#("blue" "orange" "yellow" "green" "cyan" "magenta" "pink")) (let ((g (simulation.display sim))) (define (draw color) (let ((x (vector-ref (simulation.x sim) i)) (y (vector-ref (simulation.y sim) i))) (graphics-operation g 'set-foreground-color color) (graphics-draw-text g x y "."))) (cond ((not g) unspecific) ((string? color) (draw color)) ((exact-integer? color) (if (and (<= 0 color) (< color (vector-length colors))) (draw (vector-ref colors color)) (draw "white"))) (else (error:wrong-type-argument color "color string" 'color-me)))))