I am building an Othello game( it similar to Go game) on android device by using Android Studio.
I used the minimax algorithm
to build a smart bot to defeat the player. However, there are many recursive call in the minimax algorithm
, so the calculation of the bot is very slow( I have tried to play and saw that it took about 30 seconds for calculation). So, I want to show a progress bar
to signal the player that the bot is calculating. I have tried as follows but the progress bar did not show on my activity:
//Each time the player goes one step, I show progress bar on activity
// to signal to the player that the bot is calculating
progress_bar.setVisible(View.VISIBLE);
//Then, wait for bot's calculation. I have tried to play many time
//and I saw that it takes about 30 seconds
minimax = new Minimax(chessColorMaxtrix);
best_position=minimax.findBestMove();
put(best_position); //complete bot's calculation
//Then, I set the progress bar invisible
progress_bar.setVisible(View.INVISIBLE);
//And wait for the next move of the player
Further, if I do not do progress_bar.setVisible(View.INVISIBLE);
then the progress_bar shows on activity normally. But it is not what I want.
I want to ask, Is my progress_bar
usage right or wrong? If right, why did not the progress_bar
show on activity. If wrong, How can I solve may problem?