The AI is a sub-section of the network synchronised gameplay simulation. The game provides a proxy representation of the state of the simulation. Direct access to the rest of the simulation is not allowed so that theAI can be safely made asynchronous. The proxy representation is a set of javascript objects, with one for every entity in the game, with appropriate properties. Diff's are sent each AI turn to keep the list up to date. This is done with the combination of AIInterface and AIProxy (simulation/components). The AI has the function HandleMessage(state) called each turn. state is an object with quite a few properties, see the function in base.js for more details. The thing which gives you all of the entity information is state.entities which is an object of the form {5: {id: 5, owner:1, ...} , 7:{...},...}. So state.entities[id] is an object containing all of he changes to an entity in the last turn. When an object is created then state.entities[id] will contains all of the properties for that object. The common-api applies the diffs each turn to keep all of the entities up to date for the AI. The AI performs actions by calling an interface called Engine.PostCommand() which sends a message to simulation/helpers/commands.js which runs the command. There are a few other Engine commands, which should be self explanatory (run a search on the AI folder to find them all). They are defined somewhere in the C++ (I can't remember exactly).