Original Post
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
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