I am working on a project for fun. What I am trying to do is create a C# version of the game Deal or No Deal.
Currently, I am struggling with the concept of the briefcases. What I would like to do is create an array of size 26 (there are 26 total briefcases) with values between $0.01 and 1M (just like on the game show).
This way, the case number can be the index of the array element and the values can be any value between $0.01 and 1M.
So, my question is: Is there a way to create an array that fills randomly with a predefined set of values?
Or does anyone think it would be easier to create a "briefcase" object with attribute of number and value?
Then write a loop which executes 1 zillion times. Each time around the loop pick 2 random numbers between 0 to 25 inclusive and swap the array values at those index's.
A bit like shuffling cards...
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
You don't need to swap numbers millions of times. The algorithm you are looking for is called Fisher–Yates shuffle and is quite efficient (check for the modern algorithm).
Bookmarks