11-24-2009 11:23 AM
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
11-24-2009 11:28 AM - edited 11-24-2009 11:28 AM
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!
11-24-2009 11:56 AM
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? 🙂
11-24-2009 12:42 PM
11-24-2009 01:05 PM
For those responding:This is the original thread.
It's questionable whether this is a school project or a real project.
11-24-2009 01:07 PM - edited 11-24-2009 01:10 PM
Alain, I have simplified your diagonal check..
11-26-2009 07:47 AM
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)
11-26-2009 10:34 AM
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
11-26-2009 11:19 AM
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!
11-26-2009 11:28 AM
ok soon I will post my images for you to help me