void BuildPos(PositionStruct &pos, const UcciCommStruct &UcciComm) { int i, mv; pos.FromFen(UcciComm.szFenStr); for (i = 0; i < UcciComm.nMoveNum; i ++) { mv = COORD_MOVE(UcciComm.lpdwMovesCoord[i]); if (mv == 0) { break; } if (pos.ucpcSquares[SRC(mv)] == 0) { break; } pos.MakeMove(mv); } }
void BuildPos(PositionStruct &pos, const UcciCommStruct &UcciComm) { int i, mv; pos.FromFen(UcciComm.szFenStr); for (i = 0; i < UcciComm.nMoveNum; i ++) { mv = COORD_MOVE(UcciComm.lpdwMovesCoord[i]); if (mv == 0) { break; } if (pos.LegalMove(mv) && pos.MakeMove(mv) && pos.LastMove().CptDrw > 0) { // 始终让pos.nMoveNum反映没吃子的步数 pos.SetIrrev(); } } }
static void AddEcco(const char *szPgnFile, const EccoApiStruct &EccoApi) { int i, nStatus; uint32_t dwEccoIndex, dwFileMove[20]; PgnFileStruct pgn; PositionStruct pos; if (pgn.Read(szPgnFile, NO_ADVERT)) { pos.FromFen(cszStartFen); for (i = 1; i <= MIN(pgn.nMaxMove, 20); i ++) { dwFileMove[i - 1] = Move2File(pgn.wmvMoveTable[i], pos); TryMove(pos, nStatus, pgn.wmvMoveTable[i]); } if (pgn.nMaxMove < 20) { dwFileMove[pgn.nMaxMove] = 0; } dwEccoIndex = EccoApi.EccoIndex((const char *) dwFileMove); strcpy(pgn.szEcco, (const char *) &dwEccoIndex); strcpy(pgn.szOpen, EccoApi.EccoOpening(dwEccoIndex)); strcpy(pgn.szVar, EccoApi.EccoVariation(dwEccoIndex)); pgn.Write(szPgnFile); } }