本文整理汇总了C++中MoveArray::num_moves方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveArray::num_moves方法的具体用法?C++ MoveArray::num_moves怎么用?C++ MoveArray::num_moves使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveArray
的用法示例。
在下文中一共展示了MoveArray::num_moves方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
case ChessIO::Number: {
num = tok.val;
break;
}
case ChessIO::GameMove: {
if (done) {
// we should not have moves after the result
// if it looks like a tag, push it back
if (tok.val.size() && tok.val[0] == '[') {
for (int i = (int)tok.val.size()-1; i >= 0; --i)
pgn_file.putback(tok.val[0]);
}
exit = true;
break;
}
// parse the move
Move m = Notation::value(board,side,Notation::InputFormat::SAN,tok.val);
if (IsNull(m) ||
!legalMove(board,StartSquare(m),
DestSquare(m))) {
// echo to both stdout and stderr
cerr << "Illegal move: " << tok.val << endl;
cout << "Illegal move: " << tok.val << endl;
ok = false;
}
else {
BoardState bs = board.state;
string img;
// convert to SAN
Notation::image(board,m,Notation::OutputFormat::SAN,img);
moves.add_move(board,bs,m,img,false);
board.doMove(m);
}
side = OppositeColor(side);
break;
}
case ChessIO::Unknown: {
if (done) {
// ignore unknown text after result
// if it looks like a tag, push it back
if (tok.val.size() && tok.val[0] == '[') {
for (int i = (int)tok.val.size()-1; i >= 0; --i)
pgn_file.putback(tok.val[0]);
}
exit = true;
break;
}
cerr << "Unrecognized text: " << tok.val << endl;
break;
}
case ChessIO::Comment: {
// ignored for now
break;
}
case ChessIO::Result: {
result = tok.val;
done = true;
break;
}
case ChessIO::OpenVar:
cerr << "Warning: variations not supported" << endl;
done = true;
default:
break;
} // end switch
}
// output header
string ecoC = "";
int found = ChessIO::get_header(hdrs,"ECO",ecoC);
if (!found) {
string name;
eco.classify(moves,ecoC,name);
if (ecoC != "") {
ChessIO::Header ecoHeader("ECO",ecoC.c_str());
hdrs.push_back(ecoHeader);
}
}
else if (ecoC == "") {
string name;
eco.classify(moves,ecoC,name);
if (ecoC != "") {
ChessIO::Header ecoHeader("ECO",ecoC.c_str());
for (auto it = hdrs.begin(); it != hdrs.end(); it++) {
const ChessIO::Header &hdr = *it;
if (hdr.tag() == "ECO") { // replace old header
*it = ecoHeader;
break;
}
}
}
}
if (moves.num_moves()>0) ChessIO::store_pgn(cout,moves,result,hdrs);
}
pgn_file.close();
}
}
return 0;
}