Todd Vance

Todd Vance

  • NA
  • 160
  • 130.5k

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

Nov 7 2007 9:48 AM

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)