> LeekScript Tutorial
You code your AI like a blessed. The lines scroll, and the names of... No wait, we've already seen that. This time, no more red messages in the editor, the compiler has no more secrets for you. It's duel time! You observe your leeks in their natural environment, like Steve Irwin in the vegetable garden. They walk around, they frolic, they machine-gun each other, they look happy!
They do not suspect that in the shadows lurk formidable enemies...
Ahhh a classic!! This is not necessarily an AI error, but an overrun of the maximum number of operations (OPERATIONS_LIMIT set at 20 million operations). Check out the Operations tutorials for a detailed article.
In this case, we can bet on a loop without a stopping condition, which is called an infinite loop (see The Loops).
A small example? Here is a little code to use the weapon on the opponent as long as we have TP: 
Stupid huh? Well no ! An error appears during execution: Basic, line 13 ▶ AI Interrupt: Execution Error: Too many operations executed for this round
What could be the problem... Well quite simply, as long as the getTP() condition > 0, the loop will execute. But what will happen when we can't use the weapon? Well we're not going to lose any TP! And the condition will always be true! So we have a loop that will run ad infinitiiiiiiiiiiiiiiiiiii.
To correct this case, we can test the return of the useWeapon function and analyze the result.
Possible fix:
It's not the size that matters!
Without reading your AI, I would have a hard time correcting you... We can still cite a few possibilities:
lineOfSight function once costs you 15 operations, using it in 3 nested loops will cost you!getCellToUseWeapon should not be abused! It is useful to store the result of functions that consume a lot, or recode them.So this time I was careful, I put the right number of parameters in my function. So, yes, but you can't put just any parameter in the native functions. These functions require certain input types. If you try to use them with the wrong parameters, you will get a similar result:
AI Basic, line 14 ▶ Unknown function: useWeapon(function) AI Basic, line 14 ▶ Unknown function: useWeapon(null)
Here, the useWeapon function takes a number argument (a WEAPON_... constant) and we try to give it a function, or a null. Obviously the generator groans on us.
AI Basic, line 11 ▶ Unknown function: sort(number, null) sort expects an array as first parameter, and we try to give it a number.
Basic AI, line 8 ▶ Unknown function: getNearestEnemyTo(array) getNearestEnemyTo takes an entity id as a parameter, not an array.
This error can also occur because of missing parentheses:
Here we store the getNearestEnemy function in the enemy variable, rather than its result (see Functions. Fix: var enemy = getNearestEnemy();
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.