当前位置: 首页>>代码示例>>C++>>正文


C++ MoveArray::num_moves方法代码示例

本文整理汇总了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;
}
开发者ID:jdart1,项目名称:arasan-chess,代码行数:101,代码来源:ecocoder.cpp


注:本文中的MoveArray::num_moves方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。