Announcement

Collapse
No announcement yet.

Exciting AI improvements.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #46
    Originally posted by ben04
    In XML technology files there's a proprety iAIWeight. What is that for? I played a bit around with it and though that the AI would prioritize techs with a high modifier. The AI seemed to pretty much ignore it.
    It's probably a matter of magnitude. From the SDK it seems that:
    100 would be the minimum which might be noticable.
    400 would make it simialler to a tech an AI likes (like economic AI's liking Banking).
    1000 would be enough to make it very attractive.
    3000 would lead to it being chosen in preference to founding religions and stuff.

    Also I've found that the AI build much too much units and not enough buildings.
    Indeed...
    I've started working on that bit of the code. Part of the problem is the AI has no sense of priority, the buildings it build might be crap ones.

    I'd love to help if I could only get that darn SDK to compile.

    Also that AI code really looks bad. Functions that have about 1300 lines and not a single line of comment. No wonder that that code is buggy.
    Have you tried the instructions in the creation forum for compiling it with Code::Blocks and the free VC compiler?

    I don't find the AI code to be bad... I mean the code style is good and it's ultra readable despite lack of comments (the function names are generally descriptive), the code just isn't very well tuned for CIV4...

    Comment


    • #47

      Also I've found that the AI build much too much units and not enough buildings.


      Indeed...
      I've started working on that bit of the code. Part of the problem is the AI has no sense of priority, the buildings it build might be crap ones.


      i don't quite agree here. the AI usually has too few units. or should i at least say too few strong units.

      i see it too often that the AI may have 8 units protecting each of its cities. but when you start invading, hardly any of them move in as reinforcement.

      the choice is also often bad. while they now build trebuchets and more catapults, they don't use it properly. cats have city attack promotions when they are used in defence. and even if my stack moves up on a city with 3 siege units they seldom use more than one of those to weaken the stack.

      also, the AI always promotes the units immediately instead of a) waiting to see what's needed or b) recover from a battle quicker by halving the wounds.

      last, honeypots: scouts and workers put undefended at your border will nearly always be captured/killed. if it's a lone cavalry it's much easier to deal with then, than when deep in enemy territory...

      so i don't think there should be less units built, but the use/upgrade/promotion of the units should be improved...
      - Artificial Intelligence usually beats real stupidity
      - Atheism is a nonprophet organization.

      Comment


      • #48
        Originally posted by Blake

        It's probably a matter of magnitude. From the SDK it seems that:
        100 would be the minimum which might be noticable.
        400 would make it simialler to a tech an AI likes (like economic AI's liking Banking).
        1000 would be enough to make it very attractive.
        3000 would lead to it being chosen in preference to founding religions and stuff.
        I needed to make it 100000 to have the AI do what I want. 1000 was the value I tried earlier.

        It might be an idea to give the wheel and mining a 2000 points and pottery and bronzworking 100000 each. It makes the AI a bit too predicable but on the other hand better predicable than lame.

        There are also such modifiers for buildings. Setting a granary to 100000 made a granary always being the second building. Baracs were always the frist building they have build. Except once where the second building was a library in a city without growth.

        The Leader propretries do have an iBuildUnitProb however I didn't notice any difference in behaviour when setting it to 1 and 1000 and 100000.

        Having lots of defensive units (longbows) made the AI prefer settlers and workers over other units but didn't boost buildings. It didn't know how to use gifted warriors for city defense, they simply walked around in the AI's territory without a target.

        After the AI had completed a number of units, doesn't matter if civil or military, in a city it switches into building build mode where it as a first move always build a Barac.



        Also your code doesn't get the city founding right either. It founds too often on a resource. It managed to found a city on the only occurence of silk on the entire map. That +1 happyness is wroth more. It also managed to found on a gold hill.

        Comment


        • #49
          i don't quite agree here. the AI usually has too few units. or should i at least say too few strong units.
          Before you build lots of units you should build a baracks. Early on you should also build a granary to boost growth so that the AI can make use of its higher happyness cap. In the long run you will have more and better units when prioritizing buildings.


          also, the AI always promotes the units immediately instead of a) waiting to see what's needed or b) recover from a battle quicker by halving the wounds.
          I suspect that the AI assigns promotions randomly. May I suggest the following algorithm:

          1) If a units can't be attack nor wants to attack don't promote.
          2) Otherwise evaluates the odds of combat and if under 75% choose the promotions that boosts the odds more.

          When attacking it shouldn't be complicated to determine the odds. One could work stack considerations into the code. Meaning if there is no unit without promotion in that stack with more that 75% when attacking reconsider all units with promotions and choose the best. If there still is no unit above 75% reconsider the stack and choose the best unit with colateral damage. If there is none with collateral damage choose the best unit for attacking with promotion if the odds are above 20%. Otherwise retreat.

          When defending it is probably a lot more difficult to work out the odds. An algorithms that considers all possibilities would probably be too slow. How about:
          For enemy each unit n tile away that can move n or more tiles consider the odds. With n : 1<=n<=2. Ignore stack issues.

          The downside of this algorithm is that when approaching an AI stack with a single unit it will trigger the promotions for each unit in that stack. This could be exploited by the user. For example approach an invasion force with an archer in the late game and all (damaged as the others will be over the 75% anyway) AI units will have anti archer promotion. Pretty much a wasted promotion when fighting against guns.

          On the other hand you probably will need to know the details about the game mechanics or otherwise you wont even notice this exploit.

          Comment


          • #50
            Before you build lots of units you should build a baracks. Early on you should also build a granary to boost growth so that the AI can make use of its higher happyness cap. In the long run you will have more and better units when prioritizing buildings.


            clear... some basic buildings are no-brainers. i just meant this in general, the AI doesn't build too many.

            I suspect that the AI assigns promotions randomly.

            not quite randomly. when a unit is built it gets assigned a AI-strategy. city defender, attacker, etc. so at the time. while some units are probably attack-only (swordsmen, all horse-based units), some are used for both (archers, axes, longbows, etc.). depending on what the built unit was intended for, an pikeman might get a city raider for isntance.

            May I suggest the following algorithm:
            1) If a units can't be attack nor wants to attack don't promote.
            2) Otherwise evaluates the odds of combat and if under 75% choose the promotions that boosts the odds more.


            1) --> certainly! but there probably is no flag/function called boolean couldBeAttackedAnyMomentNow()
            and don't forget that with your idea he might upgrade better for defences, but not with foresight. if we see the AI approaching with 4 knights, we'll have some elephants, spears and pikes to defend and we'll ignore upgrading the axemen. can the AI do that too?

            2) --> hardcoding is dangerous. 75% is a nice lead, but if you face cavalry vs. cavalry, giving combat I makes quite a big deal (10% more --> 68% chance of winning).


            as for the downside example with the archer: the algorithm ofcourse would consider the archer NOT a threat and wouldn't bother promoting.


            let's see what blake comes up with. so far it's been great
            - Artificial Intelligence usually beats real stupidity
            - Atheism is a nonprophet organization.

            Comment


            • #51
              Originally posted by ben04
              Also your code doesn't get the city founding right either. It founds too often on a resource. It managed to found a city on the only occurence of silk on the entire map. That +1 happyness is wroth more. It also managed to found on a gold hill.
              Founding on a luxury or food resource does not prevent the civ from obtaining the happiness or health it provides once the appropriate technology has been discovered (calender in this case). As with founding on strategic resources, it only detracts from the tile bonuses provided by the worker improvement ordinarily used to access the resource.

              Incidentally, the AI Persians settled a beautiful city on a plains cow in a game I played yesterday. Two gold mines and enough food (partially thanks to sugar) to work them both. I can't claim that the AI wouldn't have done so without the changes made but I find myself less likely to raise a city and resettle than I was before.
              LandMasses Version 3 Now Available since 18/05/2008.

              Comment


              • #52
                Sounds great work Blake.
                Clash of Civilization team member
                (a civ-like game whose goal is low micromanagement and good AI)
                web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                Comment


                • #53
                  I think I'm seeing some of the expected behaviours, I wonder if the AI is a little too keen on coast now, it's keener than I am anyway. I've seen it put down some pretty crummy towns just to get a single clam when most of the interior is a mix of moutain and desert. That's fine when space is running out, but early on, it feels like it shouldn't be one of the first three cities.

                  I can see the whipping working for the AI though, it's very cool, suddenly strategy is needed to win wars...

                  Is Barbarian city placement affected?
                  www.neo-geo.com

                  Comment


                  • #54
                    You're more than welcome to post any screenshots of suspect behaivour (remember the AI WILL maphack so take it from World Builder to reveal all resources).
                    Screenshots of smart (Wow!) behaivour are also welcome .

                    I happen to find that coastal cities are VERY good investments, they are cheap to set up and provide a good profit and are often connected to the trade for free. Other changes should improve the AI's use of food which will make them benefit more from seafood.


                    My latest developments have been to fix the pottery thing somewhat - the AI now recognizes Pottery as enabling Towns rather than Cottages. I might need to do more. It also places more weight on Alphabet especially if tech trading is enabled.

                    I know everyone wants combat improvements, but unfortunately combat is less formulaistic than other aspects. What I WILL try to do is improve city siege. I'll try and make it so the AI first bombards down all the defenses (if there's enough siege) then pauses for the siege to recover moves, it'll then attack with all the siege followed by all the other units - none of that splitting up stuff.
                    I'll also make it pillage a lot less to reduce frivolous losses.


                    edit: Ohhh man. The Worker AI is grizzly. The problem is that it doesn't see unimproved tiles and figure out how to improve them... instead it has this idea that a city's terrain is "good enough" like with floodplains, it doesn't see a great oppurtunity to improve the tile, it basically sees a tile that doesn't need improving.
                    The windmill > mine thing seems to be plain faulty coding, basically it figures out if a city will be starving at size 20 - so in that screenshot earlier of the mongol capital, all the hills leads the AI to believe that the city is starving and needs more irrigation, I can bandaid this by basing it more on population but then I discovered the issue with unimproved floodplains. I need to make the AI emphasize improving the tiles it's working.
                    Anyway as you can see with the bandaid fix (a 1-line code change) the AI is improved somewhat:


                    The lucky bugger popped a copper...
                    Last edited by Blake; October 1, 2006, 21:07.

                    Comment


                    • #55
                      Just wanted to join everyone else in saying, INCREDIBLE work, Blake.

                      Regarding building priorities, the first method that comes to mind is a systematic cost/benefit calculation.

                      Comment


                      • #56
                        Why would you train the AI to whip? A lot of real people have success without whipping on Immortal and Deity, probably more so than whippers. I can maintain an edge all the way through the middle ages (where my skills begin to deteriorate; have to work on that) and have never found whipping that good. If I can be kicking the AI's ass on deity in 500 BC, I don't think the AI needs to adopt whipping. But congratulations Blake. I can imagine myself trying to figure out that code. It looks the same as me trying to read the rossetta stone. I think the AI should be programmed to build less units and more buildings when not planning for a war in the near future. They should also bring troops to the frontal cities instead of leaving them sitting 3-6 to a city to be taken out piece-meal. Maybe that's pretty much impossible. Don't know; it's all a big mixture of hierogliphics, greek, and Egyptian to me.

                        Comment


                        • #57
                          Whipping is a quick, painless cure for happiness/unhealthiness woes.

                          Comment


                          • #58
                            Originally posted by Bobby Chicken
                            A lot of real people have success without whipping on Immortal and Deity, probably more so than whippers. I can maintain an edge all the way through the middle ages (where my skills begin to deteriorate; have to work on that) and have never found whipping that good.
                            There are people playing Deity level that do not whip!!?

                            What seems strange though is that it is possible to catch up and gain an edge at this level and yet merely “maintain” an edge thereafter. Is it perhaps the case that the “edge” is acquired too late for it to be converted into a strong advantage and that this is only possible at lower levels like Emperor?

                            But in answering your question about teaching the AI to whip, this is a more effective way of gaining production in the early to middle stages of the game for any city with moderate to good food. The AI does not play at Immortal level so it will play better if it whips.

                            Comment


                            • #59
                              I dunno about improving the AI, this thread has actually taught me a lot about city placement, whipping and build orders.
                              Jon Miller: MikeH speaks the truth
                              Jon Miller: MikeH is a shockingly revolting dolt and a masturbatory urine-reeking sideshow freak whose word is as valuable as an aging cow paddy.
                              We've got both kinds

                              Comment


                              • #60
                                Originally posted by couerdelion


                                There are people playing Deity level that do not whip!!?

                                What seems strange though is that it is possible to catch up and gain an edge at this level and yet merely “maintain” an edge thereafter. Is it perhaps the case that the “edge” is acquired too late for it to be converted into a strong advantage and that this is only possible at lower levels like Emperor?

                                But in answering your question about teaching the AI to whip, this is a more effective way of gaining production in the early to middle stages of the game for any city with moderate to good food. The AI does not play at Immortal level so it will play better if it whips.
                                OK, I think I got you. A granary is unecessary on deity because you do not want your poplulation to grow that fast. But if you ain't playin on emperor or above, you would benefit from the granary. So yah, teach 'em to whip. But yah, as far as whipping is concerned for players, pangea, deity, standard size world, ****ty starting location, and I was kicking ass into the middle ages where I got mauled from eight sides being in the middle of the continent with those unfriendly AIs surrounding me. I still might have to try a little midieval whipping though, to jumpstart some new cities.

                                Comment

                                Working...
                                X