LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a better true false loop, and how to replace previous ring picture? Checkers Board Game

Still working on the checkers project, we got the ring picture to change while running. Despite of this progress we cant seem to replace the ring image when moving the checkers piece. My partner and I struggle to make a better true and false statement for our case structure. If anyone can offer legit advice it would be great, and the Project.Vi is attached incase anyone wants to run it. This is our first time, so I apologize if this looks like garbage.

 

Thank you!

0 Kudos
Message 1 of 2
(2,316 Views)

What is a True-False Loop?  You can have a True/False case structure.  But Loops are just loops.

 

You have some weird constructs in your code.

1.  You use local variables of indicators X and Y when the terminals for X and Y are sitting there unused.

2.  You have a shift register for the 2-D board array, but you never use the wire that comes from the left side shift register.  You just use a local variable of board.  Using the local variable defeats the purpose of using the shift register.

3.  You are using local variables of clicked index base on the two different loops.  Are you sure "clicked index" is being passed between the loops without race conditions?

4.  You have two different event structures in your VI.  That in itself is not a problem.  But I find that people who do use multiple event structures and don't know what they are doing are almost certainly going to have problems.  And when I see other problems in the code, I have doubts that they'll know how to use multiple event structures.

5.  Your code in the True/False case structure is pretty redundant.  The only thing different between the two cases is the True vs. False constant you have wired inside the cases.  That is showing two other problems.

5a.  Why have a Select case in each one.  The False side will never execute in the True case because of the true constant.  The True side will never execute in the False case because of the False constant.

5b.  There is no point to have the case structure at all because of the identical code and that the True vs False constants are redundant because the Select structure can be controlled by the boolean button directly.

6.  What is the point of the 1 iteration For Loop.  I cause it is just to initialize the board, but you don't need a 1-iteration For Loop to contain it.

7.  No need to run an array constant through an I8 bullet.  If you want board to be an I8, just change the representation of the elements in that array constant to be I8.

 

Probably what you are truly asking about here is the logic that goes into your clicks.  You need to definitely work on that.  I noticed clicking on a red empty square will make it into a black square with a black piece.  That is certainly wrong.  You need code so that clicking on red squares does nothing.  Clicking on a red piece turns it into a black piece.  That is certainly wrong.

 

Whatever I click ultimately turns the whole board into black squares with black pieces.

 

You need to work out a logic table that a click on any particular square determines whether it is permissible at all, and what that square should look like after the fact.

 

 

0 Kudos
Message 2 of 2
(2,292 Views)