Report Questionable Behavior

Jdog, I've caught a minor bug in your function in "int CvPlot::calculateImprovementYieldChange(ImprovementTypes eImprovement, YieldTypes eYield, PlayerTypes ePlayer, bool bOptimal, bool bBestRoute) const".

It calculates the yield that the improvement will change on this plot. What it doesn't account for is that the minimum yield on a plot is 0. If I have a plot producing no hammers, and my improvement subtracts a hammer, your function returns -1 (causing the AI to avoid it, when it doesn't actually matter), when in reality, the improvement doesn't affect production. I suggest you return this instead:

Code:
	int iCurrYield = calculateNatureYield(eYield, ePlayer == NO_PLAYER ? NO_TEAM : GET_PLAYER(ePlayer).getTeam(), bOptimal);
	if (iCurrYield + iYield <= 0)
	{
		return -iCurrYield;
	}

	return iYield;

Which would return 0 instead of -1.
 
There is a simple assumption made here: if a buildable improvement has a negative effect, it actually has negative effect. A workshop is only allowed on flatlands which produce at least 1 food so the negative effect always matters.
Spoiler :
Allowing improvements with negative effects on plots where that effect doesn't come into play is a bit absurd, why bother adding that negative effect in the first place, so that it would only be viable on grassland? That terrain type is strong enough as it is, I think you should consider removing that negative effect from your farms.
 
There is a simple assumption made here: if a buildable improvement has a negative effect, it actually has negative effect. A workshop is only allowed on flatlands which produce at least 1 food so the negative effect always matters.
Spoiler :
Allowing improvements with negative effects on plots where that effect doesn't come into play is a bit absurd, why bother adding that negative effect in the first place, so that it would only be viable on grassland? That terrain type is strong enough as it is, I think you should consider removing that negative effect from your farms.

It has the effect of -1 production, and it can be built on grass (Where it has no effect), but removes the hammer from plains. Or did you forget plains was flatlands too. :p
 
Actually no, the opposite. I saw it will remove production from plains but leave grassland alone. The farms thus have no negative effect when built on grassland, which makes them even stronger there than they would have been anyways. If that's on purpose, as I assume it is, it's still questionable at best because one improvement has different actual effects on different terrain.
short version: plains farms are underpowered.
 
Actually no, the opposite. I saw it will remove production from plains but leave grassland alone. The farms thus have no negative effect when built on grassland, which makes them even stronger there than they would have been anyways. If that's on purpose, as I assume it is, it's still questionable at best because one improvement has different actual effects on different terrain.
short version: plains farms are underpowered.

The farm thing was simply an example... I don't actually have farms that have a negative yield. I do have a mine that has negative food though.

Whether it's practical, or balanced is irrelevant to the main point. The function's name (and intended purpose) is "calculateImprovementYieldChange", so it Calculates the change in yield the improvement will bring. Since the total yield can never go negative, this function should reflect that. I fail to see the issue with making it work correctly.
 
I found a bug, which wasnt in the game prior to v1.00

When you have heaps of siege units in a stack, more than the enemy has troops in their stack, all of them can attack even though the last few arent doing any damage or collateral to enemy troops.

Previously, once your siege units could no longer do damage, they could no longer attack an enemy stack
 
I found a bug, which wasnt in the game prior to v1.00

When you have heaps of siege units in a stack, more than the enemy has troops in their stack, all of them can attack even though the last few arent doing any damage or collateral to enemy troops.

Previously, once your siege units could no longer do damage, they could no longer attack an enemy stack

I tried recreating this with a stack of catapults but couldn't, it seems to work correctly for me and after the enemy gets below a certain health level the rest of the catapults cannot attack. Stack attack also worked fine.

Can you post a save?
 
I tried recreating this with a stack of catapults but couldn't, it seems to work correctly for me and after the enemy gets below a certain health level the rest of the catapults cannot attack. Stack attack also worked fine.

Can you post a save?

Sure, heres a save game. Theres a large stack of cannon next to Chaco Canyon ready to attack Sitting Bull

Also, all the cannon that attack, despite not actually doing any damage receive experience

For me I seem to be able to reproduce it no matter what siege unit Im using
 

Attachments

  • Mat2.CivBeyondSwordSave
    792.3 KB · Views: 76
I found the city-raze logic a bit questionable in my last game.

It was early game, Ragnar was my direct neighbour and attacked me. Captureds St.Petersburg within 2 turns, and razed it.

However, St.Petersburg was directly adjacent to Ragnars empire, in a good spot with ressources Ragnar needed, not surrounded by foreign culture, easy to defend for Ragnar (I played bad and had no army...), and Ragnar had a very small empire and no chance to expand peacefully anymore.


Basically, he attacked the right target at the right time and then refused to accept his reward :eek:

The save is from my next turn, you can see the Viking stack on the right side of Moscow, standing on top of city ruins. That was size 5 St.Petersburg.
 

Attachments

  • Razestpetersburg.CivBeyondSwordSave
    440.5 KB · Views: 63
I've never seen the AI build like this before; I attacked France early on (Prince) with Chariots and encountered an army of about 30 Warriors. France didn't get Archery until much later and he didn't have Copper or Iron.
 
Sure, heres a save game. Theres a large stack of cannon next to Chaco Canyon ready to attack Sitting Bull

Also, all the cannon that attack, despite not actually doing any damage receive experience

For me I seem to be able to reproduce it no matter what siege unit Im using

Thanks mwyeoh, I've got the bug happening now. What appears to cause the bug is the presence of a ship in the city. Some change (I think from Lead from Behind, cause it changes a lot of these functions) appears to have made the code consider the ship a possible target, at least enough so that it lets you launch an attack (but the actual attack code blocks that properly).

Will looking in to it.
 
Just want to make sure you don't miss my post:


Jdog, I have a code submission for you.

The Long Version:

I noticed the AI were poor (read: terrible) at choosing buildings that gave free promotions. When I checked out the code, I found this comment on it:

Code:
iValue += ((iHasMetCount > 0) ? 100 : 40); // XXX some sort of promotion value???

Not exactly a good sign.

The problem was that promotion values were evaluated on a unit-by-unit basis, which is fine for units, but terrible for everything else. I short-circuited CvUnitAI::AI_promotionValue(...) to a new function in CvPlayerAI, which mimics the UnitAI exactly, except that it does not require (but will accept) a CvUnit object to return a value.

With this, I created a valuation function in CvCityAI so that it properly evaluates promotions based on their effect, and how many units they can effect. I'm hoping this can be added to Better AI, mostly for selfish reasons, so that my future update merges are easier. ;)

The Short Version:

I created a new City promotion AI for you to use. ;)

Feel free to make any adjustments that you see fit.

Code:
View attachment 254512
 
mwyeoh:

Thank you for reporting that bug, I have fixed it for the next version. I also posted in the Lead from Behind thread, hopefully the fix will be included there as well.

Afforess:

Thanks, I'm not surprised that a non-vanilla feature had terrible logic underneath. Will take a look at your code an incorporate.
 
Hi everyone,
I playing a hemisperes, Warlord level, Normal speed game. I'm Korea. In 1960 AD I declare war to Darius (Persian) on my same continent. Immediately I send a transport with 4 tanks for destroy his unique oil well and than park the tanks over the oil tile. Than I attack his cities.
Darius in 15 turns don't try to regain oil except when he send a single anti tank intantry unit which is wiped out by one of the 4 tanks:eek::eek:.
Without oil Darius cannot combat well against my attack force: tanks, artillery, infantry, figthers, destroyer and battleship. He go in "survival mode" -> no counter attack and wait in his cities my attack troops.

I think that in modern wars AI must protect better Oil (and also Aluminum and Uranium). For example: if an AI pillage my unique Oil well with 4 tanks I will send minimum 6 anti tank infantry and also suicides troops in order to regain Oil...

Infact no Oil no modern units.....

Also AI should apply the same schema when attacking another player: cutting off enemy's strategic resources.

I post 2 zip files:
1) auto save from 1960 AD to 1967 AD
2) BBAI 1.00 + BUG 4.4 (absolutely I made no changes at the mods)

I know that programming AI is not easy but I hope that people like Jdog, Afforess, Fuyu, LunarMongoose can solve this problem.

Thanks in advance for replies. If is necessary to post other autosave tell me.

PS: BBAI is great!!!!!! :goodjob::goodjob:
 

Attachments

  • Save one per turn.zip
    3.4 MB · Views: 72
  • BUG4.4 BBAI1.00e.zip
    4.4 MB · Views: 80
Thanks in advance for replies. If is necessary to post other autosave tell me.

Saves aren't necessary for this I would think, since the behavior you describe is obvious and not a rare bug or something.

I realize oil is the single most important one of them all, but iron and horses and anything else can have the same tide-turning effect in many cases. Assuming there is already code present to make AIs defend their resources in any way shape or form, it should be pretty easy to increase the priority for unique strategics.

Making AIs target key enemy strategics as part of a war strategy is an entirely different animal (probably a llama) however. I seem to vaguely recall JDog mentioning this in his text files at one point a while back, and it may already be in the code for all I know, but if it's not this is a non-trivial thing to add.

But there was a bug just reported in the version 1.0 thread about AIs being unwilling to capture empty cities which I'm going to have to fix if JDog doesn't get back again soon, so I guess I can take a look at the strategic resource stuff too.
 
Thanks for the reply. Waiting Jdog for more info.
I think that will be wondeful if next BBAI will manage a strategy for pillage strategic resources.
 
A good point Axios ... the AI definitely doesn't understand and act on the importance of oil and other strategic resources well enough, defensively or offensively.

To improve this we'd need a three staged approach:

1. Resource defense: The AI should defend its important strategic resources very heavily. I remember noting that it treated most resources the same, but I may have fixed that a while ago. This is the easiest part to improve as it just requires tweaking existing logic.

2. Recapture pillaged resource tiles: I don't believe the AI ever worries about this explicitly ... right now it's a tactic only a human player uses, and the AI has no counter strategy. The AI will build defensive stacks that will counter attack enemy stacks in its territory, but they don't consider resources when making decisions.

3. Resource offense: The AI will take out resources which are unguarded, but it doesn't yet consider attacking guarded resources as far as I remember, and certainly doesn't then stick around to deprive their opponent longer. This behavior would be possible to add to attack city stacks who are not strong enough to take a city alone, could probably also get some attempt at denial also by splitting off a few units who can defend.

I'll keep thinking about the right way to implement this ... any other ideas or comments?
 
Top Bottom