Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
  • 0
ClowDes

Сложная математика. :)

Здравствуйте, пожалуйста распишите на русском языке принцип работы кода (с цифрами соответствующими):

_Aiming = (0.5 + (random 1));

_Aiming = _Aiming + ((random (1 - _Aiming)) / 2);

Итого _Aiming чему равен?

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

123new Не вводите в заблуждение. 

random 1 возвратит число с плавающей точкой в пределах 0-1.

Чтобы получить 0 или 1, нужно использовать floor или ceil соответственно.

Есть еще round (округляет до ближайшего целого числа).

Share this post


Link to post
Share on other sites



  • 0

дебаг консоль? Не, не слышал

Share this post


Link to post
Share on other sites
  • 0
2 часа назад, ClowDes сказал:

Итого _Aiming чему равен?

а тут все зависит от random как раз таки) а рандом он и в африке рандом, как повезет, так и получится результат))

 

Для наглядности, те же самые вычисления, но в более простом для понимания видже:

_а = (рандомное значение от 0 до 1) + 0.5;

_b =  1 - (значение _a);

_c = (рандомное значение от 0.0 до значения _b выше);

_d = (значение _c) / 2;

_а = _а + (значение _d);

результат этих вычислений - значение _a и есть
 

Edited by 123new (see edit history)

Share this post


Link to post
Share on other sites
  • 0

Поправьте меня если я не так понимаю: (random 1) - рандомное число от нуля до максимально допустимой единицы?

Share this post


Link to post
Share on other sites
  • 0
25 минут назад, ClowDes сказал:

Поправьте меня если я не так понимаю: (random 1) - рандомное число от нуля до максимально допустимой единицы?

верно, от 0 до 1.
random 1  выдаст рандомно 0 или 1

random 0.2 выдаст рандомно 0.0, 0.1 или 0.2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.