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


C++ MaterialInfo::clear方法代码示例

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


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

示例1: if

MaterialInfo *MaterialInfoTable::get_material_info(const Position &pos) {
  Key key = pos.get_material_key();
  int index = key & (size - 1);
  MaterialInfo *mi = entries + index;

  // If mi->key matches the position's material hash key, it means that we 
  // have analysed this material configuration before, and we can simply
  // return the information we found the last time instead of recomputing it:
  if(mi->key == key)
    return mi;

  // Clear the MaterialInfo object, and set its key:
  mi->clear();
  mi->key = key;

  // A special case before looking for a specialized evaluation function:
  // KNN vs K is a draw:
  if(key == KNNKMaterialKey || key == KKNNMaterialKey) {
    mi->factor[WHITE] = mi->factor[BLACK] = 0;
    return mi;
  }

  // Let's look if we have a specialized evaluation function for this
  // particular material configuration:
  if(key == KPKMaterialKey) {
    mi->evaluationFunction = &EvaluateKPK;
    return mi;
  }
  else if(key == KKPMaterialKey) {
    mi->evaluationFunction = &EvaluateKKP;
    return mi;
  }
  else if(key == KBNKMaterialKey) {
    mi->evaluationFunction = &EvaluateKBNK;
    return mi;
  }
  else if(key == KKBNMaterialKey) {
    mi->evaluationFunction = &EvaluateKKBN;
    return mi;
  }
  else if(key == KRKPMaterialKey) {
    mi->evaluationFunction = &EvaluateKRKP;
    return mi;
  }
  else if(key == KPKRMaterialKey) {
    mi->evaluationFunction = &EvaluateKPKR;
    return mi;
  }
  else if(key == KRKBMaterialKey) {
    mi->evaluationFunction = &EvaluateKRKB;
    return mi;
  }
  else if(key == KBKRMaterialKey) {
    mi->evaluationFunction = &EvaluateKBKR;
    return mi;
  }
  else if(key == KRKNMaterialKey) {
    mi->evaluationFunction = &EvaluateKRKN;
    return mi;
  }
  else if(key == KNKRMaterialKey) {
    mi->evaluationFunction = &EvaluateKNKR;
    return mi;
  }
  else if(key == KQKRMaterialKey) {
    mi->evaluationFunction = &EvaluateKQKR;
    return mi;
  }
  else if(key == KRKQMaterialKey) {
    mi->evaluationFunction = &EvaluateKRKQ;
    return mi;
  }
  else if(key == KBBKNMaterialKey) {
    mi->evaluationFunction = &EvaluateKBBKN;
    return mi;
  }
  else if(key == KNKBBMaterialKey) {
    mi->evaluationFunction = &EvaluateKNKBB;
    return mi;
  }
  else if(pos.non_pawn_material(BLACK) == Value(0) &&
          pos.pawn_count(BLACK) == 0 &&
          pos.non_pawn_material(WHITE) >= RookValueEndgame) {
    mi->evaluationFunction = &EvaluateKXK;
    return mi;
  }
  else if(pos.non_pawn_material(WHITE) == Value(0) &&
          pos.pawn_count(WHITE) == 0 &&
          pos.non_pawn_material(BLACK) >= RookValueEndgame) {
    mi->evaluationFunction = &EvaluateKKX;
    return mi;
  }
  else if(pos.pawns() == EmptyBoardBB && pos.rooks() == EmptyBoardBB
          && pos.queens() == EmptyBoardBB) {
    // Minor piece endgame with at least one minor piece per side,
    // and no pawns.
    assert(pos.knights(WHITE) | pos.bishops(WHITE));
    assert(pos.knights(BLACK) | pos.bishops(BLACK));

    if(pos.bishop_count(WHITE) + pos.knight_count(WHITE) <= 2
//.........这里部分代码省略.........
开发者ID:GordCaswell,项目名称:lucaschessportable,代码行数:101,代码来源:material.cpp


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