Here's a breakdown of a game loop I'm currently using:

while (true){ //unprocessedTime calculations. Ignore while (unprocessedTime > 1){ tick(); } } tick(){ for (i: 0->units.length){ units[i].tick(); } } //The element in units Units.tick(){ for (i: 0->units.length){ //Do calculations that calculates the distances between each and every unit. For pathfinding. } }

I abridged a lot of the details in my code, only leaving the nested loops above. As you can see, the level of nested loops reached 4, therefore, my game is running at O(n^{4}).

People say this will cause the program to grind the CPU on older computers to an amble speed, thus slowing down the calculations. I do know doing pathfinding algorithms require extensive uses of loops, however nested they required.

Is this a sign of trouble? Does the fact that optimizations can only go as low as O(n^{4}) because of the way nested loops work in the game logic?