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


C++ Move::Copy方法代码示例

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


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

示例1: GetBestMove

//--------------------------------------------------------------------------
//       Class:  AlphaBetaMemory
//      Method:  GetBestMove
// Description:  Return the best move available for the given side as
//               determined by the search algorithm
//--------------------------------------------------------------------------
Move* AlphaBetaMemory::GetBestMove(int side) 
{
   bool winningMove = false;
   int alpha = mAlpha;
   int beta =  mBeta;
   int score;
   PRECISION_TIME startTime, finishTime;
   
   vector<Move> movelist;
   vector<Move> line;

   Move* bestmove = 0;
   Move* move = 0;
   
   // Increase the time stamp indicator
   TranspositionTable::sTimeStamp++;
   
   // Get the start time for the search
   GET_PRECISION_TIME(startTime);
   
   // For which side are we searching?
   mSide = side;

   // Generate all legal moves for the first ply
   mpMoveGenerator->GenerateMoves(movelist, side);

   // Perform a special move sort for the root of the search
   SortRootChildren(winningMove, movelist);

   // We're done if we found a winning move during the sort
   if (winningMove) {
      mPVScore = MAXIMUM_SCORE;
      mPrincipleVariation.push_back( movelist.back() );
      bestmove = new Move( movelist.back() );
   }
   else {
      // Prep the search
      PrepareSearch();
      
      // Clear out the line
      line.clear();
      
      mPVScore = MINIMUM_SCORE;
      // Initialize our optimal move, line, and score
      if (!movelist.empty()) {
         bestmove = new Move( movelist.back() );
         mPrincipleVariation.push_back(*bestmove);
      }

      // Initialize values for monitoring whether we need to stop
      mNextCheck = NODES_BETWEEN_TIME_CHECKS;
      mAbort = false;
      
      // Recursively search each move
      do {
         move = &(movelist.back());
         if (!move->mValidate || mpGame->IsValid(move, side)) {
            mNodes++; // Count the nodes that we've search

            mpRepTable->AddKey( mpBoard->MakeMove(move) );
            PRINT_DESCENT(0, alpha, beta, move, "Root");
            score = -DoSearch(1, -beta, -alpha, line);
            if (score > mPVScore) {
               bestmove->Copy(*move);
               
               mPVScore = score;
               mPrincipleVariation.clear();
               mPrincipleVariation.push_back(*move);
               mPrincipleVariation.insert(mPrincipleVariation.end(), 
                                          line.begin(), line.end());
            }

            mpRepTable->RemoveKey( mpBoard->UnmakeMove(move) );
            PRINT_SCORE(0, score, alpha, beta);
            if (mAbort) break;
            
            if (score > alpha) { // Update alpha
               alpha = score;
            }
         }
         
         movelist.pop_back();
      } while( !movelist.empty() );
   }
   
   // Get the finish time for the search
   GET_PRECISION_TIME(finishTime);

   // Calculate the time difference in fractional seconds
   DIFF_PRECISION_TIME(mSeconds, finishTime, startTime); 
   
   return bestmove;
}
开发者ID:jweathers777,项目名称:mShogi,代码行数:99,代码来源:AlphaBetaMemory.cpp


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