string[int[][]] ??
dcoder
dcoder at devnull.com
Sun Jul 25 22:57:30 PDT 2010
== Quote from Stewart Gordon (smjg_1998 at yahoo.com)'s article
> Further to what others have said, why use strings? There are only 12
> possible chess pieces (black and white), plus blank, so probably the
> most efficient approach is
> char[8][8] board;
> and use uppercase letters for white and lowercase for black. This also
> makes it very easy to embed board positions in code, and to write/read
> positions to/from a file (but don't forget to validate).
> But there's something else to consider. Do you want to be able to
> represent:
> - whose turn it is to move?
> - availability of en passant capture?
> - possibility of castling? (One of my programs uses 'C' to represent a
> rook on which castling may still be possible, and 'R' for one on which
> it isn't.)
Wow, well you have certainly thought about this alot more than I have. I am
merely experimenting / learning the D language, and a good way to do that would be
to come up with a pet project. So, I figure writing a chess program would be
good, non-trivial project to do. I also want to practice my patterns, which I
haven't had a real chance to do in years. So, I figure I want to really write a
generalize board game program so that it can play:
1. checkers.
2. othello
3. tic tac toe
4. connect four
5. chess
By deriving the right base classes.
Anyways, thanks for the suggestions, I will keep them in mind.
More information about the Digitalmars-d-learn
mailing list