And there are several agents that realize game objects behavior. For 
example this is movement agent:

(defn movement-loop [{:keys [game last-time] {:keys [heroes-container 
bullets-container finished?]} :game}]
  "Moves heroes by their current direction"
  (if-not finished?
    (send-off *agent* movement-loop))
  (let [curtime (current-seconds)
        dt (- curtime last-time)]
    (do-with-objects heroes-container
                     (fn [hero]
                       (move (select-keys hero [:x :y]) (* (:speed hero) dt) 
(:direction hero))))
    (do-with-objects bullets-container
                     (fn [bullet]
                       (merge
                         (move (select-keys bullet [:x :y]) (* (:speed 
bullet) dt) (:direction bullet))
                         {:destroy-time (- (:destroy-time bullet) dt)})))
    (. Thread (sleep 15))
    {:game game :last-time curtime}))

I need to access heroes-container, finished and some other ^Game variables 
so I pass the game record into each agent. I supposed that this is normal, 
because in any other language we can pass links to the same object. It's 
like:

public class CycleLinked {
     private List<int> list
     private me = this;
     private myList = this.list;

     //some other data....
}

And the me and myList variables are just 8(16) bytes. These variables are 
just links and here's no "cycles" at all.

Why can't I create long posts? to be continued again....

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to