How to bypass the loop limit?

Rebuild the engine from GitHub source? :stuck_out_tongue:
Probably easier just to split the loops into sub-loops.
Instead of 1000x1000, do 10x10 sections can get each section to do 100x100.

Hey guys,
I am creating a procedurally generated tile based map. I start the construction of the map on event begin play, but I quickly run into the million loop limit that is meant to prevent infinite loops. Is there a way to bypass this?

To put it in perspective a 1000x1000 map automatically hits the million loop limit and that’s if all you do is generate a tile.

Hello,

You can go into ScriptCore.cpp and look for the property RUNAWAY_LIMIT. That property determines how many loops you can hit before the limiter kicks in. I hope that this helps!

Cheers!

so I tried converting my for loop into a for loop with a break and I break it up in intervals, so I’ll do like 1k iterations at a time → break → run loop again at last stopping point.

But this logic still caused the infinite loop detector to fire.

So looping other loops also hits this ceiling?

Try putting a sequence between groups of loops. If your map generates sector by sector it may get around the limit.

I would really like to not have to rebuild the engine from source and then deal with keeping it up to date at this stage. Is there any other way to get around this?

The problem with this method is there is no way to dynamically set how many pins are in the sequence

You could set it to the maximum that you could need and then use booleans to close paths down when they are not needed.

Interesting.
Is it ok to spread out the cretion over a few frames?
Set a timer or use Tick() to generate the tiles shortly after the Blueprint is constructed.

This either requires building the engine from source to fix the loop limit, which I would like to avoid, or using the tick() event. As I already tried using booleans to stop and restart the loop to no avail. The infinite loop detection must encompass all loops on a single event fire. :frowning:

Have you tried using the Tick Event? Creating a branch to stop the iterations once finishes?

Have you tried using a delay? You say you are generating the map which means play cant begin until the map is generated. There is a reason for this limit though, if you do an infinite loop in construction script it can render an entire blueprint useless. Another suggest I might have is to use “Do N” node.

Man, now that I have moved my code into the event graph I am having the same issue. Apparently this limit is not present in construction script…

I have another problem though… I am counting only 70K loops before the editor cuts me short with the 1000000 iteration limit. It is fine at 63K…

can i set DO_GUARD to 0 so it disable this infinite loop error?

Or you can just change the loop limit in project settings / general settings from 1 million to something higher.

I think this is what you want

you can increse the -1000 to extend the loops betwen breaks

EDIT this works just for 88000 loops