On Oct 21, 9:04 pm, "Meikel Brandmeyer (kotarak)" <m...@kotka.de>
wrote:
> Hi,
>
> may I question the transitivity of state information?
>
> Maybe the world's state is that player "Trantor" is at position [15 34]. Now
> Trantor eats an appel. The appel is removed from his inventory and his
> health is raised by 5 hit points. Did the state of the world change? No.
> Trantor is still at position [15 34]. Does the world have to know about the
> apple in Trantors inventory and the sad state of his hit points?
>
> Disclaimer: I have no clue about game programming, about what information is
> needed where and how this is implemented insanely fast. Just a naive
> question from the distance.

I think it generally makes sense to consider the entire world
including Trantor and his tasty apple as part of the world state. This
seems logically consistent - they are part of the world and it would
seem odd if some actions like dropping an apple on the ground at [15
34] altered the world state but eating an apple didn't.

It also has nice properties..... you can then treat the world state as
a single value that you can pass to functions etc.

e.g. you could create a higher order functions to update the world
with something like:

  ((command "Trantor" :eat "apple") world-state)

The problem with identities of actors comes in when you consider code
like the following:

  (def trantor (get-actor "Trantor" world-state))

  (:hit-points trantor)
  => 10

  (def new-world-state ((command "Trantor" :eat "apple") world-state))

  (:hit-points trantor)
  => 10     (still!! because we took a snapshot of trantor......)

  (def new-trantor (get-actor "Trantor" new-world-state))

  (:hit-points new-trantor)
  => 15

Maybe this is all fine and I'm sure it is possible to successfully
write a game this way. However it does feel a little strange when you
are coming from OOP languages where you are used to simulating
everything with mutable state....

-- 
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