> you mean making 32 new pieces after each move regardless of whether they
> moved or not? how can I identify the ones that are different from the ones
> that remain unchanged so i can conj them in a new list? move will eventually
> call 'build-board' which has to look somewhere for the current pieces. If
> moving a piece returns a new piece how do i associate it with the previous
> board to produce the new? remember the piece has to leave its current
> position and go the next one. That is one dissoc and one assoc isn't it?
>

No. If they are immutable you can reuse all of those that didn't change.
(That also includes part of the board structure itself that do not change).

For example, if your state were a vector [:x :o :x nil .... :x]
(for a board of tic-tac-toe), calling (assoc board 3 :x) will return a
new board
with the position 3 set to :x. This board shares all other content,
and even part of
the structure of the board is kept.
This should be enough to represent and operate on the game state.
Performance should be quite good too. A big win is in clarity of the code
and in the fact you can keep different states around: you won need undo
and exploring a tree in // will be easy.

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