2
Answers

How to read Diagonally (tic tac toe) to check for a win.

Todd Vance

Todd Vance

16y
10k
1

I'm trying to build a program for school that plays tic tac toe.  I DO NOT want to make it the standard 3x3.  I was hoping to make a bigger grid (4x4 or 5x5) but with the same win conditions of three in a row.

I thought I would make a two dimensional array of text boxes that either mark X or O when clicked.  I THINK that simply checking three in a row would be easy enough to see if there is a win BUT CAN ANYONE give me a clue how to do this for Diagonals?

My thoughts were to check an if statement that looks subtracts or adds one to each of the dimensions and IF there is a matching X or O then does it again by adding or subtracting again...then we should have a win.

 

HOWEVER, this becomes complicated and messy for those boxes starting on the edges.... ????

Answers (2)