Time AI
Add Coroutine To AI
The default behaviour of AI is execute immediately when it's on their turn. However, a delay, before they starts their calculation can be done through steps below.
Steps 1 - Remove unnecessary code
In ChessGameAIGUI script, there are numerous line of code contains macro #if (UNITY_WEBGL && !UNITY_EDITOR)
, uncomment or remove them entirely. Do the same for the content inside the #else
statement, if there's any. In the end, what remains will be those code within the if statement.
*EXCEPT those macro in RequestAIMove()
function, just don't do this step in the function, otherwise, screen will freeze while AI is calculating.
Steps 2 - Migrate code to next steps
In the RequestAIMove()
function, remove the line AITurnEffect(isAIMoving);
Steps 3 - Making the request to AI move function a timed coroutine
In the IEnumerator AITurn()
function, the code within should become something like
Last updated