From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Yahtzee Game

I need to create a Yahtzee game on Labview. I figured out the entire way to generate random numbers but I need to find a way so that the User can stop certain numbers from rolling so that they get their 3 times to try to get highest numbers they can. Here is a preview of the program. Any tips?
https://postimg.org/image/uk5gz70oj/

 

 

0 Kudos
Message 1 of 13
(4,914 Views)

You will want an array of buttons stating which elements to leave alone.  Then just use a case structure so that you do not replace elements you want to keep.


GCentral
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 2 of 13
(4,879 Views)

I'm confused on whats going on with left side of your picture. What are these current values?

0 Kudos
Message 3 of 13
(4,851 Views)

That is an array constant to give initial values to your dice.

 

(You can't replace the value of an array, if there wasn't an array element there to begin with.)

0 Kudos
Message 4 of 13
(4,848 Views)

@djcdominic wrote:

What are these current values?


It is mostly just a place holder.  In theory, you will be storing those values in a shift register on your outside loop.


GCentral
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 5 of 13
(4,844 Views)

OK so I have fixed it up a bit. I still have problems with the following:

-Keeping the value on the screen once locking it to the array

-System ending once all Three rolls are completed

 

Thank you guys so much.

 

Here is how it looks now. What should I fix?

0 Kudos
Message 6 of 13
(4,829 Views)

Your array constants are empty.  Crossrulz's are not empty and consist of 5 zeroes.

 

(His image is a snippet.  Drag that image to your desktop.  Then drag the image to your block diagram.  Now you have is code.)

 

Also, you have 5 copies of that code.  Notice he only has 1 copy and he is working on an array of 5 "dice" and 5 boolean switches for what to keep.

 

Also, I think you have too many loops, that or they are in the wrong order.  Right now if you hit okay, the inner For Loop executes 3 times without ever giving the user a chance to check or uncheck which dice they want to keep.  Your outermost while loop shoud have the shift registers, and the game should end once you've pressed Roll 3 times.

 

You should rename your controls to be something meaningful.  Stop 1, 2, 3, 4, 5 doesn't sound anything like the dice you want to keep.  And OK doesn't sound like it is a button you'd press to Roll the dice.

0 Kudos
Message 7 of 13
(4,815 Views)

Try something like this. Let me know if you have any questions.

 

Of course you should expand it into a state machine where you can start over with a new set of three rolls without stopping the program. e.g. implement a reset function.

0 Kudos
Message 8 of 13
(4,808 Views)

OK I have taken all your advice. Here is my program right now. Anyways to have to numbers stored in the number when pressed KEEP instead of it turning to 0? Also Is it possible to make the Stop button reset the program instead of closing it?

 

0 Kudos
Message 9 of 13
(4,732 Views)

You need to put your array wire into a shift register on the outer while loop as well.  Right now all of your dice reset to zero upon a new roll because you intialized your inner For Loop shift register to do that.

 

If you want the stop button to just reset the game, create an event for that, inside that event case, place the initial all-zero array as a constant to wire into the shift registers.

 

Don't forget to add a new stop button and an event case for that which will actually stop the VI.

 

Message 10 of 13
(4,730 Views)