dcoder wrote:
== Quote from Steven Schveighoffer ([email protected])'s article
This is what I think you should use:
string[int[2]]
<snip>
board[[0,0]] = "Rook";
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.)
seems to work. thanks. But, the foreach loop looks strange. It looks like it
takes the hash value of the key:
<snip>
Clearly a bug. Need to investigate further....
Stewart.