Subscribe to Random Programs I've created/altered.        RSS Feed
-----

Random List Generator

Icon Leave Comment
Today I created a random list generator that can take in any list containing strings, and randomize them in what seems to me to be a True Random Number generator. I know true random generation really doesn't exist, but for the way I did it, it is pretty difficult to get the same results multiple times. I've run probably 150 tests today using a list of 10 different names and every time it created new results. So it's random enough for me. It's probably a really unorthodox way of doing things, but I just wanted to try something new, so be nice :tt2: below is the code, and an explanation of how it works step by step

1. it creates a random object (rnd(3)) with a seed of the current times millisecond
2. it uses rnd(3) to create an integer (loopCount) between 0 and the current times millisecond divided by 100. loopCount is how many times it goes through the "randomization" block of code
3. it creates an integer (seed1) equal to the current times millisecond
4. it creates another random object (rnd1) with a seed equal to seed1
5. it creates another integer (seed2) equal to a random number between 0 and seed1 using the rnd1 object.
6. it creates another integer (sleepTime) equal to a random number between 0 and seed2 using the rnd1 object.
7. it then sleeps the program for sleepTime divided by (Math.Pi * 10) converted to a Double.
8. it creates another random object (rnd2) with a seed of the current times millisecond plus sleepTime
9. it then creates 2 more integers the first one (iName1) equals a random number between 0 and the number of items in the list using rnd1 as the random object, and the second one (iName2) equals a random number between 0 and the number of items in the list using rnd2 as the random object.
10. it then creates 2 strings, the first (Name1) equal to the item at the index of iName1 in the list, and the second (Name2) equal to the item at the index of iName2 in the list.
11. it then checks if it hasn't chosen the same value for both items, and assigns the item at the index of iName1 in the list to Name2 and the item at the index of iName2 in the list to Name1.

the code will be placed in a spoiler tag directly below this, by tomorrow. and I will attach the project with a commented line to show you where to change where it looks for input.

Spoiler

Attached File(s)

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

February 2020

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829

Recent Entries

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)