Help with True Randoms

ST_NumerialS

Member!
Joined
Aug 13, 2003
Messages
36
Reaction score
0
Location
uhh, jeese. thats a good quest
Website
www.network54.com
How do I get a true random number?

First off, to point out to those that tell me "Use math - random number" I'm well aware of that. Thats why I titled this "true randoms."

I had an idea that I have players click on their main base to start the game, and then the amount of game time that went by is saved as a variable, and then the variable is multiplied by the interger I want to be a random number, and then when its less than 1 its multiplied by a number ,and when its greater than 14 its divided. But thats a very clumisly way to do this, and its not working properly as I'm getting numbers like 3098 and 987 and -0.24 and -605.

The reason I need this, is because in my card game, I want it to be so that each time you play the game, you get difference cards. Because while in the game its completely random based off the first number, its all based on the first number. So every time you play the game you'll get the same numbers. But if you change the first number, and ONLY the first, all the rest of the numbers will be different. I thought that I need something that is different evertime you play the game. Such as time of day, but you can't call into windows API for time of day (Unless you know how, please tell me) so I figured there's only two things. Thats the player's names, and the time of day you select your main base (as it can be different for evertime because its a "real" variable that goes down to the hundreths of a second.)

But I don't know how to incorperate my new random number with my first one staying inside the parameters of any number between 1 and 14.

All help is appreciated. Thankyou.
 

IceDevil9

BattleForums Senior Member
Joined
Feb 19, 2003
Messages
3,418
Reaction score
3
Location
CA
Website
www.rcthaven.com
Computers themselves, as there very nature cannot truly create a random number. They use whats known as a pseudorandom number generator. What happens is, every time that you create a Random object in Java (The language I've been learning), a set of random numbers is calculatedm, and that same set is used over and over and over again, it all depends on wherwe your pointer (or seed) is located. Pseudo-random number generators act by randomly moving your seed to a different number.

-Frank :cool:
 

ST_NumerialS

Member!
Joined
Aug 13, 2003
Messages
36
Reaction score
0
Location
uhh, jeese. thats a good quest
Website
www.network54.com
Known

This is known. This is why I ask if anyone has an idea, as I suggested above. I am using a system where it counts the number of seconds it takes for players to click on a unit before converting that to the number the randoms use off of, so that its different every game.

But I don't know how to incorperate by counter to the random number, and what if it takes them longer than 14 seconds? or less than 1 second? Anybody got an idea or explanation to derive off of mine? or another secondary way to make true randoms?
 

x42bn6

Retired Staff
Joined
Nov 11, 2002
Messages
15,150
Reaction score
2
Location
London, United Kingdom
ST_NumerialS said:
How do I get a true random number?

First off, to point out to those that tell me "Use math - random number" I'm well aware of that. Thats why I titled this "true randoms."

I had an idea that I have players click on their main base to start the game, and then the amount of game time that went by is saved as a variable, and then the variable is multiplied by the interger I want to be a random number, and then when its less than 1 its multiplied by a number ,and when its greater than 14 its divided. But thats a very clumisly way to do this, and its not working properly as I'm getting numbers like 3098 and 987 and -0.24 and -605.

The reason I need this, is because in my card game, I want it to be so that each time you play the game, you get difference cards. Because while in the game its completely random based off the first number, its all based on the first number. So every time you play the game you'll get the same numbers. But if you change the first number, and ONLY the first, all the rest of the numbers will be different. I thought that I need something that is different evertime you play the game. Such as time of day, but you can't call into windows API for time of day (Unless you know how, please tell me) so I figured there's only two things. Thats the player's names, and the time of day you select your main base (as it can be different for evertime because its a "real" variable that goes down to the hundreths of a second.)

But I don't know how to incorperate my new random number with my first one staying inside the parameters of any number between 1 and 14.

All help is appreciated. Thankyou.
For your way, use these actions, but store it into a variable. I'll call it x.

Set x=abs(x)
Set x=Convert to Real(Convert to Integer(x))
Set x=Mod(x,14) I don't know about this
Set x=x+1


The first line gets rid of the negatives.
The second line rounds this off to the nearest integer, then converts it to real (I assume that x is a real value).
The third line finds the remainder of x divided by 14. The result is basically a number between 0 and 13.
The fourth number adds 1 to x, so you have a number between 1 and 14.*
 

NewPosts

New threads

Top