05-02-2025 06:36 PM
I am in a LabView class in school and we were assigned our final project which is just making a tool or game using LabView. I've been interested in making the simple dice game "Farkle" but so far my progress has been small as making this in a program not designed for this is challenging. I'll provide a photo of what I have so far but the only help I have with making this program is looking at what people have done to make Yahtzee style games and then using that or just using ChatGPT to help me with specific questions but so far I haven't been very successful. At this point I just want to be able to roll six dice and select which dice I want to keep and which I want to re-roll.
05-02-2025 06:53 PM
Glad to see students learning LabVIEW!
Many LabVIEW problems, including many of the ones I can see in your starter code, come down to a misunderstanding of how execution order works, which in LabVIEW is driven by what we call "Dataflow". Hopefully that was covered by your class?
If not, quick summary: In a LabVIEW VI, a block diagram node can only execute after receiving data for all inputs. When a block diagram node executes it can return data through wires which in turn 'flows' to other block diagram nodes.
What you might not realize is that everything on a LabVIEW block diagram is one of 3 things:
So all those For loops? Nodes. While loops? Nodes. Event structure? A node.
In particular, with what you have made so far the biggest problem with it is your event structure. Event structures, in addition to needing all their input data to start executing, also need one of the conditions for one of its frames to occur. If none of them occur, it will just sit there forever. So the way you have your code set up it will run everything in it once, and then wait for an event, then repeat until the stop button is pressed.
...Except it will repeat one last time, because the read of the "stop" value occurs immediately when the loop starts, so it doesn't check the "stop" value again until the loop starts again. And then the loop won't finish then either, because you have to press a button to make the event case resolve.
Anyway, what I would suggest is that you look up something called a "state machine" in LabVIEW. If you implement a state machine it allows you to run your code in an order that is a lot easier to manage than putting everything all in a row in one big loop. There's plenty of lessons and examples of state machines out there so I'm not going to repeat them here.
05-03-2025 10:06 AM - edited 05-03-2025 10:06 AM
Also have a look at your FOR loops. All their code can be combined into a singe FOR loop.
A bad idea is to have controls disconnected outside the toplevel loop. (Roll Dice). Since it is a latch action boolean, it will only reset once it is read by the code (in your case never once the loop runs), that means it will never return automatically when pressed.
So, all you need is a simple state machine as has been suggested. The hardest part is probably the scoring of all combinations, Once you decide what rules to use. Create a subVI for that!
Have you looked at the learning resources listed at the top of the forum? I would think all necessary tools would have been covered in class already, so look at your notes.
In any case, we can't really debug pictures (e.g. we cannot see what's in the other cases of case structures or what the controls really are. So please attach your VI (Make sure to do a "save for previous", (2020 or below) if you use a newer LabVIEW version.
05-03-2025 12:39 PM
Here is a Tip:
Do not "Roll the dice" take the 0th riffled index++ of each die array[size n] as the TOP of each die. (Use the current riffle.vi not the deprecated version) it scales much better when your scope-creep changes from 6d6 to ndn, whatever the dungeon master requires. solve for the General Case!
05-03-2025 12:51 PM
All you probably need is Random number (range). No need for orange. Keep it all blue.
05-03-2025 01:30 PM
@Kyle97330 wrote:
Glad to see students learning LabVIEW!
Many LabVIEW problems, including many of the ones I can see in your starter code, come down to a misunderstanding of how execution order works, which in LabVIEW is driven by what we call "Dataflow". Hopefully that was covered by your class?
If not, quick summary: In a LabVIEW VI, a block diagram node can only execute after receiving data for all inputs. When a block diagram node executes it can return data through wires which in turn 'flows' to other block diagram nodes.
What you might not realize is that everything on a LabVIEW block diagram is one of 3 things:
- A decoration
- A wire
- A node (or part of a node)
Almost. Technically, Constants, FlatSequences, and Terminals are none of the above.
05-05-2025 02:55 AM
Hope you don't give up on this just because you are making it "in a program not designed for this". LabVIEW is no more or less designed for it than other programming languages/environments. Having a clear goal like you have is a great way to learn.
When you have the base game up, then you can add cheating dice, like in KCD2. My guess is that is where you found the game. Its crazy how made it fun to play dice in a game not about playing dice.
Then you can add graphics, rolling the dice. But probably not in LabVIEW, but then you will learn how to interact between LabVIEW and other languages.
05-05-2025 11:29 AM
You can do the dice role in LabVIEW. I made this for a game I made a while back.
05-07-2025 04:25 PM
I made a Craps game a long time ago just for fun using a simple State Machine
05-08-2025 08:09 PM
Nope! I haven't given up on it. I just haven't had a good amount of time to dive in and see where I can improve and attempt to use an event structure/case. And, yes, I did first learn about Farkle from KCD2. "Care for a round of dice, Henry?" (loving it so far).
I just got to my class so I'll be tinkering a bit more with LabView with the help of my teacher.