As far as memory management goes, malloc-s and free's should be replaced so:
Code:
void Player::init(int n)
{
draughts = new Draught[n]; //n new Draughts
n_draughts = n;
}
Player::~Player()
{
delete [] draughts; //free dynamic array of draughts
}
As to your design, I'm in no place to help you there, particularly without seeing the code. If your pieces are indexed, then probably each of them contains fields with their coordinates? (But this is duplicate data, because the position of the piece in the grid would already tell you that. I've found that whenever I have redundant data like that to take care of, programming quickly becomes very hard.) So, if a user picks a square, loop through their pieces to see, if some matches this square.
What I was thinking was something like that:
Code:
class Square
{
bool has_piece_;
Piece piece_;
//interface
};
class Piece
{
player_type owner_; //black or white
piece_type type_; //if this is the game I think it is, there's two types of pieces
//interface
};
Of course, this wouldn't probably all be very good, if you wanted an advanced AI, in which case you would store the board state in a couple of unsigned ints as a bitset.
As to the computer making a legal move:
if it's computer's turn, loop through its pieces and generate all possible moves (forced moves separately). If there are any forced moves, pick one from this list, otherwise pick from non-forced moves.