AI Flexible difficulty

Ok, I've uploaded my changes if you want to try or have a look, Afforess.
There's another part of the code that I haven't uploaded but IMO it should work better than yours and here I explain why:

This is your code (for research, for example):

Code:
	//	Arkatakor
	if (!isHuman() && !isBarbarian())
	{
		//	The handicap type will be based on the average handicap of all human players
		iCost *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIResearchPercent();
	}
	else
	{
		iCost *= GC.getHandicapInfo(getHandicapType()).getResearchPercent();
	}
	
	//Afforess AI Flexible Difficulty Start
	if (GC.getGameINLINE().isModderGameOption(MODDERGAMEOPTION_AI_USE_FLEXIBLE_DIFFICULTY))
	{
		HandicapTypes eStandardDifficulty = (HandicapTypes)GC.getDefineINT("STANDARD_HANDICAP");
		iCost *= std::max(50, 100 - (GC.getHandicapInfo(getHandicapType()).getAIResearchPercent() - GC.getHandicapInfo(eStandardDifficulty).getAIResearchPercent()));
		iCost /= 100;
	}
	//Afforess AI Flexible Difficulty End

	iCost /= 100;

Let's assume there's just 1 player and use real values. What happens if you use both Flexible difficulty and Flexible AI and both human and AI are on deity (or if human player is simply playing on Deity)?

Since human is on deity, AI research gets multiplied by 0.65, which makes AI tech faster (first step). Then it gets multiplied by std::max(50, 100 - (65-80)) / 100, which is 1.15. So in general it's multiplied by 0.74 which makes AI tech faster than humans. But in Handicapinfo while playing on deity, human player is already slower than AI due to iResearchPercent, set to 125 on deity. So while human is already teching slower than AI while they're on the same deity level, AI gets another bonus and techs even faster.

This is my code, same assumption:

Code:
	//	Arkatakor
	if (!isHuman() && !isBarbarian())
	{
		//	The handicap type will be based on the average handicap of all human players
		iCost *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIResearchPercent();
	}
	else
	{
		iCost *= GC.getHandicapInfo(getHandicapType()).getResearchPercent();
	}
	iCost /= 100;	
	if (!isHuman() && GC.getGame().isModderGameOption(MODDERGAMEOPTION_AI_USE_FLEXIBLE_DIFFICULTY))
	{
		iCost *= 100;
		iCost /= GC.getHandicapInfo(getHandicapType()).getAIResearchPercent();
	}

you can clearly see that AIResearchPercent is reduced to 1 in the whole process when both AI and human player are on the same handicap level. Hence human handicap is only given by a slower ResearchPercent (125%), which is what it's meant to be from the beginning.
What do you think Afforess?
 
About Flexible AI / Flexible difficulty and multiplayer, it looks like handicap level is being reset to noble for everyone each time you reload a game; if I have time, I'll try and look where the problem is. :)
 
More about Flexible Difficulty and Multiplayer; players should agree on the frequency of handicap level check; in my current game I had my handicap checked every 10 turns, my opponents every 50 turns. It's ok if you agree on that, but probably we should put a warning on it or making it mandatory for both players to have the same frequency in handicap level check.

Code:
[40473.758] [Flexible Difficulty] (1 / 10) turns until next flexible difficulty check for Player: Co******
[40473.758] [Flexible Difficulty] [COLOR="Red"](51 / 50)[/COLOR] turns until next flexible difficulty check for Player: Ca*****
[40473.758] [Flexible Difficulty] Player: Carlos, Checking Flexible Difficulty
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Cleopatra
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Justinian I
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Suryavarman II
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Tokugawa
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Charlemagne
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Brennus
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Mansa Musa
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Augustus Caesar
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Bismarck
[40473.758] [Flexible Difficulty] (6 / 9) turns until next flexible difficulty check for Player: Pericles

Also strangely it looks like my opponent's timer for checking handicap didn't reset: it went up to 240/50 (240 being current turn)
 
Just for everyone information, we've set both Flexible Difficulty to be checked every 10 turns and now everything seems to work. Better than that, we've played 30 turns tonight in late renaissance/early industrial era and no OOS or crash.
 
Pity I missed out on this thread; I was the one who implemented the AIResearchPercent feature (by creating the XML tag and editing the C++ code accordingly to accomodate for it). Contrary to what the OP said, this feature has always been working as I use it in everyone of my games. I have a heavily configured HandicapInfo file and the AIResearchPercent reflects what I configured in it appropriately.

I do have to point out the following:

1) I switch difficulty manually in game as the automatic flexible difficulty option has issues.

2) As someone pointed out, barbarian civ's are excluded from AIResearchPercent (that should be changed so that they are not excluded).

I have not tested it in the multiplayer context though I remember following the convention of AI difficulty tag's in the same way as the others (AIGrowthPercent) for example.

Do let me know if you still feel if AIResearchPercent has issues in any way :)
 
Pity I missed out on this thread; I was the one who implemented the AIResearchPercent feature (by creating the XML tag and editing the C++ code accordingly to accomodate for it). Contrary to what the OP said, this feature has always been working as I use it in everyone of my games. I have a heavily configured HandicapInfo file and the AIResearchPercent reflects what I configured in it appropriately.

I do have to point out the following:

1) I switch difficulty manually in game as the automatic flexible difficulty option has issues.

2) As someone pointed out, barbarian civ's are excluded from AIResearchPercent (that should be changed so that they are not excluded).

I have not tested it in the multiplayer context though I remember following the convention of AI difficulty tag's in the same way as the others (AIGrowthPercent) for example.

Do let me know if you still feel if AIResearchPercent has issues in any way :)

I still have problems with Flexibile Difficulty sometimes. Last game? Heh, I had a Mastery Score of 125 and the second best civ had a score of 18. My score was twice as much as the second civ (on scoreboard) but the game was like "Nop, gonna keep you on Prince. Not going to move you up even though the max is Immortal. But we'll push that struggling second-place civ up to Monarch, he's looking like a runaway there..."
Can't remember the last time I was pushed down a difficulty either... Well, once when I was an era behind two of the AIs, but the game was quite eager to push me back up to Noble then keep me there no matter what :rolleyes:


For the AI, it seems to be working well - they go up and down in difficulty as they get more land and tech.
 
I also think there's a problem with flexible difficulty. AI is working fine but human flexible difficulty has some problems. Last game for example I have set warlord as minimum difficulty but I've gone down to chieftain. I'm not even sure parameters were being changed with difficulty change.
 
In your logs, the ANewDawn.log will log all Flexible Difficulty actions, or inactions.
 
45°38'N-13°47'E;13529504 said:
I know, I simply haven't had time to check yet. :p

I just took a look at mine, but the date is from five months ago :eek:
MyGames/Logs... Most of the stuff in here is old, can I just clear it out? (Taking up 1.33gb too eek!)
 
I just took a look at mine, but the date is from five months ago :eek:
MyGames/Logs... Most of the stuff in here is old, can I just clear it out? (Taking up 1.33gb too eek!)

Yes, you can clear it without harm. You may have disabled logging in the ini. Turn that back on.
 
I have not seen Afforess or 45 make reference to issues with AIResearchPercent following my previous post in this thread. I assume then that it is in good working order.

I still have problems with Flexibile Difficulty sometimes. Last game? Heh, I had a Mastery Score of 125 and the second best civ had a score of 18. My score was twice as much as the second civ (on scoreboard) but the game was like "Nop, gonna keep you on Prince. Not going to move you up even though the max is Immortal. But we'll push that struggling second-place civ up to Monarch, he's looking like a runaway there..."
Yeah, I use this functionality manually. I heavily configure my HandicapInfo XML file so that settler difficulty is an offshoot of monarch / immortal in the normal HandicapInfo file and start on that difficulty. If I see myself getting ahead, I set up reminders (Ctrl + Alt + R) every 50 turns to turn up the difficulty manually through the in game flexibility option. My deity has insane numbers but helps keep the game interesting longer.
 
I have not seen Afforess or 45 make reference to issues with AIResearchPercent following my previous post in this thread. I assume then that it is in good working order.

I think so, there's been just a slight modification to make it work with FlexibleAI.

Code:
	//	Arkatakor
	if (!isHuman() && !isBarbarian())
	{
		//	The handicap type will be based on the average handicap of all human players
		iCost *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIResearchPercent();
	}
	else
	{
		iCost *= GC.getHandicapInfo(getHandicapType()).getResearchPercent();
	}
	
[COLOR="Red"]	//Afforess AI Flexible Difficulty Start
	if (GC.getGameINLINE().isModderGameOption(MODDERGAMEOPTION_AI_USE_FLEXIBLE_DIFFICULTY))
	{
		HandicapTypes eStandardDifficulty = (HandicapTypes)GC.getDefineINT("STANDARD_HANDICAP");
		iCost *= std::max(50, 100 - (GC.getHandicapInfo(getHandicapType()).getAIResearchPercent() - GC.getHandicapInfo(eStandardDifficulty).getAIResearchPercent()));
		iCost /= 100;
	}
	//Afforess AI Flexible Difficulty End[/COLOR]

this is because with flexibleAI, AI also is changing handicap. If we leave the code as it was, AIResearchPercent is making the game harder for AI when it's supposed to make it easier and vice versa.
 
45°38'N-13°47'E;13537424 said:
I think so, there's been just a slight modification to make it work with FlexibleAI.

Code:
	//	Arkatakor
	if (!isHuman() && !isBarbarian())
	{
		//	The handicap type will be based on the average handicap of all human players
		iCost *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIResearchPercent();
	}
	else
	{
		iCost *= GC.getHandicapInfo(getHandicapType()).getResearchPercent();
	}
	
[COLOR="Red"]	//Afforess AI Flexible Difficulty Start
	if (GC.getGameINLINE().isModderGameOption(MODDERGAMEOPTION_AI_USE_FLEXIBLE_DIFFICULTY))
	{
		HandicapTypes eStandardDifficulty = (HandicapTypes)GC.getDefineINT("STANDARD_HANDICAP");
		iCost *= std::max(50, 100 - (GC.getHandicapInfo(getHandicapType()).getAIResearchPercent() - GC.getHandicapInfo(eStandardDifficulty).getAIResearchPercent()));
		iCost /= 100;
	}
	//Afforess AI Flexible Difficulty End[/COLOR]

this is because with flexibleAI, AI also is changing handicap. If we leave the code as it was, AIResearchPercent is making the game harder for AI when it's supposed to make it easier and vice versa.
Thanks for your feedback. I used flexibile difficulty manually so maybe AIResearchPercent only worked properly then. Its been a while since I wrote this so your fix sounds good. Also I would like to take this opportunity to suggest the removal of the && !isBarbarian() from the if (!isHuman() && !isBarbarian()) statement so that barbarians are also included in when AIResearchPercent gets modified.
 
Top Bottom