memcpy() bug
Posted: Fri Aug 14, 2015 1:14 am
I'm trying to add the structure for my board position at the leaf node to my PV structure, and I'm just not getting the copy correct. Can anyone help me out with what I am doing wrong?
and the second PrintBoard call returns garbage.
Code: Select all
The structures are:
typedef struct {
bitboard hash;
bitboard bb_pieces[2][7];
char kingsq[2];
char board[64]; // bits 0-3 piecetype, bit 4 color
int pieceCnt[2][7]; // number of pieces of each type
int epSquare;
char castleStat;
char movingColor;
char fiftyCount;
int moveCount;
int mob[2];
} position;
typedef struct tagLINE {
int cmove; // Number of moves in the line
int argmove[MAXPLY+1]; // PV line
position leaf; // Leaf position of PV
int leafScore;
} LINE;
and the code:
int Quiesce(position* bd,tree* space, int alpha,int beta,LINE* pline)
{
...
// Assume this will be a leaf - copy the position and score;
memcpy(&pline->leaf,&bd,sizeof(bd));
Print(3, "Leaf Board\n");
PrintBoard(bd);
Print(3, "Copied to Pline\n");
PrintBoard(&pline->leaf);
...
}