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

[BTS] Development thread

Discussion in 'Civ4 - Better AI' started by jdog5000, Sep 19, 2008.

  1. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    HAAA... haha... ha. Dood, there's no, freaking, way he'll stop with this version. Unlike all other parts of a game, AI is an area where potential improvements are virtually limitless.

    Also, if he didn't absolutely love working on this project, he'd have made a much-less-substantial 0.90 release long before now and then given the excuse of wanting to just wait for Civ5 at this point. The fact that that hasn't happened pretty much guarantees continued updates through at least Civ5's release date.

    p.s. -- JDog, feel free to correct me if I'm wrong (though I rarely am :p).
     
  2. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    No, the 1.0 designator means that it's (finally) got the most important changes I've been wanting to get in done well: combat logic and victory strategy. There are still a lot of other parts which could be improved that I've been thinking about ...

    However, this might be the last major update because the next several months will be a little crazy for me, and then Civ5 will come out. So I might not have time for rewriting the tech selection system, we shall see, but I certainly intend to polish up the victory strategy AI and then play a few games myself!

    From what I've read and seen, Civ5 should be pretty awesome ... I am looking forward to seeing how it works when it does arrive.

    Hmm, thanks. I'll see what I can figure out.
     
  3. Maniac

    Maniac Apolyton Sage

    Joined:
    Nov 27, 2004
    Messages:
    5,588
    Location:
    Gent, Belgium
    Cool. :D

    Yeah I certainly agree. The combat system will be different (but IMO better) though, which means probably few of your combat code will translate to Civ5. :( I was kinda hoping Firaxis had recruited you to write some combat AI for Civ5.
     
  4. Yakk

    Yakk Cheftan

    Joined:
    Mar 6, 2006
    Messages:
    1,288
    Probably a times zero or rounding error, where it values non-production too low to actually show up as being of any value at all?
     
  5. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    I believe it has been reported frequently that these prioritize buttons don't work as well as many people wished they would but there's a really simple solution to it: don't use them. Same goes for worker automation.
    The problem here is, as Yakk suggests, that anything that isn't production simply doesn't count (at all, or at least not much). That's the result of pushing that button.

    I'll believe that when I see it, no sooner. And it's rather doubtful we'll have as much freedom to mod (the AI) as we have in Civ4 right now.


    Code:
    	<Define>
    		[COLOR="Green"]<!-- Better BTS AI: Changes behavior of defensive pacts (Def: 0) :
    			0 : Default BTS
    			[B]1 : Defensive pacts do not cancel when a player has war declared on them[/B]
    			2 : Turns defensive pacts into alliances, so they are now also offensive pacts.  Plus pacts
    				do not cancel when war is declared.  Does not change name/description in game.
    		 -->[/COLOR]
    		<DefineName>BBAI_DEFENSIVE_PACT_BEHAVIOR</DefineName>
    		<iDefineIntVal>0</iDefineIntVal>
    	</Define>
    Did you actually test 1? I did yesterday, and it seems to behave like 0. Which was not exactly unexpected since you didn't completely rewrite whole chunks of the DoW function, which might be necessary.

    X has DP with Y, A declares war on X: A's DoW on X removes any DPs A might have (A = aggressor), and triggers all DPs X has: Y declares war on A because of DP - Y's DoW (Y = aggressor) removes any DPs Y has (which would be the DP with X). In the end, A loses all DPs, and all of X's DP partners lose all DPs, which includes, but is not necessarily limited to, all DPs of X. (If Y had a DP with Z then Y would lose that too even if Z had no connection to X or A.)
    I think your change in the code only removed the part where X would actively cancel DPs, which looks redundant to me since all of X's DP partners declare war and thus cancel any DPs on their own.

    At least I think that's how it works :crazyeye:
     
  6. Pfeffersack

    Pfeffersack Deity

    Joined:
    May 10, 2003
    Messages:
    2,351
    Location:
    Germany
    Have you tried to press both the production and commerce emphasize button as well? Sometimes combination is the key and here the logic might be that assigning an Engineer might lead to GE later - which can help to speed up a wonders. The co-emphasize on Commerce perhaps makes the governor value the addiotional commerce from the priest more.
     
  7. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    I don't think there is any such logic.

    I would avoid emphasizing commerce in a production city.
     
  8. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    Try it. I believe I once read something about a very similar problem where the only way to make the city work the right tiles was to have all prioritize buttons pressed. Maybe that works here too :p
     
  9. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    I would rather just force the priest if the buttons can't work properly.
     
  10. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    The production value of a settled Great Priest with Angkor Wat is exactly the same as the production value of a settled Great Engineer (3). So in this example, you're telling the AI to focus on production, and in that matter, both options are of equal value. You can't expect the AI to read your mind and know that you would prefer a Priest instead of an Engineer. But the solution is simple enough, assign the Specialists yourself.
     
  11. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Ah, good catch! I hadn't yet tested that setting, it was on the list before release. I think it'll be easy to get that setting working logically.
     
  12. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    I think even a computer doesn't need to be a mind reader to understand that an Angkor Wat Priest is better than an Engineer. It's called programming.
     
  13. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Then I guess you don't understand simple math. Because 3 is not > than 3.

    You say MAXIMIZE PRODUCTION. Production is hammers. A priest with Angkor Wat is 3 hammers. An Engineer with Angkor Wat is 3 hammers. They are EXACTLY EQUAL! There side benefits (gold and research respectively), have absolutely nothing at all to do with production. Pretty simple and basic. You're expecting the AI to understand that you prefer limes to lemons when telling it to make apples. That's a pretty hefty expectation from a human, much less a computer. I prefer lemons myself, but I guess you already know that, right?
     
  14. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    Wow, all the great people on this forum...

    So you don't expect the computer to pick a workshop by a river instead of the one not next to one? (it does, by the way, must be a mind reader)
    Lets see who doesn't understand simple maths:
    Hmm, 2 hammers and 1 gold or 2 hammers and NOTHING. Hmm, I think I'll have nothing.
     
  15. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    The AI does count the little extras, just with much lower value than the production.

    I have tried to recreate this in game but have not been able to, the value placed on the priest is always a bit higher. If you have a save or a screenshot of the city screen or something maybe I can track it down.
     
  16. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    Attached a savegame (using Better BUG AI - dunno if that matters).

    Washington, Philadelphia and Addis Ababa will remove a free priest and add an engineer if prioritize production is on.
     

    Attached Files:

  17. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Alright, I figured it out ... as kind of expected, the issue was basically caused by rounding with integer math. The value the AI places on the one commerce from the priest is pretty small to begin with, and when it gets multiplied and divided a few times it can disappear.

    This has been fixed and will appear in BBAI 1.00 and then in UP 1.51 when I get around to that.

    Thanks for your persistence Caboose.
     
  18. Caboose

    Caboose Another Drill IV defender

    Joined:
    May 1, 2008
    Messages:
    302
    Location:
    Norway
    You're a genius, jdog. :thanx:
     
  19. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    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 CvGameCoreDLL.zip
     
  20. Fuyu

    Fuyu Emperor

    Joined:
    Nov 5, 2009
    Messages:
    1,225
    Location:
    Austria
    AI ships breaking blockades?
    With high enough odds, Attack_Sea ships will attack anyway but if the odds are lower, this special place is called. I am doutful if that part is really working as it should.
     

Share This Page