Announcement

Collapse
No announcement yet.

Civ III AI - This explains everything (at least to me)

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

  • #46
    Peter,

    Has anybody in CTP2 community used anything from SLIC code I wrote for MyMOD (nuke, spies and naval building stratgegies for example).

    Comment


    • #47
      I don't know. I think Martin may have incorporated some of your stuff into GoodMod but I don't know if it found it's way from there into any of the other mods.

      Comment


      • #48
        Originally posted by SwitchMoO


        Any mere game company? Try any company, ever. Does anyone think anyone'll develop AI that even comes close to human behaviour? IMO, no. Our brains are just too complex, and then there's the added problem of dynamic personalities, forgetfullnes, moral fibres, and the soul. No, it's just too much for our small in comprehension yet high in complexity brains
        Remember that today's chess programs can beat even grandmasters (and world champions, for that matter). I bet if as much effort would be spent on developing a Civ AI as is being spent on developing more powerful chess engines, soon only the most brilliant Civ players could beat the AI.

        The reason is that computers are potentially very good at all kinds of games involving randomness and luck. A computer can calculate probabilities just that much faster than any human being. So it would say: "there's a 37.593% chance to win this war now, but if I keep building units for 10 more rounds I could increase the odds to 62.524%". But of course this can't be done in 8 months

        Comment


        • #49
          kavau,
          Chess is a SIMPLE game. MUCH simpler than any of the Civilization franchise!

          Comment


          • #50
            Originally posted by kavau
            The reason is that computers are potentially very good at all kinds of games involving randomness and luck. A computer can calculate probabilities just that much faster than any human being. So it would say: "there's a 37.593% chance to win this war now, but if I keep building units for 10 more rounds I could increase the odds to 62.524%". But of course this can't be done in 8 months
            Hi kavau:

            We're trying to do something like what you're talking about with the Clash of Civs AI. Without perfect information the sort of calculation you forsee can't be done accurately. And projecting a game with thousands of decision variables ten turns into the future with 5-digit accuracy is a challenging problem

            But we're willing to spend years at it if necessary, to get it right. The other advantage we have is that we plan to run the AI in the background during player moves, since Clash is simultaneous. That helps a Lot with heavy-duty simulation of scenarios.


            Hey Jaybe:

            The reason I think the chess analogy isn't too far off is that while chess has a simpler search space, the objective function is much more sensitive to bad moves. In a civ-type game, if one has a decent strategy, there are lots of large blunders that can be made along the way that can be recovered from. In chess, once you drop that piece, you're toast. So the fitness function is "spikier" requiring a lot more care in the search IMO. I've done just a little AI professionally, and hope to learn a lot more doing the Clash AI.

            -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


            • #51
              Originally posted by Trip
              Exactly.

              Let's just hope that they give Soren some help with IV. Just imagine how that game will be. We might be horrified and delighted at the same time seeing paratroopers landing behind our lines taking cities, while marines land from the coast, as we cry to our mommies!
              I sincerely hope Soren has NOTHING to do with Civ 4 since he seems obsessed with this Culture Flipping crap. He couldn't even figure out that roads CAN be used, historically, by invading enemies armies during war.

              Comment


              • #52
                Originally posted by Coracle


                I sincerely hope Soren has NOTHING to do with Civ 4 since he seems obsessed with this Culture Flipping crap. He couldn't even figure out that roads CAN be used, historically, by invading enemies armies during war.

                you really don't have a clue, do you coracle. Have you played the previous games? The AI is a patsy. At least in Civ3, it puts up a good fight.

                Comment


                • #53
                  Originally posted by MBD
                  I understand this may be asking too much, but can some of you guys who are more familiar with these AI scripts give me an idea of what kinds of things and what the level of detail you would want to see in this scripting language?
                  Since I am using this term, and one of the biggest advocates for scripting, I'll give it a shot. For me the best way to understand something is an example. I'll try to outline the relatively easy and powerful Swordsmen Conquest strategy. This is only the opening moves, and only good for small and standard maps, but may give readers a basic idea.

                  Ancient_Age /* change scripts when changing ages */
                  Research: Bronze then Iron, then Horseback Riding as priorities
                  Resources: Claim Iron, claim luxuries, claim horses
                  Expansion: build 3 production cities, after that look for resource cities
                  Units: build settlers until 4 to 6 cities depending on resources, after that build warriors or swordsmen
                  Aggressiveness: attack nearest enemy once 10 units are in the attacking stack

                  What this might have to translate into pseudocode, may involve flags, sliders or functions such as:

                  Research (Iron Working) /* make this top priority */
                  Build_cities (4, 50%, 10 turns) /* build four cities then build attack force, 50% chance, reroll again after each additional city, or after 10 turns of building only military units */
                  Build_defenders (1, 100%) /* one defender per city, 100% priority */
                  Build_defenders (2, 30%) /* second defender 30% of the time */
                  Build_attackers (10, 70% offensive) /* stack of 10 units, 70% offensive rest mixed */
                  Aggression (10 units, 80%, 75%) /* attack after 10 units are in stack 80% of the time, attack even if enemy appears stronger 75% */
                  Appease (90%, 20%) /* give in to enemy demands for tribute 90%, but lower this by 20% with each give in */

                  Well, this might give you an idea or might make your head spin. As I have said before writing a script engine is a huge big project. This pseudo code is off the top of my head, not from a well thought out design document.

                  I believe scripting may be one of the most cost effective ways to a decent AI. Closed system approaches are always going to have loopholes and fans find them very quickly and then everyone can drive a truck through the loophole.

                  Comment


                  • #54
                    Despite the fact Mark beat me to posting here, I'll say the Clash of Civilizations strives for good AI, including thinking about genetic algorithms, or rather simulating moves. This should include learning if that is feasible.
                    Also, scripts are good. I think CtP2 has managed to get good AIs from scripts. (The original CtP2 AI was the lamest thing I ever saw.) Remember that you learn the game, the AI does not, but scripts are a good way to circumvent that, thus they are good. Simply tweaking scripts and randomly modifying one or two figures in a script and playing it several times against the human player woul let the computer learn. Imagine there are 16 AI civs, 4 civs with script 1, 4 with script2 etc. After maybe 2 or 3 games (starts) you can probably infer that script 1 is worth nothing, but script3 has an edge, so you can use a genetic algo here. Whether it will learn faster than player will get bored is another point. Still, if you could share scripts (and experience the program had about script effectiveness) through the network, the AI could get much better faster.
                    But of course, adapting/mutating script is quite a challenge, and is not done in 8 months...
                    I insist that the programming was done in 8 months. No programmer in their right mind programs without testing their program. Or if they do, the program never runs. The half/half is actually quite a proof Soren is agood programmer because you usually spend more time debugging than programming...
                    Anyway I don't know, civ3 won't run on my machine and I won't buy a new one just to get a bigger screen.
                    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


                    • #55
                      BillChin, your scripting example is good. What is missing, however, is a discussion of how the scripts are exchanged/replaced as new information becomes available. With no adaptability, the AI you described wouldn't be very competitive. Sure, in a vacuum, it could produce a nice little force of Swordsmen, and in a real game it could even put up a nice fight early on. But most of the time the AI would be left wandering around with no one to conquer, or stuck attempting to secure Iron. Any AI needs to have either 1) a bunch of if-then statements to deal with various circumstances (the programmer needs to code these with his or her domain knowledge), 2) a means of proposing alternative actions itself. (2) is really hard to implement, but would mark the existence of a truly "intelligent" AI.


                      Dominae
                      And her eyes have all the seeming of a demon's that is dreaming...

                      Comment


                      • #56
                        Originally posted by Dominae
                        BillChin, your scripting example is good. What is missing, however, is a discussion of how the scripts are exchanged/replaced as new information becomes available. With no adaptability, the AI you described wouldn't be very competitive. Sure, in a vacuum, it could produce a nice little force of Swordsmen, and in a real game it could even put up a nice fight early on. But most of the time the AI would be left wandering around with no one to conquer, or stuck attempting to secure Iron. Any AI needs to have either 1) a bunch of if-then statements to deal with various circumstances (the programmer needs to code these with his or her domain knowledge), 2) a means of proposing alternative actions itself. (2) is really hard to implement, but would mark the existence of a truly "intelligent" AI.

                        Dominae
                        You are correct that programming constructs such as if-then-else, while loops, are good ideas to include in a scripting language. You are also correct that contigencies such as no iron or no enemy near by, are needed. Maybe place a big while loop around it and change gears once Horseback Riding is researched or change after a certain number of cities are built, or a certain number of turns are played. This is not a big deal, but may have been unclear to some readers, so thanks for the chance to clarify the point.

                        Example:
                        While Cities_in_Empire < 8 use Swordmen Conquest module

                        If a company is going to do scripts, several weeks or months of input would be incorporated into the design document. A lot of new stuff would be added as scripts are found to be inadequate. It is a dynamic process. New patches might include new functions, sliders, flags, or whatever fans might think up, as well as new scripts.

                        Proposing alternative actions within the AI is a good idea. This might be similated by a random chance to do certain things or a random chance to load a totally different script file.

                        There are easy ways to approach a problem and hard ways. Frame the problem in a way the computer can solve, instead of a way that the computer has little chance at solving and the AI has a much better chance of looking intelligent and playing a decent game. The task itself, a decent 4x game AI, is not hard. I see it more as a problem of time and resources than technical or programming issues. Humans can make the task very hard, by framing it in certain ways, but I believe this is a choice, not something inherent to this particular task.

                        Comment


                        • #57
                          IIRC, chess "AI" works less as a real AI, and more like, "Okay, calculate every possible outcome up to X turns into the future ... okay now force the game down the best path for the computer player by moving this piece." In other words, Civ AI rocks Chess AI =P
                          Caelicola

                          Comment


                          • #58
                            BillChin, thanks for the reply; I'm in complete agreement with all your points. The fact of the matter is, the current Civ3 AI is implemented in a way very similar to what you're describing (as far as I know). The main idea you're proposing is to let the player community write their own scripts in a new scripting language. I've never played CtP much, but the idea seems to have some merit. I think that main problem will be how to pool scripts together to create a interesting and challenging AI. In other words, there needs to be some code to pick and choose the scripts; this is the code that will make or break the AI, IMO.

                            Just a little example, which is an extension of yours. If the script dicates that whenever a civ's number of cities is below 8 the "Swordsmen conquest" script is called, a number of problems come to mind. When the ninth city is built, what happens to the Swordsmen? It seems necessary to have the next script mention what is done with standing forces (or are the Swordsmen disbanded?). If a civ gets bumped from 12 cities to 8 cities (through war, most probably), does it go back to the "Swordsmen conquest" script? If so, the new Settlers built via the script may not have anywhere to go anymore (all the land has been claimed). I'm sure you can imagine other scenarios.

                            My point is not that the script idea is bad. Rather, the scripts need to complex enough to be useful, regardless of the state of the game (or of many state variables). Or, the algorithm that selects the scripts needs to be make "smart" choices regarding scripts (thus creating the need for a "meta-AI"). I would much prefer seeing the second case come to life.


                            Dominae
                            And her eyes have all the seeming of a demon's that is dreaming...

                            Comment


                            • #59
                              Happy Birthday, Soren

                              Comment


                              • #60
                                BillChin, thanks for your responses from me too.

                                I agree that using scripts can be a good way to quickly develop a reasonably competent AI for a Civ-type game. There’s still a lot about where scripts fit into the whole AI that I’m not sure about. I was wondering what you think about a couple of potential problem areas –

                                First, the inputs. For the right script to be used, the AI has to be able to convert the player’s game position into something the AI can use, possibly like a set of (weighted) values. Does that make sense?

                                Second, the current situation. This relates to the first point. In order to choose a script, you have to understand the position you’re in. If you express the player’s position too specifically, it may seem to the AI that every position is unique, which makes it harder for the AI to learn from past experience. OTOH, if you express the player’s position at too high a level, crucial information may get left out. How do you find the balancing point?

                                Third, the changing situation. Over the course of the game, some things become less important, while others become more important. Once the AI player has developed a defensible core of cities, survival becomes less imperative, and the AI can turn its attention to expansion. I suppose this gets back to changing the weighted values associated with the player’s position, right?

                                Fourth, the value of each script. In order to work well, it seems like you’d want to have multiple scripts available all the time, and then choose the best one. But that brings up the problem of determining which one is best. (“Good judgment comes from experience; experience comes from bad judgment”) In other words, how would you try to figure out which script gets you the most “bang for the buck” at any given point in the game?

                                Comment

                                Working...
                                X