12-03-2008 05:52 PM
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
Solved! Go to Solution.
12-03-2008 09:36 PM - edited 12-03-2008 09:40 PM
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!
12-04-2008 11:56 AM
12-04-2008 12:26 PM - edited 12-04-2008 12:27 PM
That's because your outgoing shift register is directly connected to your incoming shift register which is an empty array.
12-04-2008 01:23 PM
08-05-2011 05:45 PM - edited 08-05-2011 05:46 PM
This is how i did it. The user can specify how many times they want to roll the dice.