//
So it looks like your Board[x,y] has a value of 0 for “no one’s gone here”, correct?
Add a temporary variable, aBlankSpaceExists = false. In your loop, if Board[x,y] == 0, set aBlankSpace = true. At the end of your loop, if aBlankSpace is still false, the board is full, and if GameOver is false, no one won - therefore, it’s a tie.
///
lol I was helping him with this originally… the spacing is messed up in the paste but I think I can slide StarManta’s suggestion into what you had 2 posts back…
void CheckWon ()
{
// move this**
if (SpotsPlayed == BoardSize) {
GameOver = true;
//winText.text = "Tie";
}
//winning logic
for(int x = 0; x < Board.GetLength(0)-4;x++) {
for(int y = 0; y < Board.GetLength (1);y++) {
if (Board[x ,y ] != 0 &&
Board[x, y] == Board [x + 1, y ]
&& Board[x, y] == Board[x + 2, y ]
&& Board[x, y] == Board[x + 3, y ]
&& Board[x, y] == Board[x + 4, y ] )
{
GameOver = true;
}
// Move this down here
if ((SpotsPlayed == BoardSize) && !GameOver) {
// got a tie
// also make sure to set GameOver here or something, but report the tie (if memory serves, GameOver is preventing more plays from going**)
}
}
Please make sure the braces line up correctly. Since I think I missed aligning them properly/code spacing is bad. ![]()