I have a game where you play against an AI. The main pygame loop looks something like this:
def main():
running = True
while running:
# Some code here.....
if move_made == True:
move = ai_make_move(gamestate)
The problem here is that ai_make_move()
takes around 10-15 seconds to calculate. During this time the pygame window freezes since the main loop is not updating until ai_make_move()
is ready. Is there a way to make calculations in the background and keep the main pygame loop running somehow? So that I can e.g. move the window around during calculation time.