Announcement

Collapse
No announcement yet.

Recruiting to do the best AI combat slic handler ever!

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

  • Recruiting to do the best AI combat slic handler ever!

    Sunday i come up with an idea. I will do the best AI combat handler ever done for CTP2!

    Ideas:

    1) Find the best city to launch an attack ever evaluating the city by inumerous variables like owner diplomatic relation, location, defense, distance, etc... Once chosen all strategy will be done there!

    2) Teach the AI to orgqanize Stacks. The idea is to make the AI check the city defense according to a threat level when building a unit. If the city has the defense according to this threat level already this units is sent to field! All field units will merge in a stack until a size 12 stack is built. If the building is complete it will make another stack!

    3) A brach from number two but teach the AI how to construct stacks.

    4) Check how many size 10-12 unit is need to conquer the best target which was already evaluated in the first topic. And send all needed units there. The AI will only attack once all the stacks sent to the location are only one tile away from the target!

    5) Make a alghorith good enough to find out if a city is in another continent. And if it is teach the AI to make Cross Water Attacks. No ideas yet but still want to check Peter Triggs work in the other thread.

    5) Teach the AI to make strategies for water battles. and water navies creation.

    6) Teach the AI what to build according to the needs of the cities and not by dark/unknow priorits of strategis.txt!

    So Far
    With this intent i started coding without testing! Just plain coding. Achieving a really good code with 400 lines for topic 1, 2 and part of 4 in which i am really proud. But when looking the agenda kind of scared me because the to do list is still enormous and the bug-freeing work will be enourmous.

    Recruiting:

    So i decide to ask for help!
    Specially coders for two task:
    1) Actual coding! Peter Triggs, Locutus, Martin, Dale, MrBaggins, IW, mapfi, ahenobarb or any other avaible coder around here to recruit to make those topics come through and workable with the others parts of the slic!
    2) Bug-freers! Anyone coder i mentioned before or any other to help me find the flaws of my code and help me with the testing of the existing code!

    But not only coders but I am also open for suggestions if anyone has a better idea bout my ideas.

    And Testers. Some guys to hep me test the in-game stuff of the code. What is working and what isnt!

    This can be the chance to make the CTP2 AI the best possible using slic with the help of all community.
    So, is anyone interested?

    The unfinished code I have worked already will follow after i hear some comments!
    "Kill a man and you are a murder.
    Kill thousands and you are a conquer.
    Kill all and you are a God!"
    -Jean Rostand

  • #2
    Re: Recruiting to do the best AI combat slic handler ever!

    Sounds very ambitious Pedrunn! It would be nice to improve the AI's tactical abilities. I would be interested in working on number 3, if possible.

    Later, It would be nice if we could get the AI to choose the best cities to attack. Such as the nearest of the opponent's top cities (in terms of size and production), so it focuses on the closest strategic cities. Maybe some diplomatic evaluation then to determine if it is time to pursue peace or press on to the next city.

    Further down the road, I would like to improve the way the stacks approach the cities they want to attack. This would be done by writing an algorithm to evaluate the defense bonus of the terrain around the cities and the number of spaces the stacks can move per turn to ensure the stacks are always on favorable terrain.

    As soon as you're ready, please share your code.

    Comment


    • #3
      Sounds good.

      What you may whish to look in one of the AI files I can't for the life of me remember which one but the other year when I was messing about in there I actually got the AI to build a plane.

      Any code you want doing give us a bell if I haven’t got much work on I will give it a go.
      "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
      The BIG MC making ctp2 a much unsafer place.
      Visit the big mc’s website

      Comment


      • #4
        heh. interesting...
        Concrete, Abstract, or Squoingy?
        "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

        Comment


        • #5
          Well, I've been working on revamping the AI as well, using a more generic pattern (a bit like ahenobarb is talking about, only worse ).

          My idea is to completely rewrite the AI in SLIC. I've suggested this before and at the time it was more a dream than a real ambition, but I'm more serious now: I do think that if a couple of people put their heads together, it *can* be done. Such a design can easily be split in independent modules, so that each module works on its own. This way even if a complete model is never finished, a lot of useful and usable code is still produced.

          I've attached a diagram of initial module design below. IMO the AI should approach the game the same way humans do: the eventual goal/desire for an AI is to win the game. Through what type of victory partially depends on circumstances and partially on personality. To accomplish this desire, a strategy (ranked list of overall goals) is created: destroy the Austrian civ, prevent war with the Germans, get an alliance with the Thai, rush to Monarchy, build up the economy, etc. To accomplish these goals, the various parts of the game (diplomacy, military, cities (including trade), infrastructure and science) need to be optimized for them. Seperate modules can be written to deal with each of these parts of the game (though eventually some communication between these modules may be needed). For each part of the game, the ideal situation that should be strifed for (= desire) is modeled and a new strategy to accomplish this is created by determining more (sub)goals (i.e. if a strategic goal is to destroy the Austrians, the military desire is to control or destroy all Austrian cities and the subgoals could for example be to conquer Graz, to get a peace treaty with the Germans, to research Catapults, etc). Finally, these goals need to be executed.

          This system of modules is good because one can simply develop one set of modules while the AI still controls all the other: while developing military code, you don't have to worry about how the AI handles science or PW as the existing built-in AI already does that for you. Also, the top layers of this model can easily be kept empty or very simple as you're developing the bottom layer(s).

          Basically the stuff Pedrunn is talking about in this thread (including Peter's naval invasion code) is part of the MilitaryStrategy and MilitaryRealization modules (which are by far the largest part of my diagram and will certainly need to be refined and split up in submodules). These can (and should) be written without having access to any other module in my diagram. But of course, in the end a kick-ass military AI will still loose the war if the economy is geared towards building Wonders and the diplomacy policy creates more enemies than allies...

          Though I was still thinking things out, Pedrunn's recruiting pretty much coincides with what I wanted to do myself. The main difference is that I do want to work a little more systematically: blindly starting to write some random code without thinking things through or debugging anything is suicide and bound to fail miserably. It's this attitude that causes 90% of professionally developed software products to take 50% longer to develop than initially calculated, cost about 200% more and in the end still doesn't do what they're supposed to (I don't know the precise numbers, I pulled those out of my arse, but the general trend is real: getting these numbers down is the biggest challenge of professional IT development today). CtP2 itself is a fine example of this

          As Pedrunn pointed out: the total amount of work that needs to be done is enormous and without any kind of structure anyone would loose sight of things in no-time. If you take some time in advance to make a design of your final product and properly split your design in modules which can be developed and tested independently, you avoid a lot of problems. The amount of work involved seems far less overwhelming, you have a far more manageable and controllable project, you can test modules seperately (Ever tried to debug 50,000+ lines of code which haven't been debugged before? You'll need at least 2 weeks to get the syntax errors out alone and you'll almost certainly never find all the bugs), you can far more easily work together in a group (without people producing double or incompatible code), etc, etc. The advantages are numerous.

          In my opinion the best thing to do right now is to make an inventory of all code that already exists (debugged or not). Since this is probably (almost) all military AI code, the next step could be to discuss what the military AI should look like. If my design of desires/strategy modules is deemed a workable model, we'd need to flesh out the design of the military branch (splitting it up in lots smaller, independent submodules) and continue to develop that. By the time that's done it's probably 2006, so if anyone is still here by then we can see how to continue after that
          Attached Files
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #6
            ahenobarb, I would love to know about your ideas for the part of the code you want to do.

            Locutus, your ideas pretty much coincide with mine. With the DG going on we are playing how the human strategy is build up. You divided the AI in the branchs: Diplomacy, Military, Domestic Affairs, Infrastructure and Science (from left to right). Which coincides immensily with the governments positios of the DG. And that is exacly what I have in mind!!!
            My project is looking for the Military and Domestic Affairs of the AI. But first a work focused in the Military. Still i planned to extend it to these other areas specially diplomacy.

            The way the AI handles diplomacy, which is as important as miltary since it is terrible broken in the game (more then military). So indeed thats something to work on!
            But i rather work not doing like Peter Triggs did in the Diplomod2 and not like Richard Meyers. Doing a proposal type checking to accept according to this typ but i would like to work in the value of the proposal arguments using functions like GetLastNewProposalArg(sender, receiver,int,param/int), GetLastNewProposalArg(sender, receiver,0,tmpCity) and GetNewProposalResult(sender,receiver,player,type).
            The last one was tested by me and serves the best for my wishs.

            Arccording to the alues of the proposals arguments the AI willl Accept or decline. So count me in to make the diplomatic advisor code.

            As for the Infrastrucure branch, indeed we need to make some work on this! The way CTP2 handles is terrble since we have no control and commerce is not included!

            The Science branch would be nice to work too but not really that needed.

            Waiting feedback from the people willing to help me about my ideas, Locutus ideas discussion and my code

            About that I count Locutus, ahenobarb and me for this project. Anyone else?

            Still what i've done in the Military Advisor code is here.
            Note: I only did the stack arragement code, the find best target algorythm (both in the BeginTurn handler) and the check where to send built unit handler(if city is too well protected send unit outside the city is in the CreateUnit handler)
            Attached Files
            "Kill a man and you are a murder.
            Kill thousands and you are a conquer.
            Kill all and you are a God!"
            -Jean Rostand

            Comment


            • #7
              I reviewed the part of the code dealing with creating the stacks (MoveUnitsOutsideCities). I have some ideas on how to further elaborate and implement this portion of the code. The idea works like this:

              Code:
              1)	Establish rally points outside the city, i.e. build forts.
              	Store the location of these forts in an array.
              2)	When a city builds a unit in excess of what it currently 
              	needs for city defense (determined by the Defense 
              	Strategies in the “strategies.txt” file), look at array for 
              	available rally points, then move excess units to the 
              	rally points –build stacks.
              3)	When building stacks, create different types of stacks 
              	depending on the “Conquest” flag Aggressive/neutral/passive) 
              	in the “personalities.txt” file.  There will be three types 
              	of stacks:
              	          a.	Traditional stacks: 4 attack/4 ranged/
              			4 flankers
              	          b.	Stalwart stacks: 3 defensive/ 3 attack/ 
              			4 ranged/ 2 flankers
              	          c.	Hordes: 12 flankers (used to move quickly to 
              			danger/undefended zones)
              
              Passive personalities will build: 40% type a, 50% type b, and 10% c.
              Neutral personalities will build: 50% type a, 30% b, and 20% c.
              Aggressive personalities build: 60% type a, 10% b, and 30% type c.
              Once that code is done, we can focus on improving the code to select the “best” rally points or forts locations (near capital & principal cities, near borders with opponent civs).

              Comment


              • #8
                I myself would like to focus on giving AIs 'situational awareness', i.e. making them aware of the shape and terrain of the map, the proximity of neighbours (and the threat they pose), location of important cities/tiles, etc. I think Peter and maybe others have been working on this already as well, so hopefully we can put our heads together on this.
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment


                • #9
                  ahenobarb , looks better than i ever imagined to see implemented. The pesonalities is something good to talk about!
                  I myself would like to focus on giving AIs 'situational awareness', i.e. making them aware of the shape and terrain of the map, the proximity of neighbours (and the threat they pose), location of important cities/tiles, etc. I think Peter and maybe others have been working on this already as well, so hopefully we can put our heads together on this.
                  Yep! But although the advantages of this are enourmous, the implementation will be very very hard. I am not saying we should do in other way, this trully is the best way. I am just scared
                  But you are aware that the only thing we may gain from this is a MoveOrder like that gives the best path for an target and sense attackk/defensive field forces positioning when they arent attacking. What indeed is a great improvement. but do you have any idea on how to do this. Since thousands of ideas are passing in my head but any good one.
                  Have you seen my GetContinentSize function. I like it as a raw perception of the continent very useful in case of cross water movement.


                  Need to go we talk later
                  "Kill a man and you are a murder.
                  Kill thousands and you are a conquer.
                  Kill all and you are a God!"
                  -Jean Rostand

                  Comment


                  • #10
                    I too want to give the AI a better way of seeing the map -- situational awareness. The first obstacle is that there is only one way to get the AI to look at the map tiles, the GetNeighbor function. This function is a little too limited. I have some better ideas for similar but more powerful functions.

                    I gotta run too, but keep the ideas coming.

                    Comment


                    • #11
                      This project is one of the best news I have heard of since the Updater2. As far as the coding process is concerned I can't help you, I can only encourage you all.

                      I will gladly test the new AI as soon as a Beta is available.

                      Thanks to all the modders involved.

                      Note: please don't copy the cheatings of Civ3, I am not interested at all in an AI that is attacking one of my cities because it knows it is the only one that is not well defended although it should not have this information (unless it has used a spy to investigate the defence of the said city)...
                      "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

                      Comment


                      • #12
                        I'm available for debugging and general help, but actually I'm still debugging the cross water invasion stuff I've been working on. This is taking up a lot of time.

                        Also, I've got some half developed stuff on AI air tactics that I'd really like to finish off. So, I'm afraid you can't count on me to write a lot of code.

                        But, as Locutus says, the design should take top priority. There's plenty to think about here: not only what we'd like to do but also how we can incorporate it into the game engine.

                        Comment


                        • #13
                          Guys

                          Tamerlin, i guess your fears could be addressed by making the AI 'cheats' dependant on the level you play at(a bit like now where the AI gets many more bonuses on the harder difficulty settings).
                          Still i feel the priority is to get a tough game out of the AI, if it has to cheat then atleast if it plays a better game it might not be a bad thing?
                          A human player will always have an advantage just because of being human!!
                          If it's done well then letting the AI 'know' your most productive city is lightly defended might not be all bad? As long as it can make a decent evaluation of it's actions to see that taking this city is only good if it knows it can support and hold it(it has ample production to produce troops and is close enough to deliver them?).
                          That kind of thing.
                          I don't mind an Ai cheating a bit IF it's fair, like in the example above, it's upto ME to decide if i want to risk leaving my most valuable city lightly defended, not a wise decision but i may have to, its a risk.
                          Still i'm sure this whole scenario will be discussed at length - Just how do you make the CTP2 AI competitive and able to give a balanced,hard game?
                          Good luck to the coders and of course i'll be happy to help in my non-codeing way
                          'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you.info here. prove me wrong.

                          Bush's Republican=Neo-con for all intent and purpose. be afraid.

                          Comment


                          • #14
                            I can see how something will be easy to get the ai to do

                            Like

                            If they are ecotpian send a eco-ranger to kill a heavily polluting city

                            And

                            Sending an unit to free slaves.

                            But there something we can’t do without the source code.

                            But lets raise the jolly roger I am in you need anything give me a bell.
                            "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
                            The BIG MC making ctp2 a much unsafer place.
                            Visit the big mc’s website

                            Comment


                            • #15
                              Going back to Tamerlin:

                              that could be again an exploit by the human:

                              Make this city 'weak' put sufficiant troops around and you can slaughter him...........


                              For this somebody had a nice idea, I think it was MrBaggins. It would inlude some 'cheating' from the AI, but I don't know where he got with it..........It was that the AI calulated the thread in general and accordingly distibuted it's troops, the same it could do for attacking........

                              I'll try to find the threat again..........

                              Comment

                              Working...
                              X