I am trying to incorporate an artificial intelligence (AI).
Hypothetically, lets say the game is chess. So when it is the AI’s turn, it is okay that the human player has to wait while the AI calculates what move to make.
Right now it takes 10-30 seconds to complete the code for the AI to make a decision depending on the layers of complexity I add to the AI decision making.
My problem is that the screen does not update during this block of code; meaning it feels like the game has locked-up or is frozen. Reading some of the Corona documentation, I realized that screen updates do not happen until all the code has finished running.
So any sprite or “transition.to” animation that I use doesn’t really do anything because the screen doesn’t update until the code has finished. And when the code has finished running, that means the AI’s turn is over and I don’t need that animation anymore.
However I want to give the human player some visual feedback that the game is still running and that the AI is “thinking”. Some sort of animation on screen, like a ticking clock for example.
Is there a way for me to update the screen and have the AI code run in the background at the same time?
Thanks.
[import]uid: 37876 topic_id: 10457 reply_id: 310457[/import]
[import]uid: 34945 topic_id: 10457 reply_id: 38115[/import]