LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do two dimensional arrays?

I am a C++ programmer and in C++ I am able make a two dimensional array and input the values that correspond to those cells.

After I saw the proposals that you (experts) made I am going to share a little of the classified information that I was working for the undefeatable XO game.

 

First step:My idea was to make a two dimensional array(in C++ we use the following syntex for two dimensional array{array[i][j]})

I was wondering if I am able to make a two dimensional array using LABVIEW .

Second step: Store the values of X or O inside the 2D array.And use maybe boolean variables(in C++ we use inaddition to that if statement).

 

 

 

My second question :What can I do inorder to minimize the number of boolean vaariables?(also if statements in C++)

 

 

Jupiter

extinct when hell froze over
Message 1 of 16
(4,117 Views)

Hi Jupiter,

 

1) look into the array functions palette and pick the "init array" function... Or pick the array constant...

 

2) What variables? In LV you don't need variables, you use wires and shift registers instead!

 

Show code and we will help to improve it.

 

And better stick in one thread, so all needed information is kept in one place!

Message Edited by GerdW on 11-24-2009 06:28 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 16
(4,113 Views)

This is a subroutine I use to check for a winner in a XO game.

While playing, the main code replaces default 0's by 1's inside the 2D array of a single player.

Then the main code calls this VI with the 2D array of that player and check for a winning game.

Any board size is ok as long as you have equal number of cols & rows.

So, enter 1's at any location in the "Score" 2D array and the code will check for a winning game.

 

As you can see I don't use any boolean variables, except the return value of this VI (read function) 🙂

So to answer your second question; I minimized the use of boolean variables to 0 1! Is that ok for you? 🙂

Message 3 of 16
(4,086 Views)
Your VI claims there is a winner on an empty board.
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 4 of 16
(4,057 Views)

For those responding:This is the original thread.

 

It's questionable whether this is a school project or a real project.

Message 5 of 16
(4,044 Views)

Alain, I have simplified your diagonal check..

untitled.PNG

Message Edited by elset191 on 11-24-2009 01:10 PM
--
Tim Elsey
Certified LabVIEW Architect
Message 6 of 16
(4,042 Views)

smercurio_fc wrote:

For those responding:This is the original thread.

 

It's questionable whether this is a school project or a real project.


Gee..

 

Well..  Let's see.  

 

We want this super-duper robot to be able to play tic-tac-toe.

 

Wow..  a C++ programmer that writes:   array{array[i][j]} 

 

(no comments)

 

Message 7 of 16
(3,930 Views)

At least I share my ideas unlike you who likes to comment on others.

Soon i am going to post images of the labview prog. I am doing.

 

 

Jupiter

extinct when hell froze over
0 Kudos
Message 8 of 16
(3,904 Views)

Hi 9×95,

 

"Soon i am going to post images of the labview prog. I am doing."

 

Well, until now you have not. When you look for our posts you will find a lot of examples, either pictures or VIs...

 

As has been said before: Nobody will do all the work for you. But we are always willing to guide in improving your own code!

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 16
(3,893 Views)

ok soon I will post my images for you to help me

 

extinct when hell froze over
0 Kudos
Message 10 of 16
(3,888 Views)