Search code examples
java-menokia-s40

How to add a pause between player move and AI's move in checkers game?


When in my game, a player makes a move, its not visible until the AI move is computed. And then both the moves are shown together.

I want to show player's move and after that, AI move (after its computation). I tried Thread delay but no use. How to add this visibility using some kind of a pause, but that pause must not pause the execution of the program?


Solution

    1. Player made his selection, stop accepting player input, start animation for player movement in a Thread and start AI in another Thread.
    2. When AI is done, while animation for player movement is not done: wait(100). When animation for player movement is done start animation for AI movement.
    3. When animation for AI movement is done resume accepting player input.

      In step 2, if AI takes longer than the animation for player movement, show some waiting animation. This waiting animation should be stopped before start animation for AI movement.