How does AITestMode work?
- Is construction made in test mode persistent, i.e. if I build a station on the same spot twice, will the seond attempt give an error (I assume it works like this, but I'm just checking to be certain)
- If its persistent, does that only last until the AITestMode instance is destroyed or doe it persist into every subsequent AITestMode (i.e. is there only one test mode that you switch back and forth from)?
- How is the test mode represented? Is it like a secondary map array or perhaps a diff against the map array?
- Would it be even slightly possible to have multiple instances of AITestMode, each with different changes?
At present, my AI checks to see if any proposed construction (e.g. the next road tile) is valid before building, as I'm sure everyone else's does. The problem is that it can only check against the CURRENT state of the map and not against the map how it WILL BE when all the construction up to that point has been done.
For instance the AI might build a tunnel, then loop around and try to build another tunnel that crosses it. I know this is a very bad example and I wouldn't actually make it do this, but its just to illustrate a point. The first tunnel will be built fine, but since it wont actually build it until AFTER the whole path has been planned then when the AI check to see if the second tunnel is valid it will succeed, though when it tries to build it it will fail.
The problem is that the path-finder has no awareness of the construction that it is GOING to do. This isn't such a problem if its only building roads but what about if the pathfinder attempts terraforming? Terraforming affects more than tile, and so could affect part of a path that we have already found and perhaps parts of the path that we haven't reached yet. In order to avoid this problem the AI would need some way of keeping track of all the terraforming and construction it plans to do.
I thought of three ways of doing this...
- Do all terraforming at any proposed node live in the real world
- Would waste money and turn half the map brown!
- Accumulate all the planned terraforming in each path node (an array?) and then each time and then perform it all in AITestMode for every node
- Doesn't affect the real world until we need to, but wastes time and would slow down path-finding tremendously
- Keep a persistent instance of AITestMode for each open node and accumulate all terraforming in that, branching from that instance to create new nodes
- Faster as theres no need to keep re-doing the same terraforming over and over, but would use lots of memory and might not be possible!!
Thanks