04-12-2015 06:18 PM - edited 04-12-2015 06:19 PM
Need to create a game of dice that starts by pressing a start button. After the game has startredm each tune you press 'dice' button a pair of dice are rolled and whoever have the higest number gets one point. In case of tie no points are given. Whoever gets 5 points first wins the game and you have to press 'start' again.
I'm stuck and i don't know what to do, need any help i can get please. This is what I did so far:
04-12-2015 06:30 PM
First, get rid of the 1 iteration for loops. They have no purpose.
Second you random number generator should round down, than add 1 to the result to get a roll of 1 to 6 with each number having an equal chance of happening. (Right now, 6 has a very slightly less chance than 1 through 5. And even a zero has a slight chance of happening.)
You will want to to the greater than, and add one to a player's total. You will want a less than and add one to the other player's total. If it is a tie, then neither will be incremeneted as a result.
The player totals you will keep in shift registers that. You need an overall while loop that will stop when either total reaches 5.
04-13-2015 06:58 PM - edited 04-13-2015 06:59 PM
Thanks for the help, ill try to do that.
-Daniel
04-13-2015 11:25 PM
This is what I did so far.
I need help in setting the shift register to store the accumulated points for each user, and also how to stop when either reaches 5.
My updates VI is on the attachments.
04-13-2015 11:31 PM
Have you tried running your code with highlight execution on to see how it is working? That should clue you in pretty quickly that is still has problems and where they are.
First, your inner while loops serve no purpose since they only run once, and the shift registers don't store anything because when your code runs again, they get reinitialized.
Have you taken those LabVIEW tutorials yet?
Your code is inside out and doesn't look anything like I described. You need a master while loop on the outside, the case structures on the inside that will either increment the counters or leave them alone.
04-14-2015 07:35 AM - edited 04-14-2015 07:35 AM
I would set this problem up like this. Use an event structure to detect when the button is pressed. The shift registers in the outer loop keep track of the totals. You can make some of your logic easier by subtracting the two values and use a case structure with three cases "..-1" for the second value being higher, "0" for both are the same, and "1.." for the first value being higher. Do whatever you need to inside of the case structures.

04-14-2015 05:50 PM
I tried connecting the I32 integer to the Index array but it's not accepting it for some reason..
04-14-2015 05:54 PM
Post your VI so we can see why.
Do you have a broken wire? If you turn on context help and hover it, it will tell you why.