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


C++ roll函数代码示例

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


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

示例1: check_priority

bool check_priority() { // true if battle, false if surrender
	if (PLAYER1_ACTION == SURRENDER_A || PLAYER2_ACTION == SURRENDER_A) {
		return false;
	}

	int player1_priority = get_priority(PLAYER1);
	int player2_priority = get_priority(PLAYER2);

	if (player1_priority == player2_priority) {
		int player1_speed = calc_speed(PLAYER1_POKEMON);
		int player2_speed = calc_speed(PLAYER2_POKEMON);

		if (player1_speed == player2_speed) {
			set_curr((roll(.5) ? PLAYER1 : PLAYER2));
			return true;
		} else {
			set_curr((player1_speed > player2_speed ? PLAYER1 : PLAYER2));
			return true;
		}
	} else {
		set_curr((player1_priority > player2_priority ? PLAYER1 : PLAYER2));
		return true;
	}

	return true;
}
开发者ID:JBai23,项目名称:MicroPsFinalProject,代码行数:26,代码来源:battle-p.c

示例2: generateBatter

static void generateBatter( const player_s *player, const int season, fileplayer_s *players_file )
{
     batter_s      *batter  = player->details.batting;
     filebatting_s *batting = &(players_file->filestats.filebatting);

     filehand_e     hand      = mapHandedness( player->handedness );
     fileposition_e primary   = mapPosition( batter->primary_position   );
     fileposition_e secondary = mapPosition( batter->secondary_position );

     int arm       = adjustRating( batter->arm,       season, player );
     int running   = adjustRating( batter->running,   season, player );
     int range     = adjustRating( batter->range,     season, player );
     int power     = adjustRating( batter->power,     season, player );
     int bunt      = adjustRating( batter->bunt,      season, player );
     int hit_n_run = adjustRating( batter->hit_n_run, season, player );

     players_file->position[0] = (primary << 4) + secondary;

     batting->ratings[0] = (hand    << 4) +         arm;
     batting->ratings[1] = (running << 4) +         range;
     batting->ratings[2] = (power   << 4) + player->longevity;
     batting->ratings[3] = (bunt    << 4) +         hit_n_run;

     if   ( player->skin_tone == st_Dark ) int2byte( batting->color, fc_Dark  );
     else                                  int2byte( batting->color, fc_Light );

     int games = (rand() % 25) + 120;
     int ab    = (int)round( (double)games * ab_per_game );
     int po    = (int)round( (double)games * ((double)getValueForTwo( put_outs, primary, range ) / 100.0) );
     int as    = (int)round( (double)games * ((double)getValueForTwo( assists, primary, arm ) / 100.0) );
     int ba    = getValueForTwo( batting_avg, power, hit_n_run );
     int soa   = getValueForOne( strikeout_avg, hit_n_run );
     int fa    = getValueForTwo( fielding_avg, range, arm ) + 9000;
     int fa2   = roll( 9500, fa - 9500 );
     int hits  = (int)round( (double)ab * (double)ba  / 1000.0 );
     int so    = (int)round( (double)ab * (double)soa / 1000.0 );
     int err   = (int)round( (double)(po + as) / (double)fa * 10000.0 ) - (po + as);

     if ( err < 0 ) err = 0;

     hits += getValueForOne( extra_hits, running );

     int2word( players_file->real_avg, ba );

     int2byte( batting->real_games, games );
     int2byte( batting->real_sb,    getValueForOne( steals, running ) );
     int2word( batting->vl_ab,      ab   );
     int2word( batting->vl_hits,    hits );
     int2byte( batting->vl_2b,      getValueForOne( doubles, power ) );
     int2byte( batting->vl_3b,      getValueForTwo( triples, power, running ) );
     int2byte( batting->vl_hr,      getValueForOne( home_runs, power ) );
     int2byte( batting->vl_bb,      getValueForOne( walks, hit_n_run ) );
     int2byte( batting->vl_so,      so );
     int2byte( batting->real_runs,  batting->vl_hr[0] + getValueForOne( runs, running ) );
     int2byte( batting->real_rbi,   batting->vl_hr[0] + getValueForOne( rbi, power ) );
     int2word( batting->real_po,    po   );
     int2word( batting->real_as,    as   );
     int2byte( batting->real_err,   err );
     int2byte( batting->real_fa2,   (int)round( (10000.0 - (double)fa2) / 10.0 ) );
}
开发者ID:zjentohlauedy,项目名称:MBA,代码行数:60,代码来源:generate_file_players.c

示例3: generateBatter

static void generateBatter( fileplayer_s *player, const names_s *name, const position2_e position )
{
     batter_attr_s attributes = { 0 };

     rollBatterAttributes( &attributes );

     strcpy( attributes.last_name,  name->last_name  );
     strcpy( attributes.first_name, name->first_name );

     int games = (rand() % 25) + 120;
     int ab    = (int)round( (double)games * ab_per_game );
     int po    = (int)round( (double)games * ((double)getValueForTwo( put_outs, position, attributes.range ) / 100.0) );
     int as    = (int)round( (double)games * ((double)getValueForTwo( assists, position, attributes.arm ) / 100.0) );
     int ba    = getValueForTwo( batting_avg, attributes.power, attributes.hit_n_run );
     int soa   = getValueForOne( strikeout_avg, attributes.hit_n_run );
     int fa    = getValueForTwo( fielding_avg, attributes.range, attributes.arm ) + 9000;
     int fa2   = roll( 9500, fa - 9500 );
     int hits  = (int)round( (double)ab * (double)ba  / 1000.0 );
     int so    = (int)round( (double)ab * (double)soa / 1000.0 );
     int err   = (int)round( (double)(po + as) / (double)fa * 10000.0 ) - (po + as);

     if ( err < 0 ) err = 0;

     hits += getValueForOne( extra_hits, attributes.speed );

     memset( player, '\0', sizeof(fileplayer_s) );

     strncpy( player->last_name,  attributes.last_name,  sizeof(player->last_name)  );
     strncpy( player->first_name, attributes.first_name, sizeof(player->first_name) );

     termName( player->last_name,  sizeof(player->last_name)  );
     termName( player->first_name, sizeof(player->first_name) );

     int2word( player->real_avg, ba );
     player->year[0]     = 0x9D;

     player->position[0] = (position * 0x10) + getSecondaryPosition( position );

     struct batting_s *batting = &(player->filestats.filebatting);

     setBatterRatings( batting->ratings, &attributes );

     batting->real_games[0] = games;
     batting->real_sb[0]    = getValueForOne( steals, attributes.speed );
     batting->vl_2b[0]      = getValueForOne( doubles, attributes.power );
     batting->vl_3b[0]      = getValueForTwo( triples, attributes.power, attributes.speed );
     batting->vl_hr[0]      = getValueForOne( home_runs, attributes.power );
     batting->vl_bb[0]      = getValueForOne( walks, attributes.hit_n_run );
     batting->vl_so[0]      = so;
     batting->real_runs[0]  = batting->vl_hr[0] + getValueForOne( runs, attributes.speed );
     batting->real_rbi[0]   = batting->vl_hr[0] + getValueForOne( rbi, attributes.power );
     batting->real_err[0]   = err;
     batting->real_fa2[0]   = (int)round( (10000.0 - (double)fa2) / 10.0 );
     batting->color[0]      = attributes.color;

     int2word( batting->vl_ab,   ab   );
     int2word( batting->vl_hits, hits );
     int2word( batting->real_po, po   );
     int2word( batting->real_as, as   );
}
开发者ID:zjentohlauedy,项目名称:MBA,代码行数:60,代码来源:gen_players.c

示例4: main

void main()
{       int i,j,ch;
	clrscr();
	for(i=0;i<3;i++)
	{
		printf("\nName\tRoll no\tDepartment\tyear\tcourse\n");
		scanf("%s \t%d\t %s\t %d\t %s",a[i].name,&a[i].no,&a[i].dept,&a[i].year,a[i].cour);
	}
	printf("Enter 1 for printing datas of students joined in aparticular yaer:");
	printf("Enter 2 for printing datas of students you want to see:");
	scanf("%d",&ch);
	if(ch==1)
	{
		year(a);
	}
	else if(ch==2)
	{
		roll(a);
	}
	else
	{
		printf("Invalid choice.");
	}
	getch();
}
开发者ID:nishant07,项目名称:CSI_C_Programs,代码行数:25,代码来源:ASSEN_ST.C

示例5: utility

// handles players landing on a utility
void utility(struct player * players, struct location * board, const int multiplier, const int n, int * pvalue, char * plocation) 
{
    struct player * p = &players[n];
    // if property is owned pay up
    if (board[p->location].owner > -1)
    {
        long long amt;
        amt = roll() * 4 * multiplier;
        p->money -= amt;
        players[board[p->location].owner].money += amt;
        board[p->location].profits += amt;
    }
    // otherwise buy it
    else if (board[p->location].owner == -2)
    {
        if (p->money > board[p->location].value)
        {
#ifdef DEBUG
        fprintf(output[globalrank], "Player %d bought location %d\n", n, p->location);
#endif
            *pvalue = board[p->location].value;
            *plocation = p->location;
        }
    }

}
开发者ID:scott-walker-llnl,项目名称:Parallel-Monopoly,代码行数:27,代码来源:par.c

示例6: main

int main (void)
{
    int first_roll;
    int result;// 0 mean continue,1 mean won, 2 mean lost
    int sum,restroll,i=1;
    srand(time(NULL));
    sum=roll();
    //while(i==1){
    switch (sum) {
    case'7':
    case'11':
        result=1;
    //break;
    case'2':
    case'3':
    case'12':
        result=2;
    //break;
    default:
        result=0;
        //break;
        //}
    }
    if (result!=0) {
        if (result!=1)
            printf("You lost the game!\n");
        else
            printf("You win the game!\n");
    }
    else {
        first_roll=sum;
        printf("the first roll is %d\n ",first_roll);
        while(result==0) {
            restroll=roll();
            if(restroll==7) {
                result=1;
                printf("You lost the game!\n");
            }
            else if(restroll==first_roll) {
                result=2;
                printf("You win the game!\n");
            }

        }
    }
    return 0;
}
开发者ID:ziploe,项目名称:learning-c,代码行数:47,代码来源:A+game.c

示例7: m_filename

LogFile::LogFile(const std::string filename)
    : m_filename(filename),
      m_curFilename(""),
      m_fd(1), //标准输出
      m_logHour(0)
{
    roll();
}
开发者ID:coneo,项目名称:walle,代码行数:8,代码来源:log_file.cpp

示例8: save_throw

/*
 * save_throw:
 *	See if a creature save against something
 */
int
save_throw(int which, const THING *tp)
{
    int need;

    need = 14 + which - tp->t_stats.s_lvl / 2;
    return (roll(1, 20) >= need);
}
开发者ID:RoguelikeRestorationProject,项目名称:rogue5.4,代码行数:12,代码来源:monsters.c

示例9: core_handle

void core_handle(string str, int n, int k)
{
    cout << "for string " << str << endl;
    Stack<char> s = createStack(str);
    cout << s.toString() << endl;
    roll(s, n, k);
    cout << s.toString() << endl << endl;
}
开发者ID:MO2013,项目名称:practice,代码行数:8,代码来源:roll.cpp

示例10: translate

void View::orbit(float _x, float _y, float _radians) {
    
    glm::vec2 radial = { _x, _y };
    glm::vec2 displacement = glm::rotate(radial, _radians) - radial;
    translate(-displacement.x, -displacement.y);
    roll(_radians);
    
}
开发者ID:hanchao,项目名称:tangram-es,代码行数:8,代码来源:view.cpp

示例11: roll

/**
 * Check if our children are unrolled and if so roll them back up.
 *
 * @param it :: iterator pointing to the item whose children will be rolled up.
 */
void HistoryView::rollChildren(std::vector<HistoryItem>::iterator it) {
  const size_t numChildren = it->numberOfChildren();
  ++it;
  for (size_t i = 0; i < numChildren; ++i) {
    if (it->isUnrolled())
      roll(it);
  }
}
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:HistoryView.cpp

示例12: roll

void SignalSpy::slot(QObject *caller, int index, void **)
{
    if(entered.localData()) return;
    QScopedValueRollback<bool> roll(entered.localData(), true);
    if(spyCondition(caller))
    {
        DBG << caller << callerNickname(caller) << " :: " << caller->metaObject()->method(index).methodSignature() << std::endl;
    }
}
开发者ID:fferri,项目名称:v_repExtCustomUI,代码行数:9,代码来源:signal_spy.cpp

示例13: detectLanding

    void detectLanding() {

        // if we are not trying to move by setting motor outputs
        if (isAlmostZero(goal_.roll()) && isAlmostZero(goal_.pitch()) && isAlmostZero(goal_.yaw()) && isGreaterThanMinThrottle(goal_.throttle()))
        {
            // and we are not currently moving (based on current velocities)
            auto angular = state_estimator_->getAngularVelocity();
            auto velocity = state_estimator_->getLinearVelocity();
            if (isAlmostZero(angular.roll()) && isAlmostZero(angular.pitch()) && isAlmostZero(angular.yaw()) &&
                isAlmostZero(velocity.roll()) && isAlmostZero(velocity.pitch()) && isAlmostZero(velocity.yaw())) {
                // then we must be landed...
                landed_ = true;
                return;
            }
        }

        landed_ = false;
    }
开发者ID:Jinwei1,项目名称:AirSim,代码行数:18,代码来源:OffboardApi.hpp

示例14: roll

	void BowlingGame::roll(int p) {
		*cur_roll = p; 
		cur_roll++;

		auto cur_index = (cur_roll - &this->pins[0]);
		if (p == 10 && cur_index % 2 != 0) {
			roll(0);
		}
	}
开发者ID:darkiri,项目名称:Kata,代码行数:9,代码来源:BowlingGame.cpp

示例15: stat

/// \brief Loads info from a property bag
//
// We get out of the bag the stat, modifier and roll settings.
//
/// \param propBag	Bag containing properties to load
//
/// \sa LoadLegacy, Save
/// \return true if stat was found
//
bool Value::Load( moPropBagRef& propBag )
{
    moPropStringRef stat  ( f_statName  );
    moPropIntRef    mod   ( f_modName   );
    moPropIntRef    roll  ( f_rollName  );
    moPropStringRef notes ( f_notesName );
    //
    stat.Link( propBag );
    mod .Link( propBag );
    roll.Link( propBag );
    notes.Link( propBag );

    if( stat.HasProp() )
    {
        f_stat = StatManager::Instance().lock()->GetStat( static_cast<moName>(stat) );
        if( !f_stat )
        {
            return false;
        }
    }
    else
    {
        LoadLegacy( propBag );
    }
    //
    assert(f_stat);
    //
    if( mod.HasProp() )
    {
        f_mod = mod;
    }
    else
    {
        f_mod = 0;
    }
    //
    if( roll.HasProp() )
    {
        f_roll = roll;
    }
    else
    {
        f_roll = 0;
    }
    //
    if( notes.HasProp() )
    {
        f_notes = static_cast<moWCString>(notes).c_str();
    }
    else
    {
        f_notes = "";
    }

    return true;
}
开发者ID:m2osw,项目名称:turnwatcher,代码行数:65,代码来源:stat.cpp


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