• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Rank函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TMpiException

 //____________________________________________________________________
 void TCommunicator::AllReduceRecvScalar(Float_t &recvScalar, const TOperation& operation)
 {
    if (!fAllReduceRootScalar.empty()) {
       recvScalar = fAllReduceRootScalar.front();
       fAllReduceRootScalar.pop();
    } else {
       throw TMpiException(MPI_ERR_BUFFER, Rank(), __METHOD_LONG__, ALL_REDUCE_MSG, -1, bShowExceptionMessage);
    }
 }
开发者ID:omazapa,项目名称:RootMpi,代码行数:10,代码来源:TCommunicatorAllReduce.cpp


示例17: InCheck

/* Tests to see if the side specified is in check.  */
int InCheck(const Board *B,const int side) {
  int kpos,kx,ky;
  BITBOARD rq,bq,r,b,q,mask,tsq;

   /* We don't have any precalculated attack information
    * so we'll have to do this the hard way */
 
   /* (1) Check for king attacks.  Note that if the white king
    * can attack the black one then vice versa too. */
  if (KingMoves[B->WhiteKing]&Mask[B->BlackKing]) return king;

   /* It's not a king attack so let's set up some more variables. */
  if (side==WHITE) kpos = B->WhiteKing;
  else             kpos = B->BlackKing;
  kx = File(kpos);
  ky = Rank(kpos);
   
   /* (2) Check for pawn and knight attacks */
  if (side==WHITE) {
    if (ky>1 && (PawnAttacksWhite[kpos] & B->BlackPawns)) return pawn;
    if (B->BlackKnights & KnightMoves[kpos]) return knight;
  }
  if (side==BLACK) {
    if (ky<6 && (PawnAttacksBlack[kpos] & B->WhitePawns)) return pawn;
    if (B->WhiteKnights & KnightMoves[kpos]) return knight;
  }

   /* (3) *sigh* We'll have to check for sliding pieces then.  This isn't actually
    * all that painful.  First of all set up bitboards holding the relevant enemy
    * piece locations. r=Rooks, b=Bishops, q=Queens */
  if (side==WHITE) {
    r = B->BlackRooks;
    q = B->BlackQueens;
    b = B->BlackBishops;
  }
  else {
    r = B->WhiteRooks;
    q = B->WhiteQueens;
    b = B->WhiteBishops;
  }
   /* Combined bitboard representing the locations of enemy rooks & queens */
  rq = r|q;
   
   /* (3a) Horizontal/Vertical sliders : Rooks and queens first */
   /* Solve this by inverting the problem - i.e. imagine the target king as
    * a rook/bishop/queen.  See where it can move, and then & these squares
    * with the board positions of the required piece.  If this is !=0 then
    * king is in check */
   
   /* Check for rooks/queens on this rank. */
  if (RankMask[ky] & rq) {
    mask = (B->All >> (ky*8)) & FullRank;
    tsq  = MovesRank[kpos][mask];
    if (tsq & r) return rook;
    if (tsq & q) return queen;
  }     
开发者ID:vollmerm,项目名称:TrappyBeowulf,代码行数:57,代码来源:checks.c


示例18: Card

// Prepare a deck by creating 52 cards
// 13 ranks per suit & 4 suit
void Deck::prepareDeck() {
    int cardCounter = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < RANK_COUNT; j++) {
            Card* card = new Card(Suit(i), Rank(j));
            cards_[cardCounter] = card;
            cardCounter++;
        }
    }
}
开发者ID:dcaoyz,项目名称:straights,代码行数:12,代码来源:Deck.cpp


示例19: Name

_TCHAR *LogBookData::NameWRank(void)
{
	if(gStringMgr)
	{
		_TCHAR *rank = gStringMgr->GetString(gRanksTxt[Rank()]);
		_stprintf(nameWrank,"%s %s",rank,Pilot.Name);
		return nameWrank;
	}
	return Name();
}
开发者ID:JagHond,项目名称:freefalcon-central,代码行数:10,代码来源:logbook.cpp


示例20: fIdx

/* uses rank() and c() to obtain the LastFirstFunc function */
int DynSuffixArray::LastFirstFunc(unsigned L_idx) {
  int fIdx(-1);
  //cerr << "in LastFirstFcn() with L_idx = " << L_idx << endl;
  unsigned word = m_L->at(L_idx);
  if((fIdx = F_firstIdx(word)) != -1) { 
    //cerr << "fidx + Rank(" << word << "," << L_idx << ") = " << fIdx << "+" << Rank(word, L_idx) << endl;
    fIdx += Rank(word, L_idx);
  }
  return fIdx;
}
开发者ID:obo,项目名称:Moses-Extensions-at-UFAL,代码行数:11,代码来源:DynSuffixArray.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Rast_close函数代码示例发布时间:2022-05-30
下一篇:
C++ Range函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap