I've just uploaded yet another bug fix... v1.04d. The bug would sometimes prevent peace deals from being made. (What was happening was that the human player was automatically refusing peace with the same decision making code that is meant for the AI. ie. The K-Mod AI is meant to refuse to make peace when it is aiming for a conquest victory; but this bug was forcing that same decision onto human players when it thinks they should be going for a conquest victory...)
But perhaps more importantly, I've just worked out one of the main causes for late-game slowdown. It turns out that a lot of the slowness is nothing to do with the inefficient code or python callbacks or anything like that. (a lot of the slowness is to do with that stuff, but a lot isn't.) I've discovered that by far the biggest cause of slowdown is that the AI is programmed to only move one group in each game time-slice.
This means that when there are lots and lots of units, lots and lots of time is spent simply waiting for actions to be carried out by AI units before the AI even considers issuing a command for its next unit.
I can change this, and the speed gain will be enormous. I've changed the code so that the AI will move all groups that have the same AI priority level at the same time. (for example, all AI spies will move at once, and then all bombers, or whatever, and so on.) I profiled some late-game turns with and without this change, and the difference is 100%!. The game runs twice as fast with this change. ie. the time between each turn is halved.
That's a pretty attractive speed gain - but I should point out that it could come with some cost to the AI's abilities. Because it is ordering a bunch of units at the same time, it is likely to get a bit confused. For example, two spies might try to sabotage the same building at the same time; or two cavalry might try to attack the same enemy unit. The spy thing isn't a big problem; because the second spy mission will simply not happen if the first succeeds, and the second spy will then get to move again before the AI finishes its turn. But the attacking thing is a problem - because sometimes it will result in a big bunch of AI units all moving to attack a single target, while other potential targets simply get ignored.
To get around this problem, I'm thinking of setting it up to move multiple units only when none of them are doing any non-movement actions. For example, if there is combat, or a spy mission, or an airship recon mission, etc., the AI will wait for the that mission to finish before giving its next command (just as it does currently). But if all the unit does is move, or just skip its turn (for example, a city defender just standing still in a city), then the AI will consider moving another unit at the same time.
This solution might still lead to some slightly degraded AI decision making (for example, the AI might decide to move two city defenders to the same destination at the same time for the same reason, when it only needs one.) - but the potential speed gains might just be too big to ignore.
What do you think?
But perhaps more importantly, I've just worked out one of the main causes for late-game slowdown. It turns out that a lot of the slowness is nothing to do with the inefficient code or python callbacks or anything like that. (a lot of the slowness is to do with that stuff, but a lot isn't.) I've discovered that by far the biggest cause of slowdown is that the AI is programmed to only move one group in each game time-slice.
This means that when there are lots and lots of units, lots and lots of time is spent simply waiting for actions to be carried out by AI units before the AI even considers issuing a command for its next unit.
I can change this, and the speed gain will be enormous. I've changed the code so that the AI will move all groups that have the same AI priority level at the same time. (for example, all AI spies will move at once, and then all bombers, or whatever, and so on.) I profiled some late-game turns with and without this change, and the difference is 100%!. The game runs twice as fast with this change. ie. the time between each turn is halved.
That's a pretty attractive speed gain - but I should point out that it could come with some cost to the AI's abilities. Because it is ordering a bunch of units at the same time, it is likely to get a bit confused. For example, two spies might try to sabotage the same building at the same time; or two cavalry might try to attack the same enemy unit. The spy thing isn't a big problem; because the second spy mission will simply not happen if the first succeeds, and the second spy will then get to move again before the AI finishes its turn. But the attacking thing is a problem - because sometimes it will result in a big bunch of AI units all moving to attack a single target, while other potential targets simply get ignored.
To get around this problem, I'm thinking of setting it up to move multiple units only when none of them are doing any non-movement actions. For example, if there is combat, or a spy mission, or an airship recon mission, etc., the AI will wait for the that mission to finish before giving its next command (just as it does currently). But if all the unit does is move, or just skip its turn (for example, a city defender just standing still in a city), then the AI will consider moving another unit at the same time.
This solution might still lead to some slightly degraded AI decision making (for example, the AI might decide to move two city defenders to the same destination at the same time for the same reason, when it only needs one.) - but the potential speed gains might just be too big to ignore.
What do you think?