;;;; -*- Scheme -*-
;;
;; neighbors example for HLSIM
;;
;; David DeRoure Sep 11 1997
;; dder@martigny.ai.mit.edu
;;
;; This is the simulation setup for neighbors1.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 "club5d") ; normal compilation (scm -> bin -> com), generates club5d.com

(cps "neighbors1") ;  gunk compilation (scm -> bin), generates neighbors1.bin
(cbf "neighbors1") ;  gunk compilation (bin -> com), generates neighbors1.com

;; If you have the compiled files, start from here

(load "club5d")

;; Make the simulation

(set! *store-size* 30)

;; Go from here to run different simulations.

;; The mean neighborhood density is just under n * pi * r^2
;; e.g. for a quick simulation try 1000 procs, radius 0.04, n pi r^2 = 5.0

(define sim (make-sim/1 1000 0.04))

;; e.g. for a large simulation try 10000 procs, radius 0.012, n pi r^2 = 4.5
; (define sim (make-sim/1 10000 0.012))

(simulation.display! sim #T)

(simulation.load sim 'init "neighbors1")

(simulation.run sim)

;; get some stats on collisions and numbers of neighbors

(let ((l (vector->list (simulation.eval sim 'collisions))))
  (list (apply min l) (apply max l)))

(let ((l (vector->list (simulation.eval sim '(length neighbors)))))
  (list (apply min l) (apply max l)))

;; end of neighbors1s.scm

