• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ roll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: roll

void YAC_LoggerRoll::flush()
{
    YAC_ThreadQueue<pair<int, string> >::queue_type qt;
    _buffer.swap(qt);

    if (!qt.empty())
    {
        roll(qt);
    }
}
开发者ID:peerswu,项目名称:Jump,代码行数:10,代码来源:yac_logger.cpp


示例17: rollsetstandard

/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  rollset
 *  Description:  return a set of random dice rolls of the passed size
 * =====================================================================================
 */
static int * rollsetstandard(int size)
{
	int * ret = (int*) safeMalloc(sizeof(int) * size);

	for(int i = 0 ; i < size ; i++)
	{
		ret[i] = roll();
	}

	return ret;
}
开发者ID:sylvarant,项目名称:dice-game,代码行数:17,代码来源:player.c


示例18: rval

Image Image::fromNoise(int w, int h) //static
{
    Image rval(w, h);

    std::mt19937 rng;
    std::uniform_int_distribution<int> roll(0,255);

    for (int i=0; i<w; ++i)
    {
        for (int j=0; j<h; ++j)
        {
            for (int k=0; k<4; ++k)
            {
                rval.at(j,i)[k] = roll(rng);
            }
        }
    }

    return rval;
}
开发者ID:dbralir,项目名称:escape,代码行数:20,代码来源:image.cpp


示例19: forwardAxis

void SimpleCamera::update()
{

	int forwardAxis(-1);
	switch (m_data->m_cameraUpAxis)
	{
    case 1:
    	forwardAxis = 2;
    	m_data->m_cameraUp = b3MakeVector3(0,1,0);
    	//gLightPos = b3MakeVector3(-50.f,100,30);
    	break;
    case 2:
		forwardAxis = 1;
		m_data->m_cameraUp = b3MakeVector3(0,0,1);
		//gLightPos = b3MakeVector3(-50.f,30,100);
		break;
    default:
		{
			b3Assert(0);
			return;
		}
	};

	b3Vector3 eyePos = b3MakeVector3(0,0,0);
	eyePos[forwardAxis] = -m_data->m_cameraDistance;

	m_data->m_cameraForward = b3MakeVector3(eyePos[0],eyePos[1],eyePos[2]);
	if (m_data->m_cameraForward.length2() < B3_EPSILON)
	{
		m_data->m_cameraForward.setValue(1.f,0.f,0.f);
	} else
	{
		m_data->m_cameraForward.normalize();
	}
	

//    m_azi=m_azi+0.01;
	b3Scalar rele = m_data->m_yaw * b3Scalar(0.01745329251994329547);// rads per deg
	b3Scalar razi = m_data->m_pitch * b3Scalar(0.01745329251994329547);// rads per deg


	b3Quaternion rot(m_data->m_cameraUp,razi);

	
	b3Vector3 right = m_data->m_cameraUp.cross(m_data->m_cameraForward);
	b3Quaternion roll(right,-rele);

	eyePos = b3Matrix3x3(rot) * b3Matrix3x3(roll) * eyePos;

	m_data->m_cameraPosition = eyePos;
	m_data->m_cameraPosition+= m_data->m_cameraTargetPosition;

}
开发者ID:rwindegger,项目名称:bullet3,代码行数:53,代码来源:SimpleCamera.cpp


示例20: eye

/*!
    Tilts the eye() up or down by \a tiltAngle degrees,
    pans the eye() left or right by \a panAngle degrees,
    and rolls the eye() left or right by \a rollAngle degrees,
    all in a single fluid movement.  The \a order parameter
    indicates the order in which to perform the rotations.

    This function is accessible to QML on the Camera item.
    It is provided as a convenience for navigation items that
    rotate the eye in multiple directions at the same time
    based on mouse movements.

    \sa tiltPanRollCenter()
*/
void QGLCamera::tiltPanRollEye
    (float tiltAngle, float panAngle, float rollAngle,
     QGLCamera::RotateOrder order)
{
    switch (order) {
    case QGLCamera::TiltPanRoll:
        rotateEye(roll(rollAngle) * pan(panAngle) * tilt(tiltAngle));
        break;
    case QGLCamera::TiltRollPan:
        rotateEye(pan(panAngle) * roll(rollAngle) * tilt(tiltAngle));
        break;
    case QGLCamera::PanTiltRoll:
        rotateEye(roll(rollAngle) * tilt(tiltAngle) * pan(panAngle));
        break;
    case QGLCamera::PanRollTilt:
        rotateEye(tilt(tiltAngle) * roll(rollAngle) * pan(panAngle));
        break;
    case QGLCamera::RollTiltPan:
        rotateEye(pan(panAngle) * tilt(tiltAngle) * roll(rollAngle));
        break;
    case QGLCamera::RollPanTilt:
        rotateEye(tilt(tiltAngle) * pan(panAngle) * roll(rollAngle));
        break;
    }
}
开发者ID:Distrotech,项目名称:qt3d,代码行数:39,代码来源:qglcamera.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ roll_chance_f函数代码示例发布时间:2022-05-30
下一篇:
C++ roleNames函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap