0

I am creating a AI backgammon bot and have written some code using an arcade to show the board, pieces, etc. I have a function that will run a simulation game between two versions of the AI. When I use a button that advances the game by one turn, the code will run and I will see the results of the turn displayed on the board. (The on_draw method calls the draw_board(MainBoard) function to draw the current board which is updated by the function that makes the AI move.) I want to be able to similarly see all the moves in the game when I run the run_game() function. I do not have any fancy move animations, just want to draw a the current board between each move in the game. Is there any way to do this?

basically what I want:

while not game_over:
    make_move()
    on_draw() #This does not work, but is there some way to manually get the screen to update outside of the on_draw function?

Additionally, although this may be harder/not possible. Is there a way to keep the application responsive while the simulation is happening (using multiprocessing or some such thing) so I could have a stop button?

I hope this is not too confusing.

Wills
  • 40
  • 8
  • Usually the right way to do this is to inject additional events for the event loop to process rather than trying to process events within such a loop (which tends to lead to difficult reentrant code). – Davis Herring Jul 24 '23 at 00:12
  • @DavisHerring Thank you. Could you explain how that would work, or at least provide a link to where I could learn about it? I was not able to find anything poking around the docs. – Wills Jul 24 '23 at 13:25
  • You can run simulation in separate thread and graphics in main – Alderven Jul 24 '23 at 14:08
  • @Alderven Thank you. Is there anywhere you can point me too where I could learn how to do that? – Wills Jul 25 '23 at 15:20

0 Answers0