Specific Bug Reports

jdog, I just want to make you aware there is still a bug in the governor (or room for A LOT of improvement) when sliders are maxed out. You'll remember the one I posted a while ago where I maxed out the culture slider and it picked very very suboptimal tiles...

Now I'm sending the esp splider to 100%, and it picks suboptimal tiles. I actually make more esp points in this city if I put it back to 90%, something which should not happen at all.

Last time the only difference was a coast tile and ocean tile. This time it's the difference between working a 1:commerce: cottage and 2:commerce: cottage vs. a 4:commerce: village and 3:commerce: hamlet.

Is there any chance you can fix the bug here?

I think last time DanF or you found what the problem was...

This bug really concerns me because it forces me to micromanage the slider, unless I want to micro manage every city.
Spoiler :
 
Hmmm ... very odd. The asserts from your first post will go away if you use the new 0.60 release (it's revision N), not sure what's causing the freeze in the second post. I'll see if I can reproduce them and figure out what's going on.

I will try the that version then! The only thing changed is the dll right? Save co patible then I guess hehe.

And "Planet Generation" is a map script from BTS(version 3.17 only I believe) that I access by using custom games too.


Thanks for looking into it!
 
I found what I think is a bug while going over the changes in the Unofficial Patch 0.21, and the comment claims the code is from BetterAI, so here goes. My apologies if this has been fixed in the latest BAI version (it's very late and I don't want to forget to post this after getting a chance to verify it).

CvTeamAI::attackAirMove() has a check designed to make bombers with less than 40% health heal instead of attack, but it looks incorrect. Here's the code:

Code:
// * Damaged AI attack planes may choose to continue attacking if no defending interceptors are around
if (([B]currHitPoints() / maxHitPoints() * 100[/B]) < 40)
{
	getGroup()->pushMission(MISSION_SKIP);
	return;
}

The problem is that both currHitPoints() and maxHitPoints() return ints, forcing the result to 0 for any unit without full hit points, and 0 * 100 = 0 is always < 40, so it will wait until fully healed.

The fix is to multiply by 100 before dividing:

Code:
if (([B]100 * currHitPoints() / maxHitPoints()[/B]) < 40)

This assumes that currHitPoints() returns a number in [0, maxHitPoints()] for [Dead, Full Health].
 
jdog, I just want to make you aware there is still a bug in the governor (or room for A LOT of improvement) when sliders are maxed out. You'll remember the one I posted a while ago where I maxed out the culture slider and it picked very very suboptimal tiles...

Now I'm sending the esp splider to 100%, and it picks suboptimal tiles. I actually make more esp points in this city if I put it back to 90%, something which should not happen at all.

Last time the only difference was a coast tile and ocean tile. This time it's the difference between working a 1:commerce: cottage and 2:commerce: cottage vs. a 4:commerce: village and 3:commerce: hamlet.

Is there any chance you can fix the bug here?

I think last time DanF or you found what the problem was...

This bug really concerns me because it forces me to micromanage the slider, unless I want to micro manage every city.
Spoiler :

Haven't forgotten ...

There's a map script called Planet Generator, maybe that's it.

Okay, I'll check that out.

I found what I think is a bug while going over the changes in the Unofficial Patch 0.21, and the comment claims the code is from BetterAI, so here goes. My apologies if this has been fixed in the latest BAI version (it's very late and I don't want to forget to post this after getting a chance to verify it).

CvTeamAI::attackAirMove() has a check designed to make bombers with less than 40% health heal instead of attack, but it looks incorrect. Here's the code:

Code:
// * Damaged AI attack planes may choose to continue attacking if no defending interceptors are around
if (([B]currHitPoints() / maxHitPoints() * 100[/B]) < 40)
{
	getGroup()->pushMission(MISSION_SKIP);
	return;
}

The problem is that both currHitPoints() and maxHitPoints() return ints, forcing the result to 0 for any unit without full hit points, and 0 * 100 = 0 is always < 40, so it will wait until fully healed.

The fix is to multiply by 100 before dividing:

Code:
if (([B]100 * currHitPoints() / maxHitPoints()[/B]) < 40)

This assumes that currHitPoints() returns a number in [0, maxHitPoints()] for [Dead, Full Health].

Yeah, I've fixed that ... thanks for checking though!
 
Haven't forgotten ...

Thanks jdog. In that case consider my post nothing more than a nag, or at best, another example demonstrating the issue. 100% :culture: and 100% :espionage: create problems, but not 100%:gold: or 100%:science: obviously.

My apologies :)
 
Hi

I saw the AI get a great general during peace time
If you load the save and just end the turn, Pericles will get a general in Athens. He's at peace with everyone and far from getting fascism.


The second save shows some strange combat behaviour. Hatshepsut attacked the stack heading east from Pi-Ramesses with the infantry that's standing 1 tile south of it.
I have an infantry in my stack with C1 & 2, and pinch, and drill. That's the infantry that should have been defending. She has only C1 and pinch.
But, if you look at the combat log, you see that she had 62% odds, and was fighting a C1/pinch infantry that wasn't even at full health.

I have an autosave from the turn before the battle, but couldn't reproduce my moves that led to her attacking. But when I initially noticed it, I reloaded once or twice, and the same attack happened.

I'm using the latest version of the mod for bts.
 
1st answer is probably that he won a combat involving a privateer. These contribute to GG points and this gaining of GG during peace would be more common in Better AI since the AI now builds privateers.

As for the second bug, that is unlikely to be caused by Better AI mod. Without a save before the battle I can't confirm it's a bug.

The enemy infantry has C1 and pinch. That is right. However your defender probably had a number of first strikes (drill promotions). These don't apepar to show up in the combat log. Are you certain the C2 pinch unit you had was full health when the enemy attacked? Without the gamesave we can't know for sure.

As far as I can tell Better AI does not mess with the bestdefender code so if it is a bug it's a bug in the current rules.
 
about number 1, you're right, Pericles did have a privateer. I've never seen an AI get a general during peace time before playing Better AI, and have only used privateers once myself, so that didn't even cross my mind.


#2 remains a mystery to me though
I have a save now, where I moved some troops around, and managed to get Hatty to attack me with that infantry once you end the turn.
The 4th infantry in my stack is C1+2+pinch, and at full health.
Yet I still lose at unfavourable odds to an inferior infatry.

I don't have much experience with bug reports, do you think it will do any good if I post this in the general forum? what with it being a modded game and all...




and on a sidenote, if you get around to loading the save, check the north-east part of my empire, there are two tiles being blockaded by a ship that's not there
they were blockaded as long as I can remember, I even built a trireme there, but couldn't find anything
then I thought it might be a barb galley in the lake to the south, and forgot about it
now that I control that lake, I see that there isn't one
bug?
 
I haven't loaded the save file, but a question: whose cultural terrain is the stack on? Was it yours or hatty's?
 
As I suspected, the unit defending has a number of first strikes. The unit that actually defends is a D4 C1 Pinch infantry with 77HP.

This is a perfect example of the bestdefender code behaving strangely when it comes to first strikes. It is definitely not a bug in Better AI.

The basic problem here is the bestdefender code does not pick the defender with the highest odds vs. the attacker. It instead tries to find an approximation to the best defender by taking shortcuts. It's because of weird lines like this in the code:

Code:
iTheirDefense *= ((((pDefender->firstStrikes() * 2) + pDefender->chanceFirstStrikes()) * ((GC.getDefineINT("COMBAT_DAMAGE") * 2) / 5)) + 100);
			iTheirDefense /= 100;
which I cannot understand how they decided on.

Here is a world-buildered example showing that your situation was to be expected according to the way the bestdefender code works. The injured Drill IV unit is picked as the best defender even though his odds are significantly worse than the odds for the C2 Pinch unit on the same tile.

 

Attachments

  • bestdefenderweird.JPG
    bestdefenderweird.JPG
    222.7 KB · Views: 809
thanks for taking another look at it

do you think it'll do any good if I post a WB example in the general bug forum?
the discrepancy is pretty significant

is it correct that what the code does is approximate the effect of first strikes by converting them into a percent bonus?
and I'm guessing that the value of first strikes is overestimated, but that overestimation only really has an effect if there's enough first strikes to raise the percentage by more than what other promotions give (45 + whatever is needed to balance the 77hp in this case)

this makes using drill IV a bit less viable (though I can't figure out which situations will most commonly lead to this error), which is a shame
 
A breakdown of what is going on:
Code:
iTheirDefense *= 
(
	(
		(
			(
				pDefender->firstStrikes()
				*
				2
			)
			+
			pDefender->chanceFirstStrikes()
		)
		*
		(
			(
				GC.getDefineINT("COMBAT_DAMAGE")
				*
				2
			)
			/
			5
		)
	)
	+
	100
);
iTheirDefense /= 100;

Another pass:
Code:
int iTwiceAverageFirstStrikes = (pDefender->firstStrikes() * 2) + pDefender->chanceFirstStrikes();
int iTwiceGlobalAverageCombatDamage = 2 * GC.getDefineINT("COMBAT_DAMAGE");
iTheirDefense *= 
(
	(
		(
			iTwiceAverageFirstStrikes
		)
		*
		(
			(
				iTwiceGlobalAverageCombatDamage
			)
			/
			5
		)
	)
	+
	100
);
iTheirDefense /= 100;

So that is 4/5 * # of first strikes * average (even on even) combat damage%

Let's use a simpler model than the full combat simulation/odds solution engine. For reasons I'll get into later, this is not the place to do a full combat engine solution. But we can improve the approximation by poking at it.

"Assume your unit is immortal. How much damage would you take in order to reduce your target's HP to 0, on average".

This is easier to calculate than your victory chance (which is important), and is a pretty decent proxy of power.

Then if you reduce your enemy HP by X% "during the fight", you drop the damage you take to kill them by X%.

If the enemy is at X% HP, you both kill faster, and they do less damage. The damage output ratio scales with (100%+X%)/2, and you only need to do X% as much damage to kill them.

If you multiply your power by X%, you divide the damage you will take by X%^2.

If you add one first strike, you will do (against an even opponent) (CombatDamage)/2 damage on average during the first strike period. If you add one first strike chance, you will do (CombatDamage)/4 average during the first strike period.

If you are at X% HP, you multiply the damage you will take by 200%/(100%+X%).

If we then take the "average damage it would take an immortal unit like you" to kill a target, then divide by your current HP, we would get a fast to calculate, decent proxy for "how well you'd defend against the target".

And this has to be fast, because when you decide which attacker to use in a stack, you iterate over each member of the stack, and get the best defender. So for two 50 element stacks, you are calculating the "defense against this attacker" value 2500 times ... on the first attack. You can see how this could bog things down if we aren't quick about it.

This will still under-value high-quality units somewhat, but it will under value them less than the current model.
 
I've found an AI Autoplay bug: After being killed under AI Autoplay, you can switch to another civilization, but you cannot 'end turn'. Therefore you cannot play anymore after beeing killed under AI Autoplay.
 
I've found an AI Autoplay bug: After being killed under AI Autoplay, you can switch to another civilization, but you cannot 'end turn'. Therefore you cannot play anymore after beeing killed under AI Autoplay.

Something like that happened to me once. I wasn't sure why the game kept going on, yet I couldn't play.
 
I used the map perfect world and there are 16? civs in play.

I put graphics on low settings but still it keeps crashing during this AI turn!! I'm pretty sure I'm getting my arse kicked anyway by the world's biggest backstab ever! (I was at war with Ragnar then suddenly 10 civs declared war on me including my best buddies!!!). AI picking on a human player!
 

Attachments

  • Bad Playa AD-1790.CivBeyondSwordSave
    1.3 MB · Views: 94
Since the new version ive re encountered the bug where, after ending your turn, the game sits on 'waiting for other civilisations to end their turns' and never finishes the turn. Anyone else seen this?

Ill try and reload from earlier (I really want to play this game) but are there any other things i can do?
Ill try and post a save later.
 
@Bad Player & Top Dog
Are either of you using a modded version, I mean are there any other mods in your game other then better AI? Is this the latest SVN, or is it the last official release, 0.6n?

Would be surprising if you'd found a critical bug in better AI 0.6n, hasn't been one found in months (at least not from the official versions, I don't know about the SVNs). Definatly post a save game where this occurs, I'm sure Jdog would want to run it through the debugger if there are no other mods in effect and you have an instance of a reproduceable hang (SNV or latest version).
 
Top Bottom