Quote:
You have your board, a 3x3 array like this
_ _ _
|_|_|_|
|_|_|_|
|_|_|_|
If you number them 1 to 9 like this:
123
456
789
then you have the 8 possible winning lines of 3 here in this list:
123,
456,
789,
147,
258,
369,
159,
357.
So what you do is you create a second array to represent the list you have, so that each row in the array represents a winning line. This array will be 8 rows by 3 columns. Call this the lookup array.
When you add a 0 or X to the 3x3 grid array, you would add that same 0 or X to each of the entries In the lookup array. So, say you had this grid:
0|_|_
0|X|_
X| |0
Your lookup array would be like this:
0 _ _
0 X _
X _ 0
0 0 X
_ X _
_ _ 0
0 X 0
_ X X
You have to fill in your lookup array with the coordinates of the grid squares that are indicated by the numbers on this grid: