In the function at your code must be placed here we add the following lines:
// "local" global variables for stuffs that will need a unique ID
// Note that since order of loading is alphabetic, this means this file must go before any other file using them.
m.playerGlobals = [];
I copied this lines from aegisBot and i dont know so much, what this line does.
I think they will be create a new object, which will contains the game goals and will be filled by common-api.
After this lines we append the following lines:
m.NewAI = function NewAI(settings) {
API3.BaseAI.call(this, settings);
this.turn = 0;
this.playedTurn = 0;
this.Config = new m.Config();
this.Config.updateDifficulty(settings.difficulty);
this.Config.personality = settings.personality;
this.firstTime = true;
this.savedEvents = {};
this.defcon = 5;
this.defconChangeTime = -10000000;
};
This lines are also copied from AegisBot and loads the BaseAI from the common-api module.
After this lines you have to add the following line:
m.NewAI.prototype = new API3.BaseAI();
You have to replace NewAI with your own module name!
At the moment my file newai.js contains the following text:
var NEWAI = (function() {
var m = {}; //an empty object
// "local" global variables for stuffs that will need a unique ID
// Note that since order of loading is alphabetic, this means this file must go before any other file using them.
m.playerGlobals = [];
m.NewAI = function NewAI(settings) {
API3.BaseAI.call(this, settings);
this.turn = 0; this.playedTurn = 0;
this.Config = new m.Config();
this.Config.updateDifficulty(settings.difficulty);
this.Config.personality = settings.personality;
this.firstTime = true; this.savedEvents = {};
this.defcon = 5;
this.defconChangeTime = -10000000;
};
m.NewAI.prototype = new API3.BaseAI();
//your code must be placed here
//return the module object
return m;
}());