Can I force program to calculate slower to prevent frame drop ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Inces

Hello

I am making turn based game. My AI has excessive calculations to do before every turn, and I believe these should not be optimised any more. They cause a sharp and short framedrop, that affects animations and actions coming afterward. Is there any way I can tell the code to calculate it calmly and start the animated actions only when the frame is back to normal ??

I also implemented all main calculations in one compressed line, like in this pseudocode :

func AI_pick_action():

decide(choosebestaction(countallpossibilities(“turn-now”),“sortbyrisk”),choosebestaction(countallpossibilities(“turn-future”),“sortbyrisk”))

Should I fragment this line into smaller parts to improve framework, or is it not necesarry ? Or should I use cascade of yields ?

You can force non-realtime simulation using the --fixed-fps N command line argument (where N is the desired framerate), but this will make the project run as fast as possible. You don’t want to use this in an actual game, but rather use it for offline rendering and stuff like that.

Calinou | 2020-12-02 17:31

Maybe do calculations in another thread? Just maybe.

MintSoda | 2020-12-17 06:15