public void CheckLose() { //This seems massively inefficent, but we'll see //May be able to optimize via an iterative approach? //do the checks for three in a row. Means player has lost. AI will automatically admit defeat. for (int x = 0; x < tileArray.GetLength(0); x++) { for (int y = 0; y < tileArray.GetLength(1); y++) { if (tileArray[x, y] == 1) { vertRowCount++; //Only need to check verticals when on top row if (x == 0) { Debug.Log("x was 0"); checkHorizontal(y); if (y == 0 || y == 2) { checkDiagonal(y); } } } } if (vertRowCount == 3) { defenseData.EndGame(false); //Would need to stop AI from picking and end update } else { vertRowCount = 0; } } }