On 13/06/12 10:58, nicolas.o...@gmail.com wrote:
And from what I understand of your design, I disagree on a point: I
think it is not true a move is a command apply to
a piece. A lot of moves involve multiple pieces.
So I would try to represent a move as something like:

(defprotocol
    Move
    (can-execute [board] "check the move can be executed on that board")
    (execute [board] "return the board after the move")
     ... )

I don't want to mix in game-logic with moving the pieces...moving the pieces is really only about changing their position...how that position will be changed and how many pieces are affected is a different story isn't it? For example I will use core.logic to encode how each piece is supposed to move (which is more than half the rules of the entire game) and so each piece will know how to move/attack and the consequences of doing so will be baked in...when 'build-board' comes to play and builds a brand new board it will pick up on all consequences of a single move (the mutated points and meta-data of pieces) so it will 'draw' everything accordingly... If i have the move object doing the checking then that means that it needs access to the board which complicates things a lot...funny you mentioned that though cos that is how I did in Java during my second year of Uni...the move object was responsible for a whole lot and the rules were all over the place...not doing that this time!

Your other point about making the Pieces pure as well is noted...however i do have some concerns about performance...also, the plan was to represent the board as list of pieces (governed by an atom) and when the time comes to build the new board you reset! one single atom (but some pieces have different positions now or some are nil (dead))... if i make the pieces pure what comes to mind is resetting or swapping possibly 32 atoms instead...I'd like moving the pieces to return the new board rather than returning the piece that moved...and moving a piece should be as cheap as possible because when i start training the neural network with the GA there will be millions of games played every minute...

Now that i think about it a bit more i may have to have a boolean flag to signal whether a move is being tried or actually made cos i don't want to log boards that are results of simply trying a move only the ones that are actually result of making a move...


Jim

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