TableView values are the same every run


#1

Even though the Possession class should make the names, values and serial numbers random I noticed that every run I was getting the exact same values everytime. I started down this path when I realized that out of the 10 possessions exactly 5 were $50 and below and the other 5 were above $50 which in at least some cases it should be unbalanced. I tried cleaning the project and rebuilding but I get the same data no matter what. What is going on here? thanks…


#2

here are the printouts of the randomValue(the valueinDollars) from 3 runs. It seems like there was something about just the rand() function that wasnt completely random? I know there was something like this in C.

Run 1:
2012-07-21 17:28:48.320 Homepwner[97790:f803] random value: 73
2012-07-21 17:28:48.321 Homepwner[97790:f803] random value: 40
2012-07-21 17:28:48.321 Homepwner[97790:f803] random value: 40
2012-07-21 17:28:48.322 Homepwner[97790:f803] random value: 99
2012-07-21 17:28:48.322 Homepwner[97790:f803] random value: 10
2012-07-21 17:28:48.324 Homepwner[97790:f803] random value: 93
2012-07-21 17:28:48.324 Homepwner[97790:f803] random value: 1

Run 2:

2012-07-21 17:28:48.320 Homepwner[97790:f803] random value: 73
2012-07-21 17:28:48.321 Homepwner[97790:f803] random value: 40
2012-07-21 17:28:48.321 Homepwner[97790:f803] random value: 40
2012-07-21 17:28:48.322 Homepwner[97790:f803] random value: 99
2012-07-21 17:28:48.322 Homepwner[97790:f803] random value: 10
2012-07-21 17:28:48.324 Homepwner[97790:f803] random value: 93
2012-07-21 17:28:48.324 Homepwner[97790:f803] random value: 1

Run 3:

2012-07-21 17:28:48.320 Homepwner[97790:f803] random value: 73
2012-07-21 17:28:48.321 Homepwner[97790:f803] random value: 40
2012-07-21 17:28:48.321 Homepwner[97790:f803] random value: 40
2012-07-21 17:28:48.322 Homepwner[97790:f803] random value: 99
2012-07-21 17:28:48.322 Homepwner[97790:f803] random value: 10
2012-07-21 17:28:48.324 Homepwner[97790:f803] random value: 93
2012-07-21 17:28:48.324 Homepwner[97790:f803] random value: 1

and on and on… what can we do to make these truly random???


#3

Absolutely right. The random() function isn’t truly random. Which is fine, because the quality of the randomness isn’t what matters, we just need a bunch of items that are different from on another, and random() is an easy, convenient function to use for the illustration.