The Queen is piece #4 instead of 5.
for(i=16,ip++; *ip >= 0; i++) pieceValues[WHITE+i] = pieceValues[BLACK+i] = *ip++; // promoted
for(i=0, ip++; *ip >= 0; i++) handVal[WHITE+i] = handVal[BLACK+i] = *ip++; // in hand
pawn = 2*handVal[WHITE] << 20; // used for detection of material-loosing loop
- queen = v ? 0 : 2*handVal[WHITE+5] << 20; // losing two Queens overflows
+ queen = v ? 0 : 2*handVal[WHITE+4] << 20; // losing two Queens overflows
for(i=0; i<16; i++) {
int demoted = dropType[handSlot[WHITE+i+16]]-1; // piece type after demotion (could be Pawn, in Chess)
handVal[WHITE+i+16] = handVal[BLACK+i+16] = pieceValues[WHITE+i+16] + handVal[demoted]; // gain by capturing promoted piece