コード例 #1
0
ファイル: SuperHero.cpp プロジェクト: durecat/OOP244_Workshop
  std::ostream& SuperHero::display(std::ostream& os) const{
    if (!empty()){ 
      os << name() << "- " << strength() << endl;
      if (_size_of_powers > 0){        
        os << "Superhero's powers:" << endl;
        for (int i = 0; i < _size_of_powers; i++){
          os << _powers[i] << "-";
          if (_powers[i] == 0)
            os << "failed power";
          else if (_powers[i] >= 1 && _powers[i] <= 10)
            os << "firebolt";
          else if (_powers[i] >= 11 && _powers[i] <= 20)
            os << "invisibility";
          else if (_powers[i] >= 21 && _powers[i] <= 30)
            os << "double strength";
          else if (_powers[i] >= 31 && _powers[i] <= 40)
            os << "shield";
          else if (_powers[i] > 40)
            os << "speed";
          os << endl;
        }
      }
      else
        os << "No Powers!" << endl;
    }

    return os;
  }
コード例 #2
0
Position MotionDetector::identifyObjectPositionByWithMotionStrength(cv::Mat& frame, 
                                                              const double threshold) {
  cv::Size s = frame.size();
  int gridWidthLen = gridWidth_.size();
  std::vector<double> strength(gridWidthLen, 0);

  double maxStrength = -1, sumStrength = 0;
  int maxStrengthRegion = -1;

  for (int i = 0; i < gridWidthLen; ++i) {
    int yStart = (1 - gridSepPos_[i+1]) * s.width;
    int yEnd = (1 - gridSepPos_[i]) * s.width;
    cv::Mat regionMat = frame(cv::Range::all(), 
                              cv::Range(yStart, yEnd));
    strength[i] = cv::sum(regionMat).val[0];
    if (strength[i] > maxStrength) {
      maxStrength = strength[i];
      maxStrengthRegion = i;
    }
    sumStrength += strength[i];
  }
  if (maxStrength / sumStrength  <  threshold / gridWidthLen) {
    return -1;
  }
  return maxStrengthRegion;
}
コード例 #3
0
ファイル: controller.cpp プロジェクト: StefanoMunari/qDB
QList<int>* Controller::search(QString txt,const int& c) const{
    QList<int>* indexlist=0;
    if( !model.empty() && !txt.isEmpty() )//se il db non è vuoto e c'è un valore su cui eseguire la ricerca
    {
        switch(c){
        case 0://Name
            indexlist=model.find(name(txt.toStdString()));//funtori
            break;
        case 1://Type
            indexlist=model.find(type(txt.toStdString()));
            break;
        case 2://HP
            indexlist=model.find(hp(txt.toShort()));
            break;
        case 3://MP
            indexlist=model.find(mp(txt.toShort()));
            break;
        case 4://LV
            indexlist=model.find(lv(txt.toShort()));
            break;
        case 5://Strength
            indexlist=model.find(strength(txt.toShort()));
            break;
        case 6://Constitution
            indexlist=model.find(constitution(txt.toShort()));
            break;
        case 7://Wisdom
            indexlist=model.find(wisdom(txt.toShort()));
            break;
        }
    }
        return indexlist;
}
コード例 #4
0
ファイル: homework_2_2.c プロジェクト: RanHuang/Hello-World
int main(int argc, char *argv[])
{
	int input;
	scanf("%d", &input);

	printf("%s, %s.\n", strength(input % 10), readability(input / 10));

	return 0;
}
コード例 #5
0
void ReinforcementCoOcurrenceEquation::reWeight(Link &l) {
    float delta_t = this->time - l.getTime();
    l.setTime(this->time);
    double weight = l.getWeight();
    weight = weight + learningRate * (strength(delta_t) - weight);
    //printf("delta_t = %f\tfinal: %f  \n",delta_t, weight);
    //fflush(stdout);
    l.setWeight(weight);
    this->time++;
}
コード例 #6
0
 virtual std::string toString() const { 
   std::stringstream ss; 
   ss << Base::toString() 
      << " fReference="      << fReference()
      << " strength="        << strength()
      << " averageStrength=" << averageStrength()
      << " strengthRMS="     << strengthRMS()
      << " bandwidth="       << bandwidth();
   return ss.str();
 }
コード例 #7
0
ファイル: connectome.cpp プロジェクト: johnsonjonaris/CoNECt
void Connectome::computeMetrics()
{
    if (NW.is_empty())
        return;
    // local metrics order:
    // strength, degree, PL, eff, vul, CC, betweeness,
    // PC, Z-score, modularity, rich-club
    // nodal local metrics

    uint n = NW.n_rows;
    localMetrics.set_size(11,n);
    localMetrics.row(0) = strength(NW);                 // strength
    localMetrics.row(1) = degree(NW);                   // degree
    pl = pathLength(1/NW);
    pl(find(pl == datum::inf)).fill(0);
    localMetrics.row(2) = sum(pl,0)/n;                  // path length
    localMetrics.row(3) = localEfficiency(NW);          // efficiency
    localMetrics.row(4) = vulnerability(NW);            // vulnerability

    localMetrics.row(5) = clusteringCoeff(NW);          // CC
    localMetrics.row(6) = betweenessCentrality(1/NW,    // betweeness: Hubs
                                               edgeBetweeness);
    // Even though modularity is not a local metric, however,
    // the output have a number of elements = number of nodes
    double Q;
    urowvec Ci = modularity_louvain(NW,&Q);
    localMetrics.row(7)=participationCoefficient(NW,Ci);// participation coeff
    localMetrics.row(8) = moduleZscore(NW,Ci);          // Z score

    localMetrics.row(9) = conv_to<rowvec>::from(Ci);    // modularity
    localMetrics.row(10) = richClub(NW,-1);             // rich club

    // global metrics order:
    // Strength_mean, degree_mean, CCmean,
    // Q modularity, CPL, GE, trans, density
    // assortativity
    globalMetrics.set_size(10,1);
    globalMetrics(0) = mean(localMetrics.row(0));   // mean strength
    globalMetrics(1) = mean(localMetrics.row(1));   // mean degree
    globalMetrics(2) = mean(localMetrics.row(5));   // mean CC
    globalMetrics(3) = Q;                           // modularity
    globalMetrics(4) = accu(pl)/(n*n-n);            // CPL
    // reusing computed shortest path to compute GE
    mat invPL = 1/pl;
    invPL(find(invPL == datum::inf)).fill(0);
    globalMetrics(5) = accu(invPL)/(n*n-n);         // global eff
    globalMetrics(6) = transitivity(NW);            // transitivity
    globalMetrics(7) = density(NW);                 // density
    globalMetrics(8) = assortativity(NW);           // assortativity
    globalMetrics(9) = 0.0;

    metricsExist = true;
}
コード例 #8
0
ファイル: npc.cpp プロジェクト: BackupTheBerlios/wolfpack-svn
void cNPC::applyDefinition( const cElement *sectionNode )
{
	cBaseChar::applyDefinition( sectionNode );

	// Let's try to assume some unspecified values
	if ( this->strength() && !this->hitpoints() ) // we don't want to instantly die, right?
	{
		if ( !this->maxHitpoints() )
			setMaxHitpoints( strength() );
		setHitpoints( maxHitpoints() );
	}
}
コード例 #9
0
ファイル: Player.cpp プロジェクト: Garchbold/minirogue
void Player::attack(Actor* monster){
    
    //check if the function input is acually a monster through dynamic cast
    Monster* temp = dynamic_cast<Monster*>(monster);
    string monsterName;
    char c = temp->getType();
    
    //check the monsters type and based on that, assign monsterName a specific name
    switch (c) {
        case 'S':
            monsterName = " a Snakewoman";
            break;
        case 'B':
            monsterName = " a Boogeyman";
            break;
        case 'D':
            monsterName = " a Dragon";
            break;
        case 'G':
            monsterName = " a Goblin";
            break;
            
        default:
            break;
    }
    
    //check if the players attackerPoints are greater than the monsters defenderPoints
    if (randInt(dexterity() + equiped->dex_bonus) >= randInt(monster->dexterity() + monster->armor())) {
        
        //subtract the inflicted damage from the monster
        monster->setHealth(monster->health() - randInt(strength() + equiped->str_bonus));
        
        //if the user is using MagicFangs and probablilty is greater than 1/3 then put the monster to sleep
        if (equiped->m_name == "Magic fangs of sleep") {
            if(trueWithProbability(.3)){
                monster->setSleep(2+randInt(5));
                //add an action to action vector
                dungeon()->action_vector.push_back("Player" + equiped->action() + monsterName+" and puts him to sleep.");
            }
            else
                //add an action saying that the player hit but did not put to sleep
                dungeon()->action_vector.push_back("Player" + equiped->action()  +monsterName + " and hits.");
        }
        else
            //add an action saying that the player hit
            dungeon()->action_vector.push_back("Player" + equiped->action()  +monsterName + " and hits.");
    }
    else
        //add an action saying that the player missed
        dungeon()->action_vector.push_back("Player" + equiped->action() + monsterName+ " and misses.");

}
コード例 #10
0
ファイル: connectome.cpp プロジェクト: johnsonjonaris/CoNECt
/**
  *
  * The assortativity coefficient is a correlation coefficient between the
  * strengths (weighted degrees) of all nodes on two opposite ends of a link.
  *  A positive assortativity coefficient indicates that nodes tend to link to
  *  other nodes with the same or similar strength.

  *      Inputs:     CIJ,    weighted directed/undirected connection matrix
  *      Outputs:    r,      assortativity coefficient

  * Notes: The function accepts weighted networks, but all connection
  * weights are ignored. The main diagonal should be empty. For flag 1
  * the function computes the directed assortativity described in Rubinov
  * and Sporns (2010) NeuroImage.

  * Reference:  Newman (2002) Phys Rev Lett 89:208701
  *             Foster et al. (2010) PNAS 107:10815–10820
  */
double Connectome::assortativity(const mat &W)
{
    rowvec str = strength(W);
    mat Wt = trimatu(W); Wt.diag().fill(0);
    umat idx = getIndex(find(Wt>0),W.n_rows,W.n_cols,0);
    uint K = idx.n_rows;
    vec stri = str(idx.col(0));
    vec strj = str(idx.col(1));
    double  a = accu(stri%strj)/K,
            b = accu(0.5*(stri+strj))/K,
            c = accu(0.5*(pow(stri,2)+pow(strj,2)))/K;
    return (a-b*b)/(c-b*b);
}
コード例 #11
0
int QGraphicsColorizeEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsEffect::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 4)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 4;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 1: *reinterpret_cast< qreal*>(_v) = strength(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setStrength(*reinterpret_cast< qreal*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #12
0
/**
    \fn configure
*/
bool Msharpen::configure(void)
{
uint8_t r=0;

#define PX(x) &(_param.x)
  
        
    diaElemToggle    mask(PX(mask),QT_TRANSLATE_NOOP("msharpen","_Mask"));
    diaElemToggle    highq(PX(highq),QT_TRANSLATE_NOOP("msharpen","_High Q"));
    
    diaElemUInteger   threshold(PX(threshold),QT_TRANSLATE_NOOP("msharpen","_Threshold:"),1,255);
    diaElemUInteger   strength(PX(strength),QT_TRANSLATE_NOOP("msharpen","_Strength:"),1,255);
    
    
  diaElem *elems[4]={&mask,&highq,&threshold,&strength};

  if(diaFactoryRun(QT_TRANSLATE_NOOP("msharpen","MSharpen"),4,elems))
  {
         invstrength=255-_param.strength;
         return 1;
  }
  return 0;
}
コード例 #13
0
ファイル: barbarian.cpp プロジェクト: dalerank/caesaria-game
void Barbarian::updateStrength(int value)
{
  setStrength( strength() + value );
}
コード例 #14
0
ファイル: rendered.c プロジェクト: 10crimes/code
void geol(int x,int y,float a,float b,int s) {
  alt.pos[x][y]=oldpull((a+b)/2.0,drv.pos[x][y],strength(s));
//  alt.pos[x][y]=oldpull((a+b)/2.0,0.5*mysquaresgn(drv.pos[x][y]),strength(s));
//  alt.pos[x][y]=1.0;
}
コード例 #15
0
float ComputeMagnetTarget() {
    /* Reset periodically */

    /*if ((get_time() - old_time) > 250){
            old_time = get_time();
            i2cMasterSend(Compass,1,ResetCommand);
            pause(10);

            }*/
    i2cMasterSend(Compass,1,ResetCommand);
    pause(10);


    /* Read Heading Information */

    i2cMasterSend(Compass,3,OutputAngleCommand);
    i2cMasterSend(Compass,1,ReadCommand);

    pause(10);

    i2cMasterReceive(Compass,2,Data);
    AngleReading = (Data[0] << 8) | Data[1];

    /* Read Offset-Corrected Magnetometer X */

    i2cMasterSend(Compass,3,OutputMagXCommand);
    i2cMasterSend(Compass,1,ReadCommand);

    pause(10);

    i2cMasterReceive(Compass,2,Data);
    MagXReading = (Data[0] << 8) | Data[1];

    /* Read Offset-Corrected Magnetometer X */

    i2cMasterSend(Compass,3,OutputMagYCommand);
    i2cMasterSend(Compass,1,ReadCommand);

    pause(10);

    i2cMasterReceive(Compass,2,Data);
    MagYReading = (Data[0] << 8) | Data[1];

    //printf("\nX:%.1f,%.1f, Y:%.1f,%.1f",MagXReading/10.0,MagXRawReading/10.0,MagYReading/10.0,MagYRawReading/10.0);
    //printf("\n(%.1f,%.1f)",MagXReading/10.0,MagYReading/10.0);

    FieldStrength = strength(MagXReading,MagYReading);
    /*
       if (FieldStrength > ACTIVATE_THRESH){
       was_overload = 1;
       }
       else if (was_overload && (FieldStrength < DEACTIVATE_THRESH)){
       was_overload = 0;
       old_time = get_time();
       i2cMasterSend(Compass,1,ResetCommand);
       pause(10);
       }
     */
    fangle = ((float)AngleReading)/10.0;
    if (fangle > 180.0) fangle -= 360.0;

    //printf("\nangle:%.1f, strength: %.2f",fangle, strength(MagXReading,MagYReading));


    //i2cMasterSend(Compass,1,ResetCommand);
    //pause(10);

    return fangle;
}
コード例 #16
0
ファイル: qglpixmapfilter.cpp プロジェクト: Suneal/qt
void QGLPixmapColorizeFilter::setUniforms(QGLShaderProgram *program)
{
    program->setUniformValue("colorizeColor", color());
    program->setUniformValue("colorizeStrength", float(strength()));
}
コード例 #17
0
 virtual std::ostream& dump_data(std::ostream& os) const {
   return os
     << boost::format("%7.2f")  % strength()        << " "
     << boost::format("%7.2f")  % averageStrength() << " "
     << boost::format("%7.2f")  % strengthRMS()     << " ";
 }