Random in LITE-C ??

Posted By: Paulo

Random in LITE-C ?? - 09/28/09 12:14

Hi,

Is my 3d gs buggy?? Im only trying to get a rondom number

code:

Code:
function random_number()
{
var number = 0;
number = integer(random(500));
printf("%i",(int)number );
}



Keeps giving my the same number over and over, 404 :s
Posted By: Widi

Re: Random in LITE-C ?? - 09/28/09 12:54

Do you have a manual ???

--> random_seed(0);
Posted By: Paulo

Re: Random in LITE-C ?? - 09/28/09 12:56

x = integer(random(10)); // returns a number between 0 and 9


right out of the manual..
Posted By: Quad

Re: Random in LITE-C ?? - 09/28/09 13:33

if you dont use random_seed(0); or randomize(); function at least once in your app, it will always return same random number when you use same limit. this is also the case in C.
Posted By: SomebodyNew

Re: Random in LITE-C ?? - 09/28/09 13:36

Take a closer look at the function's description.
I missed that part at first too.

Random only gives you a series of numbers in a specific order. That means that every time you restart your game... it will use the EXACT same "random" numbers in the order they were used last game.

If you want truly random numbers you first have to make the numbers used by the random-function truly random. Thats why you have to use random_seed if you want to use random numbers.

Just try it and you'll see.
Posted By: Hirogens

Re: Random in LITE-C ?? - 09/28/09 13:43

Hi,

I worked for 10 years on "gambling games", and I can tell you never to use "random" compilers .. it's fake.it's joke.

but not a "random generator"

(en français, c'est de la merde)^^

looking on forums mathematician.

If you are some probleme, ask me, may be send you a real professional random generator.

regards
Hirogens
Posted By: SomebodyNew

Re: Random in LITE-C ?? - 09/28/09 14:42

I'm curious, what do you mean by "it's fake"?
Do you mean random-generators in general?

Je ne comprend pas.

Aide-moi s'il vs plait.
Posted By: Hirogens

Re: Random in LITE-C ?? - 09/28/09 15:01

hi,

yes, in general..

the random generator of all compiler are bad.
never use this for a real game.

but it's my opinion...

the same problem for sin,cos,tan function.
never use. use record of sin,cos,tan etc.


regards

Posted By: Widi

Re: Random in LITE-C ?? - 09/28/09 17:07

random_seed(0); give you a really random number. At my Game i never have the same number with random after random_seed...
Posted By: Quad

Re: Random in LITE-C ?? - 09/28/09 17:32

Originally Posted By: Hirogens

the random generator of all compiler are bad.
never use this for a real game.


what defines "good random generator"?

i mean why do you think it's bad. It generates your random number after all. all of them does that.
Posted By: Rei_Ayanami

Re: Random in LITE-C ?? - 09/28/09 17:40

you´ll never have a real random generator! The number is computed in anyway!

Even if you just say a number, you thought why you take this number - so there will never be a real random number.

That´s my opinion wink
Posted By: Hirogens

Re: Random in LITE-C ?? - 09/28/09 18:06

ok you are reason

a real numeric random generator don't existe.

but you can make a "better" random.

The formula is very long...

Regards
Hirogens
Posted By: MMike

Re: Random in LITE-C ?? - 09/29/09 21:06

im interested in a real random , not for game, but , i know there are some USB you plug in, and generate random numbers, from atmosferic interference but..

Without it, its possible to get a randomized list of number, i think that random anyway..


if you multiple do, randomize(0) and then random(1)*random(1) and integer(result) its random.. for sure.
Posted By: MrGuest

Re: Random in LITE-C ?? - 09/29/09 23:26

no... using multiple randoms will always give the same result

e.g using random(2) * random(2) will always return the same number if no random seed has been set

setting a random seed is offsetting where a random number will be chosen from, usually by time and/or date as the time it's calculated each time will be different

there are many things you can apply to being random such as atmosherics, but different users acting at the same time in the same environment will get the same result

people have long looked for ways to actually 'generate a random number' but as Rei has already said (although stupidly), these are all pre-defined/pre-programmed.

unfortunately, even with the smartest AI, the simplest operations can't be performed such as randomness, unless this already has 'taught' to the program
© 2024 lite-C Forums