LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

memory game vi

Solved!
Go to solution

Hi,

 

  I am trying to do a memory game but I am facing some problems with the Flat Sequence Structure.

The for loop in the second frame compares but it gives only the last comparison.

How can I solve it?

(If I split the cases into 4 TFFF FTFF FFTF FFFT, it becomes more complicated and the case FFFF will be hard to program)

 

 

 

P.S.   Labview Version 11

0 Kudos
Message 1 of 25
(4,170 Views)

I think I would use a cluster here. I would have a button that covers an image file. When you press the button it would go to transparent mode displaying the image. You could keep the cluster and image arrays so that you could do the comparison when the button is pushed.

Tim
GHSP
0 Kudos
Message 2 of 25
(4,161 Views)

Maybe you should start with explaining what the program is supposed to do. Is the final goal something like simon?

 

  • Have you ever wondered what would happen if you delete the all true diagram constant and equal comparison in the second loop? The outcome would be exactly the same.
  • The number of iterations of the while loop is known before the loop starts, thus you should use s FOR loop.
  • Shouldn't the second replace array subset be in the outer loop?
  • Why are you saying you have a problem with the flat sequence structure? That part seems to be working fine. Think about eliminating the flat sequence and use data depedency to determine execution order.
  • You should make reasonable values for all controls as defaults before saving so we know what is normal.
  • What is the second loop actually supposed to do?
  • ...
Message 3 of 25
(4,159 Views)

Back for more homework help, I see. Smiley Wink

 

Well, the direct answer to your question is that it has nothing to do with the sequence structure. In fact, the sequence structure serves no purpose in your code. You could remove it and the code will work exactly the same way. The problem is that the for-loop is working as designed. The value that's being generated by the Add function changes with each iteration. Since you are wiring its output through a tunnel, by definition you only ever see the last value. Did you intend to auto-index?

 

I don't understand the intention of this "game". How is it supposed to work?

 

You should consider looking at standard programming architectures. You will save yourself some headaches in the future.

0 Kudos
Message 4 of 25
(4,155 Views)

mmm..

I don't want to use any pictures at the moment for the game(pure LABVIEW palletes).

As for the cluster, isn't it the same as the array in this case?

I'm having the difficulty in the element at index 3 of array2.

0 Kudos
Message 5 of 25
(4,150 Views)

@ altenbach:

I 've seen this problem and I'm trying to figure it out. (its taking the last value)

How come the number of iterations are known? It depends on the user when he will click( i used a while loop so that each time the user clicks it will count it to be equal to x.)

In the second loop, I try to figure out what the "index" the user pushed.( this is what I'm having trouble with- user interface)

 

 

@smercurio_fc:

This is no homework, project, extra bonus point exercise...And only time will tell.

reasons:

homeworks: my last post was the last homework

project: more about sensors and dimensions

extra point: lol, no extra points

For the resulted compared array, I meant to auto-index.

 

intentions of the game:

 

  The user will run run the program and the array should turn on-off randomly and user should try to memorize it

and try to click on the same pattern. until he makes a mistake three times and the game is over.

 

Its the first time I work with a code that there are user interface( The clicking of the user )

0 Kudos
Message 6 of 25
(4,142 Views)

Here is how I would start

Tim
GHSP
Message 7 of 25
(4,120 Views)

aeastet, I could not understand your code. It gave me wrong cases when I hit on the lighted parts.

 

I'm attaching the new code but I couldn't figure how to solve the problem.

 

Can you give some example where the user interferes and the output is totally related to the user.

simple example where the user clicks on an ok array and the output are the indecis of the elements clicked? number of clicked is predefined.

 

thanks

Message 8 of 25
(4,084 Views)
Solution
Accepted by topic author A.A.A.

here is the latest version

Tim
GHSP
Message 9 of 25
(4,080 Views)

Tim, your program works and does the job but it differs insome situations from my program. You use 4 independent variables while I use an array; you also use an event structure.

Is there a way to eliminate the event structure and use simple loops and case structures(I have minimal knowledge with the event structure)

Can you show me an example where the user clicks on different elements of the OK array and the outcome is the index of this array; if I understand that part I will do my own version of the mind game with no event structure

Thats what I did for this part and it doesnt work userindex.png

0 Kudos
Message 10 of 25
(4,060 Views)