Here is my struct:
struct Checker
{
short row;
short col;
unsigned short number;
short color;
};
Now, I have to also make another struct to represent a checkers board:
struct Board
{
Checker checkers[2][13]; // Zeroth entry of 13 is not used.
Checker *grid[8][8]; // each entry holds Null or an address
// of an element in the checkers array
};
If it matters, checkers[0-1] represents what side, [1-12] are unique numbers for each piece.
Anyways, I have a an 8x8 grid, that either points to NULL, or a checker piece. What i want to do is to be able to access that checker not by its unique ID (checkers[0][5] for instance), but instead by its position on the grid.
How can I access the data members in this fashion? I'l try to summarize:
Declared a Board gameBoard. Set up the grid so that I have a checkers piece at [0][0]
. This would be checkers[0][1]
. So instead of doing cout <<checkers[0][1].number
, I'd like to be able to print the checker's number without knowing its ID, and instead knowing that that specific checker is at [0][0]
Thanks.