LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Game of dice

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: 

 

 

Untitled.png

0 Kudos
Message 1 of 8
(6,651 Views)

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.

0 Kudos
Message 2 of 8
(6,639 Views)

Thanks for the help, ill try to do that.

-Daniel

0 Kudos
Message 3 of 8
(6,548 Views)

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.

 

Untitled.png

 

 

0 Kudos
Message 4 of 8
(6,521 Views)

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.

0 Kudos
Message 5 of 8
(6,514 Views)

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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(6,473 Views)

I tried connecting the I32 integer to the Index array but it's not accepting it for some reason..

0 Kudos
Message 7 of 8
(6,444 Views)

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.

0 Kudos
Message 8 of 8
(6,440 Views)