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


C++ Rank函数代码示例

本文整理汇总了C++中Rank函数的典型用法代码示例。如果您正苦于以下问题:C++ Rank函数的具体用法?C++ Rank怎么用?C++ Rank使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: MoveToStr

void MoveToStr(int move, char *move_str) {

  static const char prom_char[5] = "nbrq";

  // Move coordinates

  move_str[0] = File(Fsq(move)) + 'a';
  move_str[1] = Rank(Fsq(move)) + '1';
  move_str[2] = File(Tsq(move)) + 'a';
  move_str[3] = Rank(Tsq(move)) + '1';
  move_str[4] = '\0';

  // Bugfix by Dave Kaye for compatibility with Knights GUI (Linux) and UCI specs
  // (needed if a GUI forces the engine to analyse in checkmate/stalemate position)

  if (strcmp(move_str, "a1a1") == 0) {
    strcpy(move_str, "0000");
  }

  // Add promoted piece, if any

  if (IsProm(move)) {
    move_str[4] = prom_char[(move >> 12) & 3];
    move_str[5] = '\0';
  }
}
开发者ID:raimarHD,项目名称:lcec,代码行数:26,代码来源:util.cpp

示例2: if

//recalculates legal card set after new card is played
void Table::updateLegalCards(Card card) { //only called if card is allowed
	int suit = card.getSuit();
	int rank = card.getRank();
	std::string cardName = card.getCardName(card.getRank(), card.getSuit());

	legalCards_.erase(cardName);
	//special case: 7S played opens all other 7's
	if (legalCards_.find("7S") == legalCards_.begin()) {
		legalCards_.insert("7C");
		legalCards_.insert("7D");
		legalCards_.insert("7H");
		legalCards_.insert("6S");
		legalCards_.insert("8S");
		legalCards_.erase("7S");
	}
	else if (rank == (7-1)) { //index of 7 is 1 less due to enum numeration
		legalCards_.insert(card.getCardName(Rank(card.getRank() - 1), card.getSuit()));
		legalCards_.insert(card.getCardName(Rank(card.getRank() + 1), card.getSuit()));
	}
	else if (rank == (13-1) || rank == (1-1)) {} //king and ace
	else if (rank < (7-1)) { //cards less than 7
		legalCards_.insert(card.getCardName(Rank(card.getRank() - 1), card.getSuit()));
	}
	else { //cards greater than 7
		legalCards_.insert(card.getCardName(Rank(card.getRank() + 1), card.getSuit()));
	}
}
开发者ID:ginellegaisano,项目名称:cs247_straights,代码行数:28,代码来源:Table.cpp

示例3: if

void Table::updateLegalCards(Card card) { //only called if card is allowed
	int suit = card.getSuit();
	int rank = card.getRank();
	std::string cardName = card.getCardName(card.getRank(), card.getSuit());

	legalCards_.erase(cardName);
	// std::cout << (legalCards_.find("7S") == legalCards_.end()) << std::endl;
	if (legalCards_.find("7S") == legalCards_.begin()) {
		legalCards_.insert("7C");
		legalCards_.insert("7D");
		legalCards_.insert("7H");
		legalCards_.insert("6S");
		legalCards_.insert("8S");
		legalCards_.erase("7S");
	}
	else if (rank == (7-1)) { //index of 7 is 1 less
		legalCards_.insert(card.getCardName(Rank(card.getRank() - 1), card.getSuit()));
		legalCards_.insert(card.getCardName(Rank(card.getRank() + 1), card.getSuit()));
	}
	else if (rank < (7-1)) {
		legalCards_.insert(card.getCardName(Rank(card.getRank() - 1), card.getSuit()));
	}
	else {
		legalCards_.insert(card.getCardName(Rank(card.getRank() + 1), card.getSuit()));
	}
}
开发者ID:Rcmak,项目名称:cs247_straights,代码行数:26,代码来源:Table.cpp

示例4: Opp

void cEval::ScorePawns(POS *p, eData *e, int sd) {

  U64 bbPieces, bbSpan, fl_phalanx;
  int sq, fl_unopposed, fl_weak, fl_defended; 
  int op = Opp(sd);
  U64 bbOwnPawns = p->Pawns(sd);
  U64 bbOppPawns = p->Pawns(op);

  // Is color OK?

  assert(sd == WC || sd == BC);

  // Loop through the pawns, evaluating each one

  bbPieces = bbOwnPawns;
  while (bbPieces) {
    sq = BB.PopFirstBit(&bbPieces);

    // Get some information about the pawn we are evaluating

    bbSpan = BB.GetFrontSpan(SqBb(sq), sd);
    fl_defended  = ((SqBb(sq) & e->bbPawnTakes[sd]) != 0);
    fl_unopposed = ((bbSpan & bbOppPawns) == 0);
    fl_weak      = ((Mask.supported[sd][sq] & bbOwnPawns) == 0);
    fl_phalanx   = (BB.ShiftSideways(SqBb(sq)) & bbOwnPawns);

    // Candidate passer

    if (fl_unopposed) {
      if (fl_phalanx) {
      if (BB.PopCnt((Mask.passed[sd][sq] & bbOppPawns)) == 1)
        Add(e, sd, F_PAWNS, passed_bonus_mg[sd][Rank(sq)] / 3, passed_bonus_eg[sd][Rank(sq)] / 3);
      }
    }

    // Doubled pawn

    if (bbSpan & bbOwnPawns)
      Add(e, sd, F_PAWNS, Param.doubled_malus_mg, Param.doubled_malus_eg);

    // Supported pawn

    if (fl_phalanx)       Add(e, sd, F_PAWNS, Param.phalanx[sd][sq] , 2);
    else if (fl_defended) Add(e, sd, F_PAWNS, Param.defended[sd][sq], 1);

    // Weak pawn (two flavours)

    if (fl_weak) {
      if (!(Mask.adjacent[File(sq)] & bbOwnPawns)) 
        Add(e, sd, F_PAWNS, 
		    Param.isolated_malus_mg + Param.isolated_open_malus * fl_unopposed,
			Param.isolated_malus_eg); // isolated pawn
      else 
        Add(e, sd, F_PAWNS, 
			Param.backward_malus_mg[File(sq)] + Param.backward_open_malus * fl_unopposed, 
			Param.backward_malus_eg); // backward pawn
    }
  }
}
开发者ID:raimarHD,项目名称:lcec,代码行数:59,代码来源:eval_pawns.cpp

示例5: Count

	int Count(DATA data){
		bool exi=Find(data);
		if (exi){
			int aaa=Rank(data);
			int bbb=Rank(data());
			return bbb-aaa;
		}
		else return 0;
	}
开发者ID:williamking5,项目名称:template,代码行数:9,代码来源:treap.cpp

示例6: Find

void TUnionFind::Union(const int& Key1, const int& Key2) {
  const int root1 = Find(Key1);
  const int root2 = Find(Key2);
  TInt& rank1 = Rank(root1);
  TInt& rank2 = Rank(root2);
  if (rank1 > rank2) { Parent(root2) = root1; }
  else if (rank1 < rank2) { Parent(root1) = root2; }
  else if (root1 != root2) {
    Parent(root2) = root1;
    Rank(root1)++;
  }
}
开发者ID:FlyClover,项目名称:movieinf,代码行数:12,代码来源:gbase.cpp

示例7: init_distance

void init_distance()
{
  int i,j,f[2],r[2];
	
  for(i = 0; i < 64; i++)
  { f[0] = File(i);
    r[0] = Rank(i);
    for(j = 0; j < 64; j++)
    { f[1] = File(j);
      r[1] = Rank(j);
      distance[i][j] = max(abs(r[0]-r[1]), abs(f[0]-f[1]));
    }
  }
}
开发者ID:JERUKA9,项目名称:lucaschess,代码行数:14,代码来源:magics.c

示例8: m_data

    Value::Value(const NDArrayViewPtr& data, const NDMaskPtr& mask)
        : m_data(data), m_mask(mask)
    {
        if (mask != nullptr)
        {
            auto dataShape = data->Shape();
            auto maskShape = mask->Shape();

            if (maskShape.Rank() > dataShape.Rank())
                InvalidArgument("The rank (%d) of the mask of a Value object cannot exceed the rank (%d) of the data NDArrayView object", (int)maskShape.Rank(), (int)dataShape.Rank());

            if (dataShape.SubShape(dataShape.Rank() - maskShape.Rank()) != maskShape)
                InvalidArgument("Invalid Value object; the data and mask are incompatible. The trailing dimensions of the data with shape %S do not match the dimensions of the mask with shape %S", AsStringForErrorReporting(dataShape).c_str(), AsStringForErrorReporting(maskShape).c_str());
        }
    }
开发者ID:hahatt,项目名称:CNTK,代码行数:15,代码来源:Value.cpp

示例9: Rank

 int Rank(int &root , Type key)
 {
     if ( K[root] == key )
     {
         return SZ[LC[root]] + 1;
     }
     else if ( key < K[root] )
     {
         return Rank(LC[root], key);
     }
     else
     {
         return SZ[LC[root]] + 1 + Rank(RC[root] , key);
     }
 }
开发者ID:fanshaoze,项目名称:acm-codes,代码行数:15,代码来源:NOTONLLY的SBT模板.cpp

示例10: PrintSubTree

void PrintSubTree(FILE *OutFile, TreeNode Node, int Indent)
{
   int i,itsrank,itslocation;

   itsrank = Rank(Node);
   fprintf(OutFile, "[%5d]   ", Node);

   for (i=1; i <= Indent; i++)
      fprintf(OutFile,". ");

   Write_String(OutFile, NodeName(Node));
   fprintf(OutFile ,"(%1d)", itsrank);
   itslocation = SourceLocation(Node);

   if(itslocation!=UndefinedString)
   {
      fprintf (OutFile, " @ ");
      Write_String(OutFile, itslocation);
   }

   if (Decoration(Node) != 0)
      fprintf(OutFile, " Decoration: %1d", Decoration(Node));

   fprintf(OutFile,"\n");
 
   for (i=1; i <= itsrank; i++)
      PrintSubTree (OutFile, Child(Node, i), Indent+1);
}
开发者ID:MARFMS,项目名称:chiquitico,代码行数:28,代码来源:Tree.c

示例11: getPassedPawnScore

int getPassedPawnScore(ChessBoard * board, bool white) {
	BITBOARD pawns = (white) ? board->whitePawns : board->blackPawns;
	BITBOARD originalPawns = pawns;
	BITBOARD otherPawns = (white) ? board->blackPawns : board->whitePawns;
	BITBOARD* doubledPawnMask = (white) ? whiteDoubledPawnMask : blackDoubledPawnMask;
	BITBOARD* passedPawnMask = (white) ? whitePassedPawnMask : blackPassedPawnMask;
	int* passedPawnRankScale = (white) ? EvalParameters::whitePassedPawnRankScale : EvalParameters::blackPassedPawnRankScale;

	int passedPawnScore = 0;

	while (pawns != 0) {
		short pawnOffset = FirstOne(pawns);
		pawns ^= offset_to_mask(pawnOffset);

		if ((passedPawnMask[pawnOffset] & otherPawns) == 0) {
			// pawn is passed.  give bonus

		        // check if pawn is doubled
                        BITBOARD isDoubled = doubledPawnMask[pawnOffset] & originalPawns;

			if (isDoubled == 0) {
			  if (board->gamePhase == PHASE_ENDGAME) {
			    passedPawnScore += EvalParameters::passedPawnBonus * passedPawnRankScale[8 - Rank(pawnOffset)];
			  }
			  else {
			    passedPawnScore += (1/4.0) * EvalParameters::passedPawnBonus * passedPawnRankScale[8 - Rank(pawnOffset)];
			  }
			}

			// no passed pawn bonus if pawn is doubled
		}
	}

	return passedPawnScore;
}
开发者ID:tildedave,项目名称:apep-chess-engine,代码行数:35,代码来源:eval.cpp

示例12: SquareFactory

void ribi::Chess::QtChessBoardWidget::DrawChessBoard(
  QPainter& painter,
  const int left, const int top,
  const int width, const int height,
  const Chess::Board * const board)
{
  static const Chess::QtResources r;
  const int square_w = width  / 8;
  const int square_h = height / 8;
  for (int y=0; y!=8; ++y)
  {
    for (int x=0; x!=8; ++x)
    {
      const int x_co = x * square_w;
      const int y_co = y * square_h;
      const boost::shared_ptr<Square> square {
        SquareFactory().Create(File(x),Rank(y))
      };
      if (board->GetPiece(square))
      {
        const QPixmap p(r.Find(board->GetPiece(square)).c_str());
        painter.drawPixmap(left + x_co,top + y_co,square_w,square_h,p);
      }
      else
      {
        const QPixmap p(r.Find(square).c_str());
        painter.drawPixmap(left + x_co,top + y_co,square_w,square_h,p);
      }
    }
  }
}
开发者ID:richelbilderbeek,项目名称:RibiClasses,代码行数:31,代码来源:qtchessboardwidget.cpp

示例13: Add

void Add()
{
	if(kamo==0){
		puts("データを作成するか、ファイルを読み込んでください");
		return;
	}
	String name[NIN];
	int i,s[KAMO_MAX];
	printf("No%dの名前を入力してください\n",(preno++)+1);
	printf("→");
	
	name[preno]=(String)malloc(STLEN);
	scanf("%s",name[preno]);
	fflush(stdin);
	while(strcmp(name[preno],"0")!=0){
		puts("点数を入力してください");
		for(i=0;i<kamo;i++){
			printf("%s : ",kam[i]);
			scanf("%d",&s[i]);
			fflush(stdin);
		}
		addData(preno,name[preno],s);
		printf("No%dの名前を入力してください\n",(preno++)+1);
		printf("→");
		name[preno]=(String)malloc(STLEN);
		scanf("%s",name[preno]);
		fflush(stdin);
	}
	preno--;
	Rank();
}
开发者ID:Zaukey,项目名称:SchoolDB,代码行数:31,代码来源:seie.c

示例14: BOW

	/*
	This api takes the user input - and looks up the word[s] in the inverted index.
	The candidate documents are then ranked based on tf-idf BOW (bag of words) model
	*/
	std::vector<std::pair<int,double> > ServeIndex(const std::string& word,int topK)
	{
		//tokenize and normalize the user text
		std::vector<std::string>& word_tokens = _wordBreaker->BreakEnglishText(word.c_str());

		std::vector<std::pair<int,double> > results;

		//generate the candidate document set
		std::set<int> candSet;
		bool foundAny = false;
		for(size_t i=0;i<word_tokens.size();++i)
		{
			boost::unordered_map<std::string,IndexEntry>::iterator itor = _indexPtr->_wordIndex.find(word_tokens[i]);

			if( itor == _indexPtr->_wordIndex.end() )
				continue;

			else{
				//first entry which was found
				if(!foundAny){
					candSet = itor->second._docSet;
					foundAny = true;
				} else{
					std::set<int> temp;
					set_intersection(candSet.begin(),candSet.end(),(itor->second)._docSet.begin(),(itor->second)._docSet.end(),inserter(temp,temp.begin()));
					candSet.clear();
					candSet = temp;
				}
			}

		}

		return Rank(word_tokens,candSet,topK);
	}
开发者ID:siddharthdave,项目名称:IndexBuilder,代码行数:38,代码来源:IndexBuilder.cpp

示例15: clear

void Deck::reset () {
    clear ();
    for(int i=0;i<SUIT_COUNT;i++){
        for (int j=0;j<RANK_COUNT;j++){
            addCard (Card (Suit(i), Rank(j)));
        }
    }
}
开发者ID:tlulu,项目名称:Straights,代码行数:8,代码来源:Deck.cpp


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