Hi there i am new at this, i was reading the forum and i found this thread which is very nice.
http://www.b4x.com/forum/basic4android-getting-started-tutorials/8506-tick-tack-toe-working-arrays-views.html
I downloaded the example and tried to understand the logic, so i found this sub called Checkifwin which receives the current player name and return a boolean value.
First thing check the columns , then rows and finally diagonals.
Here is checking columns
this line here "If found = True Then Return True" means to me the function is returning a true value, but then it keeps going to the second row and returns another value.
What i dont understand is how do you know whether (0,1)(0,2),(0,3) are true if the variable "found" is being overwrited each row.
If somebody could explain it to me i'll aprecciate it.
Thanks
http://www.b4x.com/forum/basic4android-getting-started-tutorials/8506-tick-tack-toe-working-arrays-views.html
I downloaded the example and tried to understand the logic, so i found this sub called Checkifwin which receives the current player name and return a boolean value.
First thing check the columns , then rows and finally diagonals.
Here is checking columns
B4X:
Dim found As Boolean
For x = 0 To 2
found = True
For y = 0 To 2
found = found AND Buttons(x, y).Text = Player
Next
If found = True Then Return True
Next
this line here "If found = True Then Return True" means to me the function is returning a true value, but then it keeps going to the second row and returns another value.
What i dont understand is how do you know whether (0,1)(0,2),(0,3) are true if the variable "found" is being overwrited each row.
If somebody could explain it to me i'll aprecciate it.
Thanks