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


C++ Bird::getSeqLength方法代码示例

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


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

示例1: shoot

  Action Player::shoot(const GameState &pState, const Deadline &pDue) {
    if (lastRound != pState.getRound()) {
      hmm.clear();

      for (unsigned int i = 0; i < pState.getNumBirds(); ++i) {
        HMM hmm1(this -> STATES, this -> DIRECTIONS);
        hmm.push_back(hmm1);
      }
    }

    for (unsigned int i = 0; i < pState.getNumBirds(); ++i) {
      Bird b = pState.getBird(i);
      if (b.isDead())
        continue;

      int n = b.getSeqLength();

      // if (n < THRESHOLD || pState.getRound() == 0)
      //   continue;

      std::vector<int> seq(n, 0);
      for (int j = 0; j < n; ++j) {
        seq[j] = b.getObservation(j);
      }

      hmm[i].estimateMatrices(seq);

      std::vector<long double> em = hmm[i].getNextEmissionDist();
      long double max = -1;
      int nextMove = -1;
      for (int j = 0; j < DIRECTIONS; ++j) {
        if (em[j] > max) {
          max = em[j];
          nextMove = j;
        }
      }

      if (max > MIN_PROBABILITY) {
        std::cerr << "Shooting with prob: " << max << std::endl;
        hmm[i].printTransitionMatrix();
        hmm[i].printEmissionMatrix();
        std::cerr << std::endl << std::endl;
        ++shots;
        return Action(i, (EMovement)nextMove);
      }
    }

    // cerr << "Shots: " << shots << endl;
    // cerr << "Hits:  " << hits << endl;
    // if (shots != 0) 
    //   cerr << "Rate:  " << (double) hits / (double) shots << endl << endl;

    // This line choose not to shoot
    return cDontShoot;
  }
开发者ID:fristedt,项目名称:ai14,代码行数:55,代码来源:Player.cpp


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