- Home /
How to update new frame while another is computing?
Hi! I'm doing a checkers program and I want to show to screen the human while the program is computing the move of the AI. Here goes the transition between the Human and Computer move:
void FinishHumanMove(GivenMove givenMove) {
ApplyMove(pieceOnBoard,givenMove);
UpdateBoard(); //Visual Update
ComputerTurn();
}
void ComputerTurn() {
currentPlayer = WhoIsPlaying.Computer;
GivenMove chosenComputerMove = MinimaxDecision(pieceOnBoard,7);
ApplyMove(pieceOnBoard,chosenComputerMove);
UpdateBoard(); //Visual Update
UpdateTileComputerMove(chosenComputerMove); //Visual Update
HumanTurn();
}
However, because the computation time is quite long is the ComputerTurn() function, the UpdateBoard in the FinishHumanMove() does not finish, hence there is a feeling of lag. I checked the yield function and coroutine, but i don't know how to use them to solve my problem.
Any suggestion to how to finish the rendering of the UpdateBoard() while computing the ComputerTurn??
Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220613093415im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
why is every 2. frame is weird with Time.deltaTime 1 Answer
Boolean Trouble, Please help....Boolean does not flip another boolean 0 Answers
Play method only ONCE when detected by the update function 3 Answers
Character,Camera,Updates,Frame Rates,Jitter&Stutter, I need some explanations. 0 Answers
Update Guitext every frame 1 Answer