English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

4 answers

My thoughts...

If you see how a chess game is recorded, its easy to get the data structure. A chess game records each move in x-y notation. x is starting loc, y is final loc. aXb indicates piece 'a' kills piece 'b'. Squares are given A-H horizontally and 1-8 vertically. So B1-C3 (white move) means your horse has moved forward and B8-C6 means black player has moved his horse. To store this data, you need a single linked list with a char[6] as member. '0-0-0' is the biggest value (it denotes queen side castling) you will be storing in it.

struct CHESS {
char move[6];
struct CHESS* next;
};

If you want the ability to rollback the moves, then go for a doubly linked list.

2006-07-12 23:18:39 · answer #1 · answered by Indian_Male 4 · 0 0

I think a basic array works in most languages. Depending on the language you could use indices that are pertinent to the domain, for example "board(h,5)".

2006-07-13 06:14:18 · answer #2 · answered by danieltoomeydanieltoomey 2 · 0 0

class chessboard
{
int matrix[8][8];
};

2006-07-13 06:12:53 · answer #3 · answered by Gurudev 3 · 0 0

An array. Duh.

2006-07-13 06:49:44 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers