mardi 21 août 2018

Unity keeps freezing in while loop having a random function

I am making a tic tac toe game unity And when its the computer's turn , it selects a random number if the random number is already marked then it generates another random number and checks it again , but its getting stuck in while loop i don't know why.

<i> public void checkComputer()
    {
         if ( Variab == 0 && whoseTurn == 1)
            {
                int j = 0;
                int rand = Random.Range(0, 8);
                while (markedSpaces[rand] != 1 || markedSpaces[rand] != 2)
                    {
                        rand = Random.Range(0, 8);
                        j++;
                    }

                    TicTacToeButton(rand);

            }
    }</i>




Aucun commentaire:

Enregistrer un commentaire