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


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

本文整理汇总了C++中MoveArray::add_move方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveArray::add_move方法的具体用法?C++ MoveArray::add_move怎么用?C++ MoveArray::add_move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoveArray的用法示例。


在下文中一共展示了MoveArray::add_move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int CDECL main(int argc, char **argv)
{
   Bitboard::init();
   Attacks::init();
   Scoring::init();
   if (!initGlobals(argv[0], false)) {
      cleanupGlobals();
      exit(-1);
   }
   atexit(cleanupGlobals);

   Board board;
   ECO eco;
   int arg = 1;

   if (argc <=1)
   {
      show_usage();
      return -1;
   }
   else
   {
      ifstream pgn_file( argv[arg], ios::in | ios::binary);
      int c;
      ColorType side;
      string result, white, black;
      if (!pgn_file.good()) {
         cerr << "could not open file " << argv[arg] << endl;
         exit(-1);
      }
      else
      {
         vector<ChessIO::Header> hdrs;
         while (!pgn_file.eof())
         {
            long first;
            MoveArray moves;
            board.reset();
            side = White;
            while (pgn_file.good() && (c = pgn_file.get()) != EOF)
            {
               if (c=='[')
               {
                  int c1 = pgn_file.get();
                  if (c1 == 'E') {
                     int c2 = pgn_file.get();
                     if (c2 == 'v') {
                        pgn_file.putback(c2);
                        pgn_file.putback(c1);
                        pgn_file.putback(c);
                        break;
                     }
                  }
               }
            }
            hdrs.clear();
            ChessIO::collect_headers(pgn_file,hdrs,first);
            if (!hdrs.size()) continue;
            bool ok = true;
            bool done = false;
            bool exit = false;
            while (ok && !exit) {
               ChessIO::Token tok = ChessIO::get_next_token(pgn_file);
               string num;
               switch (tok.type) {
               case ChessIO::Eof: {
                  exit = true;
                  break;
               }
               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);
//.........这里部分代码省略.........
开发者ID:jdart1,项目名称:arasan-chess,代码行数:101,代码来源:ecocoder.cpp


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