I've been programming agent-based models in clojure for the last 2 years, 
and I've found that having a vector full of refs works fine. If two 
individuals interact (in my case, form a relationship), I use dosync and 
alter in a parallel environment to ensure that noone is starting more 
relationships than they have capacity for).

(def world (vec (map (fn [pos] (ref (create-host (- (rand-int (* timespan 
365)) (* maximum-age 365)) pos))) (range fullpopsize)))))

(defn pair-hosts [h1 h2]
      (dosync 
         (let [keep-till (+ @day (exp-decay (table-relation reltype)))]
           (alter h1 assoc :relas (vec (conj (:relas @h1) (struct relation 
(:id @h2) reltype @day keep-till))))
           (alter h2 assoc :relas (vec (conj (:relas @h2) (struct relation 
(:id @h1) reltype @day keep-till))))
           (vector h1 h2))))))


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to