Пример #1
0
/* Tests setState and getScore */
void test_scoring() {
  point_type *points[4];
  int i;

  for(i = 0; i < 4; i++)
    points[i] = newPoint(0, i);

  CU_ASSERT_EQUAL(getScore(points), 0);

  for(i = 0; i < 4; i++)
    setState(points[i], PLAYER_ONE);

  CU_ASSERT_EQUAL(getScore(points), 4);

  for(i = 0; i < 4; i++)
    setState(points[i], PLAYER_TWO);

  CU_ASSERT_EQUAL(getScore(points), -4);

  setState(points[1], PLAYER_ONE);

  CU_ASSERT_EQUAL(getScore(points), 0);

  for(i = 0; i < 4; i++)
    free(points[i]);
}
Пример #2
0
void NewScene::selectedEvent(Ref *pSender, ui::CheckBox::EventType type)
{
	Point origin = Director::getInstance()->getVisibleOrigin();
	Size visibleSize = Director::getInstance()->getVisibleSize();

	switch (type)
	{
	case cocos2d::ui::CheckBox::EventType::SELECTED:

		setScore(getScore() + 1);
		
		break;
	case cocos2d::ui::CheckBox::EventType::UNSELECTED:
		//log("checkbox deseleccionado");
		//i -=1;
		setScore(getScore() - 1);

		break;
	default:
		break;
	}



}
Пример #3
0
void UserData::addScore(int var)
{
	setScore(getScore() + var);
	if (getScore() > getBestScore())
	{
		setBestScore(getScore());
	}
	saveData();
}
Пример #4
0
	void IMGDock::optimizeRotation(vector < int > & conf, PoseList& best_conformations, Size bond, bool ignore_original_angle)
	{
		// just in order to produce exactly the same result as before (since the order of tested conformation does play a role)
		if (!decrease_stepwidth_)
		{
			int no_steps = no_steps_;
			if (ignore_original_angle) no_steps--;

			for (int i = 0; i < no_steps; i++)
			{
				conf[bond] = (conf[bond]+step_width_)%360;
				applyConformation(conf);

				update();
				double score = getScore();
				if (best_conformations.size() < no_solutions_ || score < best_conformations.rbegin()->first)
				{
					best_conformations.insert(make_pair(score, conf));
					if (best_conformations.size() > no_solutions_)
					{
						PoseList::iterator it = best_conformations_.end();
						it--;
						best_conformations.erase(it);
					}
				}
			}
		}

		else
		{
			int original_value = conf[bond];
			conf[bond] = (conf[bond]-(no_steps_/2)*step_width_)%360;
			if (conf[bond] < 0) conf[bond] = 360+conf[bond];
			//Log<<"conf[bond] ="<<conf[bond]<<"  ";

			for (int i = 0; i < no_steps_; i++)
			{
				conf[bond] = (conf[bond]+step_width_)%360;
				if (ignore_original_angle && conf[bond] == original_value) continue; // this conformation has been evaluated previously

				applyConformation(conf);

				update();
				double score = getScore();
				if (best_conformations.size() < no_solutions_ || score < best_conformations.rbegin()->first)
				{
					best_conformations.insert(make_pair(score, conf));
					if (best_conformations.size() > no_solutions_)
					{
						PoseList::iterator it = best_conformations_.end();
						it--;
						best_conformations.erase(it);
					}
				}
			}//Log<<endl;
		}
	}
Пример #5
0
CDGNode *getMaxScoreConditionNode(CDGNode * node) {
  CDGNode *out = NULL;
  do {
    if (!isLeaf(node) && 0 < getScore(node)) {
      if ((NULL == out) || (getScore(out) < getScore(node))) {
	out = node;
      }
    }
    node = getNextNode(node);
  } while (NULL != node);
  return out;
}
Пример #6
0
void analyze (align *myal, int cutoff, int window){
  int *first, *last, size = 1, len = 0, i, score, count = 0;
  int runstart = -1, numpairs = myal->numseq * (myal->numseq - 1) / 2;

  window = MIN (window, myal->algnlen);
  first = (int *) malloc (size * sizeof (int)); assert (first);
  last = (int *) malloc (size * sizeof (int)); assert (last);

  score = 0;
  for (i = 0; i < window; i++)
    score += getScore (myal, i);

  if (score * 100 >= window * numpairs * cutoff) runstart = 0;
  for (i = 1; i <= myal->algnlen - window; i++){
    score += getScore (myal, i + window - 1) - getScore (myal, i - 1);

    if (score * 100 >= window * numpairs * cutoff){
      if (runstart == -1){
	if (len > 0 && last[len - 1] >= i)
	  runstart = first[--len];
	else
	  runstart = i;
      }
    }
    else if (runstart >= 0){
      first[len] = runstart;
      last[len++] = i + window - 1;
      runstart = -1;
	
      if (len == size){
	size *= 2;

	first = (int *) realloc (first, sizeof (int) * size); assert (first);
	last = (int *) realloc (last, sizeof (int) * size); assert (last);
      }
    }
  }

  if (runstart >= 0){
    first[len] = runstart;
    last[len++] = myal->algnlen - 1;
  }

  for (i = 0; i < len; i++){
    count += last[i] - first[i];
  }

  printf ("%d\n", count);
  print (myal, first, last, len);

  free (first);
  free (last);
}
Пример #7
0
//获得胡舵数
int GetScore::getHuDuo()
{
	if (getScore() >= 10)
	{
		huDuo = ((getScore() - 10) / 5) + 1;
		return huDuo;
	}
	else
	{
		huDuo = 0;
		return huDuo;
	}
}
Пример #8
0
void GameLayer::setScore(int var) {
    score = var;
    if (!mScoreLabel) {
        CCLabelTTF *label = CCLabelTTF::create(CCString::createWithFormat("%d", getScore())->getCString(), "ArialMT", 30);
        label->setColor(ccYELLOW);
        label->setAnchorPoint(ccp(0, .5));
        label->setPosition(ccp(50, getContentSize().height * 0.9));
        this->addChild(label, ZORDER_COUNTDOWN);
        
        mScoreLabel = label;
    }
    mScoreLabel->setString(CCString::createWithFormat("Score: %d", getScore())->getCString());
}
Пример #9
0
int Level::getStars()
{
	if (getScore() >= getNrDivisible())
		return 3;
	
	if (getScore() >= getNrDivisible() * 0.75f)
		return 2;
	
	if (getScore() >= getNrDivisible() * 0.5f)
		return 1;
	
	return 0;
}
Пример #10
0
/** The soccer game is over if time up or either team wins.
 */
bool SoccerWorld::isRaceOver()
{

    if(race_manager->hasTimeTarget())
    {
        return m_count_down_reached_zero;
    }
    // One team scored the target goals ...
    else
    {
      return (getScore(SOCCER_TEAM_BLUE) >= m_goal_target ||
          getScore(SOCCER_TEAM_RED) >= m_goal_target);
    }

}   // isRaceOver
Пример #11
0
CCObject* EziFacebookFriend::copyWithZone(CCZone *pZone)
{
    CCZone* pNewZone = NULL;
    EziFacebookFriend* pCopy = NULL;
    if(pZone && pZone->m_pCopyObject)
    {
        //in case of being called at sub class
        pCopy = (EziFacebookFriend*)(pZone->m_pCopyObject);
    }
    else
    {
        pCopy = new EziFacebookFriend();
        pNewZone = new CCZone(pCopy);
    }
    
    pCopy->setName(getName());
    pCopy->setID(getFBID());
    pCopy->setScore(getScore());
    pCopy->setPhotoPath(getPhotoPath());
    pCopy->setInstalled(isInstalled());
    pCopy->setPhotoURL(getPhotoURL());
    
    //pCopy->initWithAction((CCActionInterval *)(m_pInner->copy()->autorelease()));
    
    CC_SAFE_DELETE(pNewZone);
    return pCopy;
}
Пример #12
0
void Enemy::destory( )
{

	if(hp <= 0){

		//explosion effect  flame
		auto effect = Effect::CreateEffect( );
		effect->explosion(gameStage, this->getPosition( ));

		//explosion effect of particle


		auto config = Config::getInstance( );
		if(config->geteffectState( ))
		{
			SimpleAudioEngine::getInstance( )->playEffect( ship_explode_effect0 );
		}
	
		config->setScore( config->getScore( ) + score );

		//log("current get score is :%d",config->getScore  () );
	
		this->unschedule(schedule_selector( Enemy::fire ) );
		this->removeFromParent( );
	}
}
Пример #13
0
void NewScene::cantidad()
{

	Point origin = Director::getInstance()->getVisibleOrigin();
	Size visibleSize = Director::getInstance()->getVisibleSize();

	auto action1 = Sequence::create(FadeIn::create(1), FadeOut::create(1), NULL);


	string ctd = "La cantidad es : "+ to_string(getScore());

	CCLOG("cantidad es: %s",  ctd.c_str());


	
	Label * l1 = Label::createWithTTF(ctd.c_str(),"fonts/airstrikecond.ttf",35); 

	l1->setPosition(Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));

	l1->setColor(Color3B::MAGENTA);

	l1->runAction(action1);

	this->addChild(l1,1);

}
Пример #14
0
void
ScoreWidget::slotScoreActivated(int)
{
        Input::Score score = getScore();

        /* Enable or disable window and frequency related widgets
           according to current score. */
        switch (score) {
        case Input::RAW_POTENTIAL:
                windowLabel->setEnabled(false);
                windowComboBox->setEnabled(false);
                frequencyLabel->setEnabled(false);
                frequencySpinBox->setEnabled(false);
                break;

        case Input::DFT_AMPLITUDE:
        case Input::DFT_PHASE:
                windowLabel->setEnabled(true);
                windowComboBox->setEnabled(true);
                frequencyLabel->setEnabled(true);
                frequencySpinBox->setEnabled(true);
                break;
        }

        /* Notify observers on change. */
        emit changed();
}
Пример #15
0
// Get the current score
int giveMeTheScore(DracView currentView) {
   int score;
   
   score = getScore(currentView->gv);
   
   return score;
}
Пример #16
0
bool GameState::isActiveTeamWinning() const
{
    auto score = getScore();
    auto activeTeam = getActiveTeam();
    return (activeTeam == 0 && score[0] > score[1]) ||
        (activeTeam == 1 && score[1] > score[0]);
}
Пример #17
0
CDGNode *getTopPath(CDGNode * node, Stack * changedNodes, Stack * changedBranches) {
  CDGNode *pathNode = newBlankNode();
  CDGNode *temp = pathNode;
  int branch;
  while (node) {
    if (0 != getScore(node)) {
      stackPush(changedNodes, &node);
      branch = getOutcome(node);
      stackPush(changedBranches, &branch);
      if (isLeaf(node)) {
	setScore(node, 0);
      } else {
	setNextNode(temp, copyToPathNode(newBlankNode(), node));
	temp = getNextNode(temp);
	if (getOutcome(node)) {
	  setBranchInfo(getID(node), 1, getBranchInfo(getID(node), 0));
	  setTrueNodeSet(temp, getTopPath(getTrueNodeSet(node), changedNodes, changedBranches));
	} else {
	  setBranchInfo(getID(node), getBranchInfo(getID(node), 1), 1);
	  setFalseNodeSet(temp, getTopPath(getFalseNodeSet(node), changedNodes, changedBranches));
	}
      }
    }
    node = getNextNode(node);
  }
  if (temp == pathNode) {
    deleteNode(pathNode);
    pathNode = NULL;
  } else {
    temp = pathNode;
    pathNode = getNextNode(pathNode);
    deleteNode(temp);
  }
  return pathNode;
}
Пример #18
0
void boatReal::updateHint(void)
{
#if 0
    QString str;
    /* adding score */
    str = getScore() + " - Spd: " + QString().setNum(getSpeed()) + " - ";
    switch(getPilotType())
    {
        case 1: /*heading*/
            str += tr("Hdg") + ": " + getPilotString() + tr("deg");
            break;
        case 2: /*constant angle*/
            str += tr("Angle") + ": " + getPilotString()+ tr("deg");
            break;
        case 3: /*pilotortho*/
            str += tr("Ortho" ) + "-> " + getPilotString();
            break;
        case 4: /*VMG*/
            str += tr("BVMG") + "-> " + getPilotString();
            break;
       case 5: /*VBVMG*/
            str += tr("VBVMG") /*+ "-> " + getPilotString()*/;
            break;
    }
    QString desc;
    if(!polarData) desc=tr(" (pas de polaire chargee)");
    else if (polarData->getIsCsv()) desc=polarData->getName() + tr(" (format CSV)");
    else desc=polarData->getName() + tr(" (format POL)");
    str=str.replace(" ","&nbsp;");
    desc=desc.replace(" ","&nbsp;");
    setToolTip(desc+"<br>"+str);
#endif
    setToolTip(pseudo);
}
Пример #19
0
void setNewTarget(Map* map, Plane* plane) {
    int i;
    int newTargetScore;
    int bestCityScore = 0;
    int bestCityindex = NO_TARGET;
    for (i = 0; i < map->cityCount; i++) {
        if (i == plane->cityIdFrom) {
            // Skip if current city or route does not exists
            continue;
        }
        newTargetScore = getScore(plane, i);
        if (bestCityScore < newTargetScore) {
            bestCityScore = newTargetScore;
            bestCityindex = map->cityRoute[plane->cityIdFrom][i];
        }
    }
    if (bestCityindex == NO_TARGET) {
        // No more cities can be supplied
        deactivatePlane(plane);
        return;
    }
    // Set new distance from currentTargetId to newTaget
    plane->cityIdTo = bestCityindex;
    plane->distanceLeft = map->cityDistance[plane->cityIdFrom][bestCityindex];
}
Пример #20
0
int main(void) {
	openfb("/dev/fb0");
	initGame();
	SetTimer(1,alarm_handler);
	while(1) {
		char c;
		c = getch();
		fflush(NULL);
		switch(c) {
		case 'w':
			rotate();
			break;
		case 'a':
			moveLeft();
			break;
		case 's':
			moveDown();
			break;
		case 'd':
			moveRight();
			break;
		case 'q':
			printf("Game Aborted!!!\n");
			printf("Your score:%d\n",getScore());
			exit(0);
		default:
			break;			
		}
	}
	closefb();
	return 0;
}
Пример #21
0
void Game::updateGameInfos(int nbLinesDeleted)
{
	setLinesCompleted(getLinesCompleted() + nbLinesDeleted);
	setLevel(computeLevel());
	setFallIterationDelay(computeFallIterationDelay());
	setScore(computeScore(nbLinesDeleted) + getScore());
}
Пример #22
0
Step *AI::getStep(GameStartLayer *game)
{
    int highScore = -3000;
    Step *ret = NULL;
    vector<Step *> allMove = getAllPossibleMove(game);
    vector<Step *> ::iterator it;
    for (it = allMove.begin(); it != allMove.end(); ++it)
    {
        Step *step = *it;
        fakeMove(game, step);
        int score = getScore(game);
        unfakeMove(game, step);
        if (score > highScore)
        {
            highScore = score;
            ret = step;
        }
    }

    for (it = allMove.begin(); it != allMove.end(); ++it)
    {
        Step *step = *it;
        if (step != ret)
        {
            delete step;
        }
    }

    return ret;
}
std::string TemplateClassifier::getClass( cv::Mat roi )
{
	float bestScore = (_method==CV_TM_SQDIFF) ? 999999:0;
	std::string classe = "";

	std::vector< std::pair< std::string, std::string > >::iterator itc = _classes.begin();
	for( ; itc != _classes.end(); itc++ )
	{
		cv::Mat templ = cv::imread(itc->second);
		float score = getScore(roi, templ);
		std::ostringstream ss;
		if( (score!=-1) && (_method==CV_TM_SQDIFF) && (score < bestScore) )
		{
			bestScore = score;
			ss << itc->first << '|' << score;
			classe = ss.str();
		}
		else if( (score!=-1) && (score > bestScore) )
		{
			bestScore = score;
			ss << itc->first << '|' << score;
			classe = ss.str();
		}
	}

	return classe;
}
Пример #24
0
Файл: todd.c Проект: uopcs/euler
int main(int argc, char **argv)
{
	// setup file pointers
	FILE *fp;
	int sum = 0; // sum of scores
	
	char filename[] = "H:\\Cdev\\MEMS\\names_s.txt";
	fp = fopen(filename, "r");
	char ch;
	char name[256];
	bool readingName = false;
	int idx = 0;
	int num = 1;
	while ((ch = getc(fp)) != EOF)
	{
		if (ch == '"' && !readingName)
		{
			readingName = true;
			idx = 0;
		}
		else if (ch == '"' && readingName)
		{
			readingName = false;
			sum += getScore(name, idx, num++);
		}
		else if (readingName)
		{
			name[idx] = ch;
			idx++;
		}
	}
	printf("%i", sum);
	return 0;
}
Пример #25
0
int rate(Group animalsOnBoard, Move move, Group enemyHand){ // Score a Move
	Board board = makeBoard(&animalsOnBoard,move);
	// Get Tile info from Group and Move
	int i;
	for(i=0; i<animalsOnBoard.num; i++){
		applyReach(animalsOnBoard.animal[i], &board);
		// apply list of animals that can reach the tile
	}
	int score = getScore(board);
	score -= placePenalty(move);
	score += effectRange(board);
	score += catchLion(board);
	score += touchDown(board);
	score += placeDanger(board,enemyHand);
	score += lionPosition(animalsOnBoard);
	// Score is (board score) + (placement penalty)
	// + (moveable range) + (did we catched lion?) + (did lion get touchdown?)
	int x,y;
	for(y=0; y<4; y++){
		for(x=0; x<3; x++){
			printf("%c",board.tile[x][y].occupied);
		}
		printf("\n");
	}
	printf("place : %d\nlion : %d\ntotal : %d\n",placeDanger(board,enemyHand),lionPosition(animalsOnBoard),score);
	return score;
}
Пример #26
0
void MVJoinGraphSolution::print(FILE* ofd, const char* indent, const char* title)const
{
  fprintf(ofd, "\nMVJoinGraphSolution (Score: %d): ", getScore());
  for (Lng32 i=0; i<entries_; i++)
    fprintf(ofd, "%d, ", route_[i]);
  fprintf(ofd, ".\n");
}
Пример #27
0
__int64 getTotalScore(std::vector<std::string> names)
{
	unsigned __int64 sum;
	sum ^= sum;
	for(unsigned int i=0;i<names.size();i++)
		sum += (getScore(names[i])*(i+1));
	return sum;
}
Пример #28
0
MatchClassification MultiaryScoreCache::getScore(MultiaryClusterPtr c1, MultiaryClusterPtr c2)
{
  // make sure all the elements in c1 can possibly (regardless of how remotely) be merged with
  // any of the elements in c2.
  foreach (const ConstElementPtr& e1, *c1)
  {
    foreach (const ConstElementPtr& e2, *c2)
    {
      MatchClassification mc = getScore(e1, e2);
      if (mc.getMissP() == 1)
      {
        return mc;
      }
    }
  }

  return getScore(c1->mergedElement, c2->mergedElement);
}
Пример #29
0
bool MaxRects::findBest(BinIt& outBin, RectIt& outFreeRect, RectDataIt& outRect, bool& flip) {
	auto bestScore = std::numeric_limits<unsigned long long>::max();

	for (auto binIt = m_bins.begin(); binIt != m_bins.end(); ++binIt) {
		auto& bin = *binIt;

		if (bin.m_full)
			continue;

		for (auto freeRect = bin.m_freeRects.begin(); freeRect != bin.m_freeRects.end(); ++freeRect) {
			for (auto rectIt = m_rectangles.begin(); rectIt != m_rectangles.end(); ++rectIt) {
				auto& rect = *rectIt;

				if (rect->m_w <= freeRect->m_w && rect->m_h <= freeRect->m_h) {
					auto score = getScore(*freeRect, rect->m_w, rect->m_h);

					if (score < bestScore) {
						outBin      = binIt;
						outFreeRect = freeRect;
						outRect     = rectIt;
						flip        = false;

						bestScore = score;
					}
				}
				
				if (m_config.m_canFlip && rect->m_h <= freeRect->m_w && rect->m_w <= freeRect->m_h) {
					auto score = getScore(*freeRect, rect->m_h, rect->m_w);

					if (score < bestScore) {
						outBin      = binIt;
						outFreeRect = freeRect;
						outRect     = rectIt;
						flip        = true;

						bestScore = score;
					}
				}
			}
		}
	}

	return bestScore != std::numeric_limits<unsigned long long>::max();
}
Пример #30
0
void StudentWorld::setDisplayText()
{
	int score = getScore();
	int round = roundNumber();
	double energyPercent = (double(m_player->currentEnergy()/50)*100);
	int torpedoes = m_player->numberOfTorpedoes();
	int shipsLeft = getLives();
	std::string s = FormatGameStatText(score, round, energyPercent, torpedoes, shipsLeft);
	setGameStatText(s);
}