I implemented a thread for my unity project and it works fine on pc but it is broken for the android.
The thread is running a recursion and for some reason teh values returned are messed up. Can;t really explain what happens there yet though
What I do is create the thread on another script and run the method…is this the way to go for android apps?
this is my thread:
public int GetPCNextTurn(int[][] board,int height,int width,int sequence)
{
this.height = height;
this.width = width;
this.sequence = sequence;
this.board = board;
weights= GetWeights(sequence);
CompPlayTurn(board,weights);
Thread myThread = new Thread(() => CompPlayTurn(board, weights));
myThread.Start();
return col2play;
}
The pc used to mess the board I sent it (the code ruins the board with teh recursion but for some reason the change becomes permanent when using threads ) so I send a copy of the board.
But the android not only messes the board still, but the value returned is always the same…
Basically I have a recursion AI that should return the move to take, and this is what I ;d like to put in a thread…
Any suggestions?