From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-17-2018 06:30 AM
Use a 2D I8 array with 4 rows and 4 columns. The 16 „playing cards“ are labeled by the numbers 1, 2,…,8. The array shall be initialized by 0 („no value assigned yet)
Implement the following SubVIs:
SubVI init: Initialization of the „playing cards“. Every n {1, 2,…, 8} shall be placed at exactly two different random locations of the array
input: 2D array initialized by 0
output: 2D array with randomly distributed Playing cards
init shall call SubVI placeNumber for every n {1, 2,…, 8} twice.
SubVI placeNumber:
Input: 2D array, number n {1, 2,…, 8}
Output: 2D array, number n placed at a random, free location
Use SubVI set:
Input: 2D array, two distinct positions (i1,j1), (i2,j2) of cards.
Output : numbers for both positions. A negative value indicates that the card was already removed. In this case, the move has to be repeated
move shall use SubVI get:
Input: 2D array, position (i,j)
Output : number for positionen (i,j) („uncovered playing card“). A negative value indicates a card that is no longer available
Note : please find the attached Working file and kindly help me to solve the Sub VI's
Regards,
Muthukumar
11-17-2018 08:48 AM - edited 11-17-2018 08:49 AM
Are you asking a question?
Or just showing us your homework assignment?
What does this have to do with "Memory usage of an array"?
11-17-2018 09:45 AM
Hello,
Thank you So much for replying . Actually i am new to Labview so the subject may differ.
But i am asking the question i have done the first SUB VI part that is what i have attached . So kindly help me to do the other Sub VI
Note: i have attached the PDF in that PDF if we drag down we will get question no A3 . that is the question i need to solve
Thanks,
Muthukumar
11-17-2018 10:05 AM
Sometimes BD Real Estate is worth more memory than the array size (easy enough with blue wires)
Your BD is too big and the While loop is not guaranteed to exit, you need a timeout!
11-17-2018 01:06 PM - edited 11-17-2018 01:16 PM
Jeff, your code does not guarantee that each card exists exactly twice. Here's what I would do.
Still, the instructions require the convoluted use of subVIs and to generate the array in steps by trial and error, so this cannot be used anyway. 😄
11-17-2018 01:51 PM
@Jocker005 wrote:
Thank you So much for replying . Actually i am new to Labview so the subject may differ.
The problem is called "Memory" because it tries to simulate a 4x4 version of the well known memory game
@Jocker005 wrote:But i am asking the question i have done the first SUB VI part that is what i have attached . So kindly help me to do the other Sub VI
You already have a version that potentially solves(?) (I have not tested) the problem with flat code. It is NOT a subVI and you don't have any connectors assigned.
Now you are required to create a subVI that takes a number and a 2D array as input and returns the 2D array with the number placed on a remaining empty (containing zero) field.
All you need is initialze a 4x4 array with zeroes and call it twice for each number 1..8. Since the 2D array completes incrementally it needs to be kept in a shift register for the duration of the game. You know about shift registers, because you already used them in your code.
(Note that the instructions have a mistake because the input to "place number" can also contain zero (not just {1..8} as written) until all tiles are placed.)
So, your init VI Calls "place number" 16 times. After that you create the remaining VIs to play, etc. operating on the 2D array as required.
@Jocker005 wrote:
Note: i have attached the PDF in that PDF if we drag down we will get question no A3 . that is the question i need to solve
Obviously, this is a course and you would not have to solve this unless you learned all required techniques in class. So go through your lecture notes. There are also plenty of online tutorials. The forum is a good place to ask questions and we will make sure to point your nose in the right direction if you run into a wall, but we will not write you a turnkey solution, of course. So please continue to write code and whenever you run into a problem, ask specific questions. We are here to help. 😄
11-18-2018 10:47 AM
@altenbach wrote:
Jeff, your code does not guarantee that each card exists exactly twice. Here's what I would do.
Still, the instructions require the convoluted use of subVIs and to generate the array in steps by trial and error, so this cannot be used anyway. 😄
Use Riffled Index ! simpler!
11-18-2018 12:55 PM - edited 11-18-2018 01:18 PM
@JÞB wrote:
Use Riffled Index ! simpler!
No, then you would get numbers [1.. 16] once each instead of [1 ..8] twice each.
(If you use the riffled index, you would need to e.g. add a Q&R and continue with the remainder, for example. More code!)