Announcement

Collapse
No announcement yet.

AI -- the Thread

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

  • #76
    Originally posted by LDiCesare
    I actually coded the production order stuff. I won't be coding the intelligence for siege however, because I think it is too complicated.
    (snip)
    Richard, Mark, do you think it'd be worth to make a new jar to send so you can actually use the improvements you asked for? Or do you think you may have more requests so it'd be better to wait a bit?
    Thanks Laurent, I'm comfortable with your take on what to do and what not to do now. (Ok with you Richard after hearing about the opportunity costs?) It seems worthwhile to me to get a new version of the testbed out to Richard as soon as he's likely to use the new features. Owen has also done some bug fixes and improved the colonization and settlement code, so we should definitly put out a new testbed version soon in any case.

    Richard, should we rush to get you something? Alternatively if its going to be a while before you'd use the new stuff Laurent coded we might hold off until the coming weekend. Your call...

    It raises a complexity problem. So before I make any more choices, here is my dilemma:
    Do I try to simulate everything (i.e. movement + fight) or make it simple in a first run (fight only)?
    Otherwise put, I think it's better to make simple, limited simulations first, and only afterwards add complexity (moves...).
    I may also need a model of the world for the ai, including all known enemy units. Is there provision for scouting/assessing enemy forces without sending armies in the surrounding squares?
    I agree with you, start simple. We don't have a provision for getting info without scouting. For the first cut I would just make the AI Omniscient. We can reduce the info to a more realistic level later in the AI development. At least that's what seems best to me.
    Project Lead for The Clash of Civilizations
    A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
    Check it out at the Clash Web Site and Forum right here at Apolyton!

    Comment


    • #77
      I can be patient. I am finishing and fine-tuning the current batch of scenarios; you might want to look at those before releasing the next testbed. It would also be good if the official testbed includes my new files as defaults.

      I say keep it simple to start with. That´s always a good plan IMO.

      Why does it matter what units are being transported? How does that affect the fight, aside from assigning the transport units a support role so they try to stay out of the fighting?

      Comment


      • #78
        Transports will be important in teh long run because I must be carefult not to simulate the troops aboard ship as if they were on land, I also want to be anle to ferry them across a sea to allow for amphibious assaults. That's not near future, though.
        Getting the ai omniscient in terms of units is probably more of soon-wasted job (no use populating the map with far away units unless you know they will take part in some fights). About the map, that sounds ok.
        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


        • #79
          Originally posted by LDiCesare
          Getting the ai omniscient in terms of units is probably more of soon-wasted job (no use populating the map with far away units unless you know they will take part in some fights).
          I thought you were doing the AI for local fights. Why do you need to populate a map for the AI with irrelevant units? When I said omniscient I meant it knows everything about things it would want to know about. If that doesn't clarify things, maybe I don't understand exactly what you're doing, because omniscient sounds by-far the simplest thing to me.
          Project Lead for The Clash of Civilizations
          A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
          Check it out at the Clash Web Site and Forum right here at Apolyton!

          Comment


          • #80
            I need a map because I need the square and the units thare. That is actually simpler than what I thought, because in fact I limit myself to one square. The problem would arise if I had to check all the path from current square to target square if the square is far away.
            Retrieving units from a square is actually more time-consuming for the ai than for the coder (I have to check all units in the world everytime I have to know the units in a square). I'll worry about that later.

            Here is a small brief of what I have been doing. Nothing in the new classes even compiles yet.
            I have coded Success and Plan objects. I am in the process of coding a plan corresponding to each order currently available to the ai. I started with a TakeSquarePlan. This plan has a simulation method in which I simulate fights in the target square. I code that as limited to the target square, and include militia. I still have to check the sieges code to make sure I don't destroy walls during simulations.
            The way lists of units are managed has to be changed to accomodate the simulation process efficiently, but I'll do that only after I reach enough code that I can actually test it.
            Armies are part of a Resources class that each plan has, and resources are also estimated for the enemy, locally to the square of interest.
            To make a good simulation for far-reached invasions, I'll have to make a copy of the world, a known world, where I have maps from which units can be retrieved easily and fast, and corresponding to the invader's knowledge. That is not a priority, however.
            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


            • #81
              Thanks Laurent, that makes it clear what you're doing. And its even more-or-less what I thought .
              Project Lead for The Clash of Civilizations
              A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
              Check it out at the Clash Web Site and Forum right here at Apolyton!

              Comment


              • #82
                Progress is being made

                AI simulation works.
                I coded the ai from both ends, and am still far from finished, but I see the first results.
                The (military) ai is all about giving orders to task forces. The objective is to simulate different strategies at a high level and find the most suitable one so each unit can be given the correct orders. Currently, taskforces are given orders, execute them, and then ask for new ones. If we keep it that way, the high level ai should have plans in which they know which order they want to give to which task force once these task forces have finished their current task.
                However, if a simulation shows things should be ok, and an order has been given at a certain time, suddenly, reality may prove it wrong. For example, the taskforce realizes there is an unplanned for wall around Rome. So, what I did is, before every move, a taskforce will look for opponents in the destination square, simulate a fight, and decide what to do. If the fight goes well, they will attack. If it doesn't, they will cancel their order and ask for new orders.
                The problem with that simulation is that it is done per task force. That means if you have 40 taskforces of 1000 men who want to go into a square defended by 2000 men, none will move. It is a bit hard for me to coordinate all the taskforces, so I added a new order, 'merge', which means a task force will try to merge with another task force in the same square. When such a merge order happens, the task force merges itself with another one. That allows the ai to build task forces instead of individual units, and to realize that 3000 men can beat 2000 men, and attack. Probably in the 40000 men example, 3 or 4 of the 40 task forces would merge together, some would move away to choose other targets, etc., but ultimately they will attack the better-defended square. Comments on this particular point are welcome. Other ideas about merging units or what to do when an order is irrealistic are welcome.

                In scenario terms, that means Hannibal won't attack Rome unless he has a huge advantage. Considering he has no siege engines, he is still unable to take the city, but he will attack only if he "wins" the fight (which is very morale dependent in a siege, but usually straightforward in an open fight).

                Some problems with this approach: The simulation run is a one-turn simulation, which will not be able to take sieges into account effectively. I'd be able to if I computed the amount of damage dealt to the wall, compared it to the ratio of damage taken, then considered that the army can breach the wall before they are totally killed. This has a drawback, however, which is that subsequent turns of fight will likely be different from the current fight, and simulation is only run when deciding to go into a square, not when already there.
                Other cases when simulation is not run:
                -The target square is owned by the civilization. The simulation doesn't consider allied troops (yet), so it is simpler to allow moves to defend one's territory because there are already troops there anyway.
                -The player controls the troops. I didn't like it when Scipio refused to fight Hannibal. Sure, I knew he was going to be toasted, but that was my decision.

                Now I must get back to the top-down orders ai which simulates things in separate threads, but I think this one is really a big step in the right direction.
                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


                • #83
                  Re: Progress is being made

                  Originally posted by LDiCesare
                  AI simulation works.
                  I coded the ai from both ends, and am still far from finished, but I see the first results.
                  Cool, Laurent, Great progress!

                  The problem with that simulation is that it is done per task force. That means if you have 40 taskforces of 1000 men who want to go into a square defended by 2000 men, none will move. It is a bit hard for me to coordinate all the taskforces, so I added a new order, 'merge', which means a task force will try to merge with another task force in the same square. When such a merge order happens, the task force merges itself with another one. That allows the ai to build task forces instead of individual units, and to realize that 3000 men can beat 2000 men, and attack. Probably in the 40000 men example, 3 or 4 of the 40 task forces would merge together, some would move away to choose other targets, etc., but ultimately they will attack the better-defended square. Comments on this particular point are welcome. Other ideas about merging units or what to do when an order is irrealistic are welcome.
                  I think what you most need is an order that has TFs go to a waypoint, wait x turns and merge with whatever's there. This should be the "goal" order in many cases while the AI is primitive. After whatever TFs are available merge then they can search for a relevant target given their power. Coupled with a "build siege engines" order this can also allow for reasonable attacks on walled cities. A suitable waypoint is the provincial capital closest to the "front". Most TFs should IMO start with the "assemble at waypoint" order. (If two choices are nearly equally good I would send the units to the closest one when built).

                  The waypoint idea also helps in that while waiting the troops are in an important defensive spot where they may do some good. When Fog of War is active the arrival of new units will actually make the players' challenge in taking an enemy provincial capital much better. There are lots more specifics I could suggest, but I'll wait to see what the response is first.

                  In scenario terms, that means Hannibal won't attack Rome unless he has a huge advantage. Considering he has no siege engines, he is still unable to take the city, but he will attack only if he "wins" the fight (which is very morale dependent in a siege, but usually straightforward in an open fight).

                  Some problems with this approach: The simulation run is a one-turn simulation, which will not be able to take sieges into account effectively. I'd be able to if I computed the amount of damage dealt to the wall, compared it to the ratio of damage taken, then considered that the army can breach the wall before they are totally killed. This has a drawback, however, which is that subsequent turns of fight will likely be different from the current fight, and simulation is only run when deciding to go into a square, not when already there.
                  I think the simulation should be run even when a battle is in progress. Otherwise I think the outline above is quite reasonable.

                  The player controls the troops. I didn't like it when Scipio refused to fight Hannibal. Sure, I knew he was going to be toasted, but that was my decision.
                  I would still like to have local-commander override of orders available as we had in Demo 4. The player can set the odds at which he wants all forces to abort an attack. That way if Scipio gets there and he is outnumbered he can consult the standard orders and abort as specified. If the player wants his units to make boneheaded attack then they can select odds of 0 or less as the retreat threshold. It would be better to use success chance than odds. If what you have can estimate success chances even for cases like walls that would be a vast improvement. Normally the setting would be say 1.5: 1 odds or better to stay, or maybe a 75% success chance. But the important thing is with one setting the player can change to overall risk profile of the field commanders. Eventually this number should be able to be overridden in an specific order, but we don't need that yet.

                  Now I must get back to the top-down orders ai which simulates things in separate threads, but I think this one is really a big step in the right direction.
                  Looking forward to seeing it in action!
                  Project Lead for The Clash of Civilizations
                  A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                  Check it out at the Clash Web Site and Forum right here at Apolyton!

                  Comment


                  • #84
                    Progress report:
                    I haven't been doing much progress lately ('cause of work last month, now of GalCiv -good ai by the way-). I have reached a point, however, where the ai needs a map of its own to work with. I am not tackling the map ai, but just wanting to let the ai be able to "see" the map, so it knows only units which it sees, etc. I am starting to code it. I want to allow an option to show what the ai sees (helpful to debug the ai - and to cheat).
                    With that in place, it will later be posssible to add some spying so a player or ai can see some units where it has significant spying info. Currently, I will keep just show military info in the neighbouring squares. Longer term, the infrastructure should also be copied (so ai doesn't know that infrastructure increased in a square it's been to only 3 centuries ago).
                    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


                    • #85
                      Hi Laurent, sounds like a basically good plan. At least you are making some progress. I still don't even have an IDE since I "bought" one on ebay, and it looks like the slime I bought it from took the money and ran. . .

                      Originally posted by LDiCesare Longer term, the infrastructure should also be copied (so ai doesn't know that infrastructure increased in a square it's been to only 3 centuries ago).
                      I don't think this is practical or particulary desirable. In the real world there are lots of info flows that are not included. In that way even though you haven't been to a square in three centuries there are ways to obtain lots of info about it. Also, it seems that a detailed infrastructure map for every civ will use more computer resources than its worth.

                      BTW, I will be on vacation next week. I should have access to my email and the forum though, so it shouldn't cause any big problems. Just if you want to discuss some AI issues in detail, its best done before this Saturday. . .
                      Project Lead for The Clash of Civilizations
                      A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                      Check it out at the Clash Web Site and Forum right here at Apolyton!

                      Comment


                      • #86
                        Also, it seems that a detailed infrastructure map for every civ will use more computer resources than its worth
                        That's also what I thought, so I decided to postpone that anyway. I think a single figure providing a composite "value" of the square could be enough for unseen squares. I agree that a square three squares away from your civ will have some contact info coming through, but an unseen square half the world away shouldn't.
                        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


                        • #87
                          Now that the new ai seems to behave like the old (read - it works), I would like to test it to see if it can get some strategies to evolve. I am not sure whether the current scenarii will allow me to test it fully. I think it may be a good idea to devise a "for the ai" scenario, where you have choices of targets. Current scenarios more or less enforce a straight route towards the nearest target, so they needn't clever tactics (though timing, etc. are an issue). I will set my goal thus:
                          Scenario where there are 2 defender cities, one walled. I want to see the attacker 1) explore, 2) attack nonwalled city, 3) build siege weapons, 4) attack walled city. I let the defender do nothing at first. The difference with siegewars is that there should be a choice between attacking walled city or attacking not walled city.
                          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


                          • #88
                            Hi Laurent, your proposal sounds good to me. I'm comfortable waiting until you have something that's noticeably better before I get the code. I don't have a functional IDE right now anyway!
                            Project Lead for The Clash of Civilizations
                            A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                            Check it out at the Clash Web Site and Forum right here at Apolyton!

                            Comment


                            • #89
                              BTW how do you like GalCiv? Does it have enough long-term playing potential to make it worth getting? I'm likely to get it the next time I'm in the mood for serious computer gaming anyway.

                              I've gone ahead and ordered an IDE too, so I should be back in business by sometime next week.

                              Cya,

                              Mark
                              Project Lead for The Clash of Civilizations
                              A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                              Check it out at the Clash Web Site and Forum right here at Apolyton!

                              Comment


                              • #90
                                Mark, I suggest you don't buy Galciv if you want to do something else. Otherwise, well, it is really worth buying, although it has a bit too much micromanagement at times (things like research points not carrying on from one tech to the following). But overall it is great, and the ai is quite good.
                                Here are a few strengths of Galciv ai (just to look like I'm still on topic):
                                - It attacks people if they are weaker, not if they are stronger.
                                - It can use destabilization/spying effectively.
                                - It sees when you make buildups or when you build 'culture bombs' in their sectors.
                                - It is very efficient in the opening.
                                - It trades between one another and considers the player as just another civ.
                                It has a few weaknesses too...

                                Back more on-topic:
                                I've got 2 weeks without apolyton access worth of remarks, so I am dumping my notes here:


                                I want AI to be able to attack walls:
                                AI must be able to switch production to good units. This means: It must be able to know what to build, so the ai must plan some kind of attack forces required:
                                It will say - I want to take city X. I find out that with current simulations, I lose, so I need more troops. How many? Also, I realize there is a wall, so I need siege engines.
                                This means the ai must be able to find out the available units, and for each unit, decide on whether or not to build it, based on the unit's stats: (Attack*Armor*Defense*Health), Movement, Distance, Morale?, Mobility?, FlankerEffectivity, Dispersion?, Cost, available orders: Attack/Scout/Skirmish/Build/Breach/Support.
                                Ideally it wants: Combat troops, divided in: Scouts, Skirmishers, Melee, Flankers, Support: Proportions should be ai-dependant/scripted. If it realizes it needs breachers, it will build some until it finds out it's able to breach the walls through simulation.
                                Obviously, I am going to start simple here. I just want to be able to ask for reinforcements and for breachers.

                                Now I have more or less coded the "ask for reinforcement of a given type" order, and it will take existing idle armies and give it to the required command.
                                I also don't know how to exactly model idle armies. I created a "reserve" order and give it to some units. Ideally, the success of that plan would be a percentage of total army so more units are not put in reserve when more needed elsewhere. This makes the current code have three different idle orders: Do nothing, wait for reinforcements to arrive, be in reserve. I may have to make things simpler at some point.

                                However, I still don't have the "change econ orders" plan. This is what I will really need now. If you have any suggestions on how to handle this, in particular what this means in terms of various levels of ai, I am interested:
                                The ai currently works by having units ask for orders to higher order plans, which take decisions when asked. This really means each unit executes its orders until it is over. So the high level ai is actually quite lazy, as it makes some computations in its thread, and gives orders off-handedly when asked by the real-world units. This doesn't work for econ orders, which never ask for anything.

                                I also have a few ideas about how threads should be implemented in order to avoid concurrent modifications, but that is still a bit murky.
                                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

                                Working...
                                X