03-14-2016 09:58 AM
Think of it like shuffling a deck of cards.
It is a simple way of randomizing a series of elements.
Actually I think it is too simple of an answer and is not the answer your teach is going to be expecting since I think you are supposed to be learning how to program in LabVIEW, Dropping a simple Riffle function on a block diagram is not teaching you anything about how to program in LabVIEW.
03-14-2016 10:05 AM
@Solrac_0 wrote:So here is my second attempt to post my VI. So Im trying to figure out what to do next. I need to create a lottery generator simulator. Numbers must be betwen 1-69 and they cannot repeat.
I took a screen shot of the VI just in case it's blank again.
The inner loops and array handling are a bit messy. No need for the last 1/2 dozen versions of the array.
When you generate a number, search the array coming from the shift register to see if it exists. If it does, then repeat the inner while loop. If it does not, end the while loop and Build that number onto the end of the array to put back into the shift register.
Have your while loop do this 6 times (not zero).
03-14-2016 10:06 AM
@Solrac_0 wrote:So here is my second attempt to post my VI. So Im trying to figure out what to do next. I need to create a lottery generator simulator. Numbers must be betwen 1-69 and they cannot repeat.
I took a screen shot of the VI just in case it's blank again.
Your shift register should not have an array. Initialize all of the history shift registers to 0. Then you should be all but there.
03-14-2016 10:07 AM
@Solrac_0 wrote:So here is my second attempt to post my VI. So Im trying to figure out what to do next. I need to create a lottery generator simulator. Numbers must be betwen 1-69 and they cannot repeat.
I took a screen shot of the VI just in case it's blank again.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
03-14-2016 10:56 AM
so i mangaged to get this far but my program only genarates the same number. How do i make it genarate differnent numbers?
03-14-2016 11:01 AM - edited 03-14-2016 11:02 AM
03-14-2016 11:02 AM
But that doesn't answer my question!!
03-14-2016 11:05 AM
Hi solrac,
I moved your new message into your older thread - please stick with one thread as much as possible…
Well, creating an array from your lottery numbers would help!
To build an array I often use the function BuildArray. Or I use the autoindexing feature of a loop output tunnel.
Both are basic LabVIEW stuff: did you go through all those free online tutorials to learn basic LabVIEW stuff?
03-14-2016 11:17 AM
I finally got it!!!!! Thank you all!!!!!
03-14-2016 11:56 PM - edited 03-15-2016 12:00 AM
OK, I'll jump back in again now.
Yes, I intentionally miswired the init array. but taking the riffled index out of riffle.vi is just so slick I had to show it. Surprisingly the "Lottery Generator" problem is quite common! I've even had it presented TWICE as a practical interview exercise!
Was it perfect each time? (of course not! the danged vi was less than a perfect implementation originally! The examiniers didn't know that though!)
Now, with that stated! If your want to randomize the distribution of a set- Riffle them! just like "Riffling" a deck of cards or ma-jong tiles. Certainly some bright mathmatician found a easy way to do that or casinos would loose their shirts!
I learned that small bit of info way back when I was asked to build a "Bridge" game in the 9th grade. The darned "Game" dealt poorer hands on average than you would expect to see. The Computer, riffled the cards more randomly than a human (And some dealers stuff the deck)