All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sim.app.scheme.ca.scm Maven / Gradle / Ivy

Go to download

MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.

The newest version!
;;; Copyright 2006 by Sean Luke
;;; Licensed under the Academic Free License version 3.0
;;; See the file "LICENSE" for more information

(define-simple-class  ()

  ;; tempGrid
  (temp-grid type: 
         init-form: ( 0 0))

  ;; public void step(SimState state)
  ((step state :: ) :: 

   (let ((width ::  (temp-grid:getWidth))
     (height ::  (temp-grid:getHeight)))

     (temp-grid:setTo (:.grid state))

     (let ((f ::  temp-grid:field)
       (g ::  (:.grid state):field))
       
       (do ((x ::  0 (+ x 1))) ((= x width))
         (do ((y ::  0 (+ y 1))) ((= y height))
           (let ((count ::  0))
             (do ((dx ::  -1 (+ dx 1))) ((= dx 2))
               (do ((dy ::  -1 (+ dy 1))) ((= dy 2))
             (set! count (+ count
                    ((f (temp-grid:stx (+ x dx)))
                     (temp-grid:sty (+ y dy)))))))
             
             (if (or (<= count 2) (>= count 5))
             (set! ((g x) y) 0)
             (if (= count 3)
                 (set! ((g x) y) 1))))))))))
    




© 2015 - 2025 Weber Informatics LLC | Privacy Policy