Function Manipulation

(info) This AI is still in early stages of development.

Function Manipulation

Create new functions based on existing functions...

 

Overview

These features allow you to create new functions based on existing functions:

An example of using both in relation to Warzone scripting is shown below:

Example

// create isMyAlly() function by pre-specifying 'me' as a param // on JS API's allaianceExistsBetween() function... var isMyAlly = allianceExistsBetween.curry(me);   // create a wrapper function... var NOT = function(bool) { return !bool; }   // create isMyEnemy() by wrapping isMyAlly() with the NOT() function... var isMyEnemy = NOT.wraps(isMyAlly); for (player = 0; player < maxPlayers; player++) { if (player == me) continue; // ignore me   if (isMyAlly(player)) { // do nice stuff to ally } if (isMyEnemy(player)) { // do nasty stuff to enemy } }