Vectors, FacingTowards and looting Coins

I have run into hard execution limits many times. Do not let this confuse you… Unless you can find it, your code is not necessarily slow or running large loops.

Despite much conjecture on this, I’ve found that using loop { breaks; } over whiles and fors (even if they run the same calculations) helps whenever you can do it. Chances are there is nothing wrong with your code, but putting limits on execution can help. In my experience, they help considerably.

Limit 1

Cache as many values as possible by storing them in a local variable. This even includes property lookups. One thing that I cache that others may not is friends and enemies. Then I only do recalcs when the field has changed. This allows for a lot of leeway.

Limit 2

Check a given condition as few times as possible per loop iteration. Combined with caching, this also helps considerably.

Limit 3

Use assertive code. I.E. Force the conditions to meet your desires as much as possible.

Limit 4

Avoid Functions. On every level I have used a function, the hard execution limit occurs faster than if it is just run inline. As much as I love functions, until this is fixed, I have sworn them off.

Limit 5

Integers as much as possible. Don’t know why, but it’s demonstrated itself over and over again. When I replace a float with an integral counterpart, fewer hard limits are reached.

Final Note

It is important that your hero always perform an action (even a wait()). Normally a move() is sufficient.

While I can’t say why it happens (only the devs can do that), These tips have helped me considerably. They do require inventive coding, however, which sometimes becomes a bit convoluted. These posts may also help:

2 Likes