Example Code

Rock Paper Scissors using Events in LabVIEW

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

This example shows how to build a Rock Paper Scissors game on LabVIEW.

 

Description

This Application allows the user to play Paper Rock Scissors against the computer. The user selects his choice by clicking one of the buttons. The value change of the button causes the computer to pick a random choice The choices are compared and the result is displayed. The game also uses shift registers to keep track of wins, losses, and ties. It also calculates the percentage of each.

The computer’s choice is calculated using the random number (0-1) function and evaluating the number of predefined ranges. This could be easily expanded to generate an algorithm that generates random choices in other programs.

 

Requirements
LabVIEW Base Development System.

 

Steps to Implement or Execute Code
1. Open the attached zip file name Rock Paper Scissors LV 2012 NI – Verified.zip.
2. Open the Project named Rock Paper Scissors Game LV 2012 - NI Verified.lvproj.
3. Open the VI named Rock Paper Scissors LV 2012 - NI Verified.vi
4. Run the VI.
5. Use the boolean buttons to play.
6. Verify the results.

 

Additional Information or References

 Snippet 4561.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

Bryan H.

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

Comments
Todd S.
NI Employee (retired)
on

Great stuff!  Thanks for posting!

Todd S.
LabVIEW Community Manager
National Instruments