本文整理汇总了C++中PositionStruct::ChangeSide方法的典型用法代码示例。如果您正苦于以下问题:C++ PositionStruct::ChangeSide方法的具体用法?C++ PositionStruct::ChangeSide怎么用?C++ PositionStruct::ChangeSide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PositionStruct
的用法示例。
在下文中一共展示了PositionStruct::ChangeSide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExchangeSide
// 红黑互换
void ExchangeSide(PositionStruct &pos) {
int i, sq;
uint8_t ucsqList[32];
for (i = 16; i < 48; i ++) {
sq = pos.ucsqPieces[i];
ucsqList[i - 16] = sq;
if (sq != 0) {
pos.AddPiece(sq, i, DEL_PIECE);
}
}
for (i = 16; i < 48; i ++) {
sq = ucsqList[i < 32 ? i : i - 32]; // 这行不同于FlipBoard
if (sq != 0) {
pos.AddPiece(SQUARE_FLIP(sq), i);
}
}
pos.ChangeSide(); // 这行不同于FlipBoard
}
示例2: Xqf2Pgn
//.........这里部分代码省略.........
GetXqfString(pgn.szDate, xqfhd.szDate);
GetXqfString(pgn.szSite, xqfhd.szSite);
GetXqfString(pgn.szRed, xqfhd.szRed);
GetXqfString(pgn.szBlack, xqfhd.szBlack);
pgn.nResult = cnResultTrans[(int) xqfhd.szResult[3]];
if (xqfhd.szSetUp[0] < 2) {
// 如果是开局或者全局,那么直接设置起始局面
pgn.posStart.FromFen(cszStartFen);
} else {
// 如果是中局或者排局,那么根据"xqfhd.szPiecePos[32]"的内容摆放局面
// 当版本号达到12时,还要进一步解密局面初始位置
if (nXqfVer < 12) {
for (i = 0; i < 32; i ++) {
nPiecePos[i] = (uint8_t) (xqfhd.szPiecePos[i] - nPieceOff);
}
} else {
for (i = 0; i < 32; i ++) {
nPiecePos[(nPieceOff + 1 + i) % 32] = (uint8_t) (xqfhd.szPiecePos[i] - nPieceOff);
}
}
// 把"nPiecePos[32]"的数据放到"PositionStruct"中
pgn.posStart.ClearBoard();
for (i = 0; i < 32; i ++) {
if (nPiecePos[i] < 90) {
pgn.posStart.AddPiece(cucsqXqf2Square[nPiecePos[i]], cpcXqf2Piece[i]);
}
}
pgn.posStart.SetIrrev();
}
pos = pgn.posStart;
bHasNext = true;
while (bHasNext && pgn.nMaxMove < MAX_MOVE_LEN) {
// 读取着法记录
if (nXqfVer < 11) {
fread(&xqfmv, sizeof(xqfmv), 1, fp);
fread(&nCommentLen, sizeof(int), 1, fp);
if ((xqfmv.ucTag & 0xf0) == 0) {
bHasNext = false;
}
} else {
ReadAndDecrypt(fp, &xqfmv, sizeof(xqfmv), nEncStream, nEncIndex);
if ((xqfmv.ucTag & 0x20) != 0) {
ReadAndDecrypt(fp, &nCommentLen, sizeof(int), nEncStream, nEncIndex);
nCommentLen -= nCommentOff;
} else {
nCommentLen = 0;
}
if ((xqfmv.ucTag & 0x80) == 0) {
bHasNext = false;
}
}
if (pgn.nMaxMove > 0) {
// 记录着法
mv = MOVE(cucsqXqf2Square[(uint8_t) (xqfmv.ucSrc - 24 - nSrcOff)], cucsqXqf2Square[(uint8_t) (xqfmv.ucDst - 32 - nDstOff)]);
if (pgn.nMaxMove == 1) {
if ((pgn.posStart.ucpcSquares[SRC(mv)] & 32) != 0) {
pgn.posStart.ChangeSide();
pos.ChangeSide();
}
}
if (xqfhd.szSetUp[0] < 2 && pgn.nMaxMove <= 20) {
dwFileMove[pgn.nMaxMove - 1] = Move2File(mv, pos);
}
TryMove(pos, nStatus, mv);
pgn.wmvMoveTable[pgn.nMaxMove] = mv;
if (pos.nMoveNum == MAX_MOVE_NUM) {
pos.SetIrrev();
}
}
if (nCommentLen > 0) {
pgn.szCommentTable[pgn.nMaxMove] = new char[nCommentLen + 1];
ReadAndDecrypt(fp, pgn.szCommentTable[pgn.nMaxMove], nCommentLen, nEncStream, nEncIndex);
pgn.szCommentTable[pgn.nMaxMove][nCommentLen] = '\0';
}
pgn.nMaxMove ++;
}
pgn.nMaxMove --;
// 解析ECCO
if (xqfhd.szSetUp[0] < 2) {
if (pgn.nMaxMove < 20) {
dwFileMove[pgn.nMaxMove] = 0;
}
if (EccoApi.Available()) {
dwEccoIndex = EccoApi.EccoIndex((const char *) dwFileMove);
strcpy(pgn.szEcco, (const char *) &dwEccoIndex);
strcpy(pgn.szOpen, EccoApi.EccoOpening(dwEccoIndex));
strcpy(pgn.szVar, EccoApi.EccoVariation(dwEccoIndex));
}
}
fclose(fp);
return (pgn.Write(szPgnFile) ? XQF2PGN_OK : XQF2PGN_ERROR_CREATE);
} else {
fclose(fp);
return XQF2PGN_ERROR_FORMAT;
}
}