> LeekScript Tutorial
All calculations performed in an AI require some time to be executed by the server. This execution time is estimated by a number: the number of operations used by this calculation.
An AI cannot use more than 20 million operations in one turn. Fortunately, the number of operations used during the current turn by an AI can be obtained with the function getOperations, and the maximum number of operations with the constant OPERATIONS_LIMIT.
Here is an (almost exhaustive) list of the costs of the different actions that can be performed in an AI:
code | Cost -----|------ var a; | 1 var a = value; | 1 (Additional cost of value) array[key/index] = value; | (cost of enlarging the array) + 4
code | Cost -----|---- a | 0 function(params) | 1 + function cost array[key/index] | 2
Of course, the cost of a and b must be added each time.
code | Cost -----|----- a = b | 1 a++ | 1 a -- | 1 a+b | 1 a-b | 1 a*b | 5 a/b | 5 a % b | 5 a += b | 1 a-=b | 1 a = b | 5 a /= b | 5 a %= b | 5 a*b | 140
code | Cost -----|----- a == b | 1 a === b | 1 a != b | 1 a !== b | 1 a > b | 1 a = b | 1 a > b | 1 a >>> b | 1 a >= b | 1 a <<= b | 1
code | Cost -----|----- class object { ... } | 0 new object(params) | 1 + number of fields in the class + constructor cost object.method(params) | 2 + method cost object.property | 1 (only if we are outside the declaration of this object)
code | Cost -----|----- if(a) | 1 (Plus cost of a) has ? b: c | 1 (Plus cost of a, b and c) while(0) | 0 do {} while(0); | 1
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.