Forum Discussion
8 years ago
"juicer420;1552532" wrote:
The idea that it would be more efficient using a random number generator is false. Unless you use some sort of data structure to reduce the time complexity, generating random and different numbers just to fill the choices has a time complexity of O(infinite). This is because of the possibility that the same number is generated every time, leaving you in an infinite loop. You would need to generate some sort of data structure (dynamic array, perhaps) which would allow you to fill the arrays with different numbers and then randomly select an index to match with whatever array you are iterating through. You would then delete that pointer in the array so that you guarantee that the next selection is different.
That's only if you populate the three boxes in advance. If you trigger the random generation on the click of the user it becomes trivial. First click rand(3), second click rand(2), third click remaining option.
Another, easier alternative, is to populate all the possibilities into arrays (pre-programmed) and then just randomly select one of the arrays. THIS is the most likely avenue they chose, considering that that's exactly how the vegas games worked, as well as the scratch tickets. There's a pre-set number of combinations and you randomly get one of the combinations.
So for the bonuts:
Possibilities are:
1,2,3
1,3,2
2,1,3
2,3,1
3,1,2
3,2,1
Then just a rand(6) and voila-- done. Most efficient solution.
About The Simpsons Tapped Out General Discussion
Talk about your The Simpsons: Tapped Out experience with other TSTO players.49,422 PostsLatest Activity: 10 hours ago
Related Posts
Recent Discussions
- 10 hours ago
- 2 days ago
- 2 days ago