示例#1
0
文件: search.cpp 项目: lennonc/Chess
void Board::displaySearchStats(int mode, int depth, int score)
{
  // displays various search statistics
  // only to be used when ply = 0
  // mode = 1 : display header
  // mode = 2 : display full stats, including score and latest PV
  // mode = 3 : display current root move that is being searched
  //                     depth = ply, score = loop counter in the search move list
  
  char sanMove[12];
  U64 dt, hh, mm, ss;
  
  switch (mode)
  {
    case 1:
      std::cout << "depth  score   nodes     time  knps PV" << std::endl;
      break;
      
    case 2:
      dt = msStop - msStart;
      
      // depth
      printf("%5d ", depth);
      
      // score
      printf("%+6.2f ", float(score/100.0));
      
      // nodes searched
      if      (inodes > 100000000) printf("%6.0f%c ", float(inodes/1000000.0), 'M');
      else if (inodes > 10000000) printf("%6.2f%c ", float(inodes/1000000.0), 'M');
      else if (inodes > 1000000) printf("%6.0f%c ", float(inodes/1000.0),    'K');
      else if (inodes > 100000)  printf("%6.1f%c ", float(inodes/1000.0),    'K');
      else if (inodes > 10000)   printf("%6.2f%c ", float(inodes/1000.0),    'K');
      else                                     printf("%7d ", inodes);
      
      // search time
      if (dt > 3600000)
      {     
        hh = dt/3600000;
        mm = (dt - 3600000*hh)/60000;
        ss = (dt - 3600000*hh - 60000*mm)/1000;
        printf("%02d%c", hh, ':');
        printf("%02d%c", mm, ':');
        printf("%02d ", ss);
      }
      else if (dt > 60000)
      {     
        mm = dt/60000;
        ss = (dt - 60000*mm)/1000;
        printf("   %02d%c", mm, ':');
        printf("%02d ", ss);
      }
      else if (dt > 10000)       printf(" %6.1f%c ", float(dt/1000.0), 's');
      else if (dt > 1000)               printf(" %6.2f%c ", float(dt/1000.0), 's');
      else if (dt > 0)                  printf(" %5dms ", dt);
      else                                     printf("     0ms ");
      
      // search speed
      if (dt > 0) std::cout << std::setw(5) << (inodes/dt) << " ";
      else          std::cout << "    - ";
      
      // store this PV:
      rememberPV();
      
      // display the PV
      displayPV();
      break;
      
    case 3: // Note that the numbers refer to pseudo-legal moves:
      printf("%12s (%2d/%2d)%16s", " ", score+1, moveBufLen[depth+1]-moveBufLen[depth], " ");
      unmakeMove(moveBuffer[score]);
      toSan(moveBuffer[score], sanMove);
      std::cout << sanMove;
      makeMove(moveBuffer[score]);
      //                         printf("...    \n");
      printf("...    \r");
      std::cout.flush();
      break;
      
    default: break;
  }
  
  return;
}
示例#2
0
void Board::displaySearchStats(int mode, int depth, int score)
{
	// displays various search statistics
	// only to be used when ply = 0
	// mode = 1 : display header
	// mode = 2 : display full stats, including score and latest PV
	// mode = 3 : display current root move that is being searched
	//			  depth = ply, score = loop counter in the search move list 

	//char timestring[8];
	U64 dt;

	dt = timer.getms() - msStart;
	switch (mode)
	{
		case 1: 
				//LC if (!XB_MODE) std::cout << "depth  score   nodes     time  knps PV" << std::endl;
				break;

		case 2:
				if (XB_MODE && XB_POST)
				{
					//LC printf("%5d %6d %8d %9d ", depth, score, dt/10, inodes);
					rememberPV();
					displayPV();
				}
				else
				{
					// depth
					//LC printf("%5d ", depth);

					// score
					//LC printf("%+6.2f ", float(score/100.0));

					// nodes searched
					//LC if      (inodes > 100000000) printf("%6.0f%c ", float(inodes/1000000.0), 'M');
					//LC else if (inodes > 10000000)	 printf("%6.2f%c ", float(inodes/1000000.0), 'M');
					//LC else if (inodes > 1000000)	 printf("%6.0f%c ", float(inodes/1000.0),    'K');
					//LC else if (inodes > 100000)	 printf("%6.1f%c ", float(inodes/1000.0),    'K');
					//LC else if (inodes > 10000)	 printf("%6.2f%c ", float(inodes/1000.0),    'K');
					//LC else						 printf("%7d ", inodes);

					// search time
					//mstostring(dt, timestring);
					//LC printf("%8s ", timestring);

					// search speed
					//LC if (dt > 0) std::cout << std::setw(5) << (inodes/dt) << " ";
					//LC else		std::cout << "    - ";

					// store this PV:
					rememberPV();

					// display the PV
					//LC displayPV();
				}
				break;

		case 3: // Note that the numbers refer to pseudo-legal moves:
				if (!TO_CONSOLE) break;
				if (XB_MODE)
				{

				}
				else
				{
					//LC mstostring(dt, timestring);
					//LC printf("             (%2d/%2d) %8s       ", score+1, moveBufLen[depth+1]-moveBufLen[depth], timestring);
					//LC unmakeMove(moveBuffer[score]);
					//LC toSan(moveBuffer[score], sanMove);
					//LC std::cout << sanMove;
					//LC makeMove(moveBuffer[score]);
					//LC printf("...    \r");
					//LC std::cout.flush();
				}
				break;

		default: break;
	}

	return;
}