LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array dice

Solved!
Go to solution

i am working on an example in a book i am reading and i am trying to count the number of times a dice lands on a side i have done this in C++ before but can not figure it out here is what they give me.

 

Harold Timmis

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 1 of 6
(8,872 Views)

Hi Harold,

     On each loop the dice are producing a random floating-point number where: 0 <= TheRandomNumber < 1.  The number is then scaled to be between 0 and 6 then rounded down to the nearest integer: 0,1,2,3,4, or 5.  Adding 1 yields the range of real-dice values:1,2,3,4,5, and 6 ("Current Roll" 😞 .

 

The thick orange wire is an array which is supposed to hold counts for each value rolled.  As you know, an array is an ordered collection of elements where the first element has an order or index value of 0 (zero.)  Of course, array elements are retrieved and updated via their array index.

 

The LabVIEW function that retrieves an array element is "Index Array".  The LabVIEW function "Replace Array Subset" is used when changing an individual array element.

 

It looks like all the pieces are there - think about how to use these array functions to update appropriate array elements depending on what random-value was generated.

 

Cheers!   

Message Edited by tbd on 12-03-2008 09:40 PM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 2 of 6
(8,856 Views)
This is how i have it wired problem is that the subset array does not save to the array because i cannot connect two things to the array
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 3 of 6
(8,823 Views)
Solution
Accepted by topic author Harold_Timmis

That's because your outgoing shift register is directly connected to your incoming shift register which is an empty array.

Message Edited by Ravens Fan on 12-04-2008 01:27 PM
Message 4 of 6
(8,812 Views)
You also don't correctly increment. You need to read and increment at the same index as you later replace. Right now you always read element zero.
0 Kudos
Message 5 of 6
(8,800 Views)

This is how i did it. The user can specify how many times they want to roll the dice.

 

 

dice.jpg

0 Kudos
Message 6 of 6
(7,739 Views)