1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

useless AI in svn version

Discussion in 'Bugs and Crashes' started by rashaverak, Oct 5, 2014.

  1. MacCoise

    MacCoise Prince

    Joined:
    Oct 14, 2011
    Messages:
    431
    Here you go
     

    Attached Files:

  2. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    I was bored from working on the new Schema-Validation so i gave this another try.

    ContractFloatingDefenders has the highest priority(CITY_BUILD_PRIORITY_CEILING) when looking for Units, Settlers requesting a Unit as escort only HIGH_PRIORITY_ESCORT_PRIORITY.

    If a Unit is build because of a Settlers request it's possible that the CityDefence get's that Unit and the Settler waits. Also the AI seems to scrap Settlers if they have nothing to do after a while so this could be a huge possible problem.

    I do some more testing but i think i simply give settlers CITY_BUILD_PRIORITY_CEILING then looking for a escort.
     
  3. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,465
    Gender:
    Male
    Location:
    MN
    Sounds like a plan. And btw thx for all the hard work you are doing and helping in:goodjob:
     
  4. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,253
    Gender:
    Male
    Location:
    Las Vegas
  5. MacCoise

    MacCoise Prince

    Joined:
    Oct 14, 2011
    Messages:
    431
    I find it strange that the AI seems unable to take out barbrain cities which might stop expansion too
     
  6. T C

    T C Prince

    Joined:
    Dec 3, 2011
    Messages:
    332
    In my latest game the AI has manged to capture some barbarian cities, but seems to have stopped now. It also seems that civs that form from barbarian cities are better at taking barbarian cities than civs which are there from the start.

    I think the biggest problem is the maintainence difference between chiefdom and anarchy. Most AIs are stuck on 3 cities in my game, one has 4, I have 5.
     
  7. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    Ok giving those Settler requests for a escort that high priority has an effect. But i'am not happy with the result because in some cases it leads to even more CityDefenders.

    The next thing i try is adding a new UnitAI type for those Settler escorts.
     
  8. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,253
    Gender:
    Male
    Location:
    Las Vegas
    While that's really not a bad idea, (very good idea actually) why is it a bad thing that they're finally getting more city defenders? This was one of their major weaknesses too that they wouldn't get enough of them wasn't it?

    What I've seen in regards to 'too many' city defenders is actually 'too much' law enforcement. They seem to really like law enforcement units as city defenders and to me they make horrible city defenders - while they help in that regard they should be built for their purpose and city defense should be selecting only that which is militarily most effective.

    Furthermore, it needs to have multiple city defender types. If they don't stock some axes and spears along with their archers, for example, they're missing out on some strong opportunities to bolster their defense and leaving themselves open to forces heavily specialized in taking down archery units. So far as I've seen it goes for the 'best' in an evaluation process and that 'best' is always the same for whatever tech level they are at, with no consideration for what's already a part of the defensive stack plan.

    Still... you're hitting on the concept I've been mulling over for quite some time now, which is to have a lot more AI defines to help the AI build for a LOT more depth of purpose and strategy. (And since you're breaking ground here I will have some questions for you as to how we can get some elements of that up and running once I turn to this project - which I hope will dominate the next development cycle for me.)

    Also... very cool that you're change had an impact. Makes me now wonder if there are some mysteries (and possibly other minor bugs) to be worked out regarding the brokerage system in general...
     
  9. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    I don't mean law enforcement because such units aren't possible in the early ancient era. Did you also count the Units with UNITAI_CITY_DEFENSE the AI put's on plots around the city?

    I havent done much gaming myself in the last weeks so i might be wrong about too much CityDefenders. Maybe i just put this change in the svn and wait how it turns out.



    EDIT:

    Here is a example what i call too much, these are the unit counts of a random player from a recent autoplay session.
     
  10. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    Thanks to 45°38'N-13°47'E for finding the change causing this issue:goodjob:


    @thunderbrd
    It is caused by a change you made in CvUnitAI::AI_update and the 'else if' added by myself.

    Code:
    	//Safely escape the Occasional an inf loop here.
    
    	if (m_iLastUnitUpdated != m_iID)
    	{
    		m_iLastUnitUpdated = m_iID;
    		m_iSameUnitUpdateCount = 0;
    	}
    	else if (m_iSameUnitUpdateCount > 0 && 
    		((m_contractualState == CONTRACTUAL_STATE_AWAITING_ANSWER || m_contractualState == CONTRACTUAL_STATE_AWAITING_WORK) || 
    		(m_contractualState == CONTRACTUAL_STATE_NONE && getGroup()->getMissionType(0) == -1)))
    	{
    		m_iSameUnitUpdateCount = 0;
    		getGroup()->pushMission(MISSION_SKIP);
    		return false;
    	}
    	else
    	{
    		m_iSameUnitUpdateCount++;
    		if (m_iSameUnitUpdateCount > 99)
    		{
    			FAssertMsg(m_iSameUnitUpdateCount <= 99, "A Unit has hit an infinite loop in its AI and triggered a loop escape");
    			m_iSameUnitUpdateCount = 0;
    			getGroup()->pushMission(MISSION_SKIP);
    			return false;
    		}
    	}
    I don't remember why we added this but it has to go.
     
  11. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,253
    Gender:
    Male
    Location:
    Las Vegas
    Actually that example looks about right though it's odd that spearmen aren't being built as part of that group.

    Yeah, I'm NOT happy with how the AI sends city defense units to hang out outside its cities. If we want local regional defenders that will take terrain defensive roles outside the city then they should be their own AI role, not City Defense! This is currently one of the big weaknesses of the AI I think.

    I hope we CAN get rid of it safely. It was a temporary solution, an escape to a huge problem with infinitely looping unit AIs that I found myself incapable of finding the root of the problem at the time. It's entirely possible the original problem was solved since then - or perhaps we'll end up finding it again as a result of getting rid of this and be able to tackle it more properly this time.
     
  12. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    It was changed to be this way and if they move into the city in case of real danger i don't see a problem. I think we could change it so the AI leaves a bit more units in cities and give settlers a stronger escort to have a stronger defense in new cities.


    We can get rid of it safely because it breaks the game so not having it can't be any worse. If there is another case of infinitely looping there has to be another way to fix it.
     
  13. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,253
    Gender:
    Male
    Location:
    Las Vegas
    The problem stems from the units that should be defending cities not getting the benefit of nearly enough of their potential fortification bonus. They move in as soon as they know they need to and if you're fast enough it's too late, particularly later in the game when you're moving in with Commando units. At that stage they don't even have warning enough to know they need to move into the city before you've stolen it out from under them.




    Yeah... I'll admit it was a problem that was over my head so I could do little but put this bandaid on it... I'm baffled by how it creates a problem but I've been finding the brokerage system a bit baffling in the first place.

    I really will need a better understanding of it soon...
     
  14. MacCoise

    MacCoise Prince

    Joined:
    Oct 14, 2011
    Messages:
    431
    There is definitely some improvement in my current game (in terms of AI expansion)
     
  15. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,465
    Gender:
    Male
    Location:
    MN
    Yeah even "some" of the barbarian towns are getting better POP then before, before some were at POP 1 forever, now i have 2 just outside my area with POP 2 at least in Ancient Era.
     
  16. MacCoise

    MacCoise Prince

    Joined:
    Oct 14, 2011
    Messages:
    431
    Quick thought. Anarchism gives a a-25% maintenance for all cities plus the -90% for the first two.

    Chiefdom only gives -25% for all cities.

    In order to encourage growth should the maintennace of -25% be removed from Anarchism. So once you go beyond two cities Chiefdom becomes more and more attractive.....
     
  17. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    I change the AI code to leave at least two-thirds of their CityDefense in the city instead of the half. The Commando promotion should have a negative CityAttack i think about -20%.
     
  18. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,253
    Gender:
    Male
    Location:
    Las Vegas
    Not only do I vehemently disagree that the commando promo be nerfed (due to it already having extremely stringent requirements to reach) but it also wouldn't help. By this time, air units are able to diminish city defenses and the healths of the units within them so severely that 20% wouldn't make much of a difference (unless there were so numerous defenders all under the shelter of the bunker protection that the city offers, that the amount of damage the air units can deliver is diffused greatly among the defensive stack in the city.)

    Additionally, we're doing what we can to nerf naval fleet invasions but they still present the same issue, hitting up to 3 cities per round per fleet they catch city defenders outside the city all the time as well, making those cities fall quite easily too.

    I can see a point in having maybe 1/4 of the city defense force outside the city - spreads out bombing raid focus and may help in that regard, and keeps some refreshments capable of coming in after bombardment and collateral hits the city and wears down those stationed there. So this might be better at least somewhat. Just seems they lose a lot of power by losing that fortification bonus.
     
  19. Yudishtira

    Yudishtira Spiritual/Creative

    Joined:
    Nov 2, 2012
    Messages:
    2,460
    Location:
    Brisbane
    The Commando promo's requirements are too stringent. That might be why it is given for free to every single mounted unit starting in prehistoric... Which in turn makes a mockery of the stringent requirements does it not?...

    I say mounted units should not have to wait till Mil Sci or whatever tech to get it, but should not get it for free, and indeed have all the current promo prereqs required of them.
     
  20. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,940
    Gender:
    Male
    Location:
    Germany
    If 20% less CityAttack makes no difference then i quess that a few more city defenders might not even matter also. Cases of huge and fast stacks need alot more defense not just few more units and just having the AI build a huge number of city defenders seems wastefull.
     

Share This Page