!set match_random := 100;; ofile := "/tmp/dla.jbv" ;; type particle = `Mobile | `Fixed ;; type mas = [particle]Moore ;; fun populate_grid(g:Moore, size_x:int, size_y:int, nb_particle: int) = ( for i = 0 to size_x-1 do ( g.(i * |E> + 0 * |N>) := `Fixed; g.(i * |E> + (size_y-1) * |N>) := `Fixed ); for j = 0 to size_y-1 do ( g.(0 * |E> + j * |N>) := `Fixed; g.((size_x-1) * |E> + j * |N>) := `Fixed ); for p = 0 to nb_particle-1 do g.( + random(size_x-1) * |E> + random(size_y-1) * |N>) := `Mobile; g ) ;; S0 := populate_grid(Moore:(),100,100, 1000) ;; mas(S0);; trans behaviors = { // Aggregation `Fixed, `Mobile => `Fixed, `Fixed; // Diffusion (random walk) `Mobile, => [| , `Mobile |]; } ;; fun output(S) = ( ofile << " { " ; foreach c @ p in S do begin let (x,y) = sequify(p) in ofile << " { " << x << " " << y; ofile << switch c case `Mobile: " 1 0 0 } " case `Fixed: " 0 1 0 } " endswitch end; ofile << " }\n" ; S ) ;; behaviors[iter = 300, prelude = output, interlude = output, postlude = output ](S0) ;;