Example Code

Card Shuffler

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

Coding that exemplifies how to simulate a cut off, or shuffle a deck of cards.

 

Description

The deck of cards is an array of clusters containing a value and a suit. The shuffle VI has 2 types to choose from (for now): riffle and cut. "Cut" simply divides the deck at a specified cut point. "Riffle" simulates the standard riffle shuffle. The deck is first cut and then cards are interleaved randomly.

Note that, since the Riffle shuffle replicates real shuffling, you may have to shuffle multiple times to get a well-shuffled deck.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Select if you would like to Shuffle, or to Cut the deck.
2. If you want to Cut the cards, select at which point you want to make the cut.
3. Run the VI.

 

Additional Information or References

Snippet.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.