Is it possible to ensure that a canvas is updated on screen in iOS.
I am trying to develop a simple two-player board game for iOS. It has 3 modes of play: 1) human vs. computer_algorithm; 2) human vs. human; and 3) computer_algorithm1 vs. computer_algorithm2. The game works fine except when I match up computer_algorithm1 vs. computer_algorithm2. Then the game still plays properly, but the canvas only updates the screen after the entire game is played, not after each “move” as I had hoped. I have tried to place a canvas1.invalidate command in a variety of methods / places to no avail. The game works fine when there is a human player because it takes time for the player to select a move. Showing each move is important since I had hoped to use it for training new players as well as for evaluating different algorithms and determining where they could be improved.
I have looked at timers and threads, but I can’t figure out how / where to use them in my situation. Below is a simplification of the code. Any suggestions appreciated:
while game_over = false
if player_to_move = player1 then
player_to_move = player2
player_to_move = player1