• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

I cant seem to generate a random number using MODULE cerberus.random

Lesther

New member
Joined
Aug 3, 2018
Messages
4
I don't know how to generate a random number here. I've only used python before and Cerberus X feels very different and I can't get my head around some of the simple stuff. Can someone help me with this pls. I only get 0,1,3 as a result

Global Seed:Int



Function Main()

Seed=1237

Local asd:Float = Int(Rnd())

Local baz:Float = Int(Rnd(5.0))

Local foo:Float = Int(Rnd(0.0,5.0))

Print asd

Print baz

Print foo

End
 
Could you tell me the problem. All random number look good.
You don't need to declare a 'Global Seed:Int'. It will override internal global.
 
The pseudo random number generator generates a sequence of numbers based on the seed value. This means, if you set seed to the same value at every start up of your program, it will generate the same sequence every time.

A very common way to set the seed is writing
Code:
Local date := GetDate()
Seed = date[3] * 3600000 + date[4] * 60000 + date[5] * 1000 + date[6]

This way, you will see different results every time you run your code.
 
Oh I get it now. I've only used python before so the idea of using a seed when generating a value is very new to me.
 
Python does seeding by the time automatically, but you can do random.seed() to set it manually.

Fixed seeds are useful for doing procedural generation; since you always get the same numbers back from the seed in order, you can basically store a whole level (or other procedurally generated thing) with just the seed number.
 
Back
Top Bottom