Hi, On Jan 15, 4:25 pm, Simon Brooke <still...@googlemail.com> wrote: > Right, I'm trying to get my head around the consequences of <!-- SNIP --> > Opinions?
You have to distinguish between identity and state. Disclaimer: I have no clue whatsoever about game design. The different rooms are identities, the different players are identities. An identity might have a varying state over time. So the right thing to call for are Clojure's state handling facilities, eg. Refs. (declare player1 ork *room1* *room2*) (def player1 (ref {:in-room *room1* :inventory nil})) (def ork (ref {:in-room *room2* :health 100})) (def *room1* (ref {:occupants #{player1}})) (def *room2* (ref {:occupants #{ork}})) Now time evolves and the player in front of the keyboard goes south: (dosync (alter player1 assoc :in-room *room2*) (alter *room1* update-in [:occupants] disj player1) (alter *room2* update-in [:occupants] conj player1)) Now the refs look like this: player1 (ref {:in-room *room2* :inventory nil}) ork (ref {:in-room *room2* :health 100}) *room1* (ref {:occupants #{}}) *room2* (ref {:occupants #{player1 ork}}) The STM takes care to coordinate these changes also across different threads. You might want to explore http://clojure.org and watch some of Rich's screencasts. Hope this helps to get you started. Sincerely Meikel
-- 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