So I'm making a "game" where there is a ssuuppeerr simple RTS game, and you write an AI to play it for you. And challenge other people's AIs and such.
Now I have a super simple little RTS game up and running. And I'm taking a crack at how to write an AI against it. And one area I'm seeing a lot of question marks in, is how to structure the units (game objects) them selves in order to provide lots of useful information to AIs.
My current idea is to have two "event" queues:
1) Current
2) Previous
Each tick of the simulation, each unit will clear it's "Previous" queue, and then move it's "Current" queue into the previous queue. Then it will go on processing like normal, and what ever it is doing that tick (moving, attacking, harvesting resources, ect) will be added to the "Current" queue.
Then when the AIs get a chance to process for that tick, they can examine the queues of each Unit and see what they are doing, and what they were doing.
Is this a sane way of doing things? How do other games handle this?
Lastly, I have another issue to think about. I'm doing this in Javascript, so there really is no public/private in the traditional sense. So I don't want to give the AIs direct access to the Units, because they would have access to things like setPosition() which would allow for teleporting (aka cheating
). So how do other games get around this? Do they usually just not care b/c AIs are generally trusted pieces of code?
The only thought I've had so far about this is to provide a Proxy object that the AI gets access to and only has "safe" methods which it proxies on through to the actual game object. But this is kinda clunky... requires an extra class for every Game Object.
Thanks in advance for the help 
If you want to prevent the created AI from accessing all the data, then you make the program operate as a server-client pair where the client only gets the information
that the server sends it. If a unit moves and that player is supposed to see it move then that info would be sent to the client (and everything they shouldnt see is never sent).
Normally the visual output comes from that info and is displayed to a player and then the player issues commands as input that then goes back to the 'server' where the bookkeeping
of the game mechanics takes place.
The local scripted AI would run in the client and would have no way to access the servers info -- only the data the server sends to the client.
The server would filter the information available to each client by certain limitations (area or view blockage or fog of unexplored areas etc..) and everything else going on in the game
never gets sent. The basic info would then have to be analyzed/interpretted by the AI according to game mechanics to figure out what is going on and then to make the appropriate decisions as
to what commands to send. This is where most of the difficulty is (and the processing load) as you have to analyze everything that happens whether its significant or not
and decide which information IS significant and then assess the situation (which may include remembering past turns data/ information to spot progressive patterns and project the future).
Priorities are determined for different goals which are evaluated as to which are possible and likely to be achieved in near time and oppotunities exploited when something beneficial can be done immediately. Some solutions take a length of time to achieve (sequences of actions) and if they are interupted they can never get done so decisions must be based on the payoff against the cost of the actions to be taken.
If your simulation is 'super' simple you can use limitations of basic range (box area of a certain size) as to factors to consider (ie like picking possible targets) and decide which one is best (do you even have a view block mechanism for terrain features...) Nearest things go high in priority (sort by range) an the best will be chosen. If there are multiple unit factors that have to be considered
in state decisions (like preserving health/damage vs offensive actions to nullify enemies vs getting buffs, etc..) then you have to build functions that escalate priority the worse/more needy each factor gets which will adjust the importance of the different tactics/action goals.
If units cordinate between themselve (the AI is to issue orders to multiple unit to coordinate game actions and achieve goals) then the complexity increases a magnitude.
--------------------------------------------[size="1"]Ratings are Opinion, not Fact