Creating AI for Cossacks

Discussion in 'Fan Zone' started by Ftoomsh, Sep 9, 2015.

  1. Ftoomsh

    Ftoomsh Well-Known Member

    I hope to start a discussion about AI. I notice this section refers to "Share your creations with the community".

    In that spirit, what work have people done in AI in Cossacks, RTS or other fields? Years ago, I wrote a program in Pascal which played chess. I haven't done any AI work in Cossacks but I would like to at some point. Has anyone programmed any AI for Cossacks or any other RTS game? If you have, please let us know what you have done and how well it worked out. I would like to kick around some RTS AI ideas for Cossacks if we can get a discussion going.
  2. Commodore

    Commodore Active Member

    I think it might be fun if the AI had names that reflected their style of play. So instead of "computer 1" you could choose to play "ultra camper" for example, who would create a strong base and play ultra defense. Or play "Kamikazi" who would attack immediately. Someone with more historical knowledge could work up some more different styles based on historical war leaders perhaps.
  3. Snuffy

    Snuffy Active Member

    I want an AI that isn't smarter than I am. I do not want it to be able to scan the map, locate me and then make a beeline toward me. I think AI should be blind in that regard as I am. AI can only see as far as the line of sight permits and once that line of sight breaks over an enemy placement, it decides what to do from there.
  4. [KGR]-^K[o]K^-

    [KGR]-^K[o]K^- Moderator Staff Member

    Hi, I agree, also it would be nice to add more options, for example:

    AI build:

    Standard (AI plays normally)
    Any build (AI chooses from all available builds)
    Full rush (AI chooses from all rush builds)
    Timing attack (AI chooses from all timing builds)
    Aggressive push (AI chooses from all aggressive builds)
    Economics focus (AI chooses from all economic builds)
    Straight to ground units (AI focuses on creating ground units as quicly as possible)
    Straight to ships units (AI focuses on creating ships units as quicly as possible)
    Straight to ground and ships units (AI focuses on creating ground and ships units as quicly as possible)

    AI Difficulty:

    Very Easy
    Medium = Normal
    Very Hard
    Cheater AI 1 Resources
    Cheater AI 2 Vision
    Cheater AI 3 Insane
    Furious Peasant and Ftoomsh like this.
  5. Ftoomsh

    Ftoomsh Well-Known Member

    I agree. An advanced AI could incorporate both styles and difficulty levels. Snuffy also makes an extremely good point which I have made previously and that professionals of AI design have made: namely that the AI must not cheat and must only have access to the same information that a good human player would have.

    "Specifically, the agent should not be allowed to utilize any game state information not available to a human player, such as the locations of non-visible units, and the set of actions provided to the agent should be identical to those provided through the game’s user interface. Enforcing this constraint ensures that an agent which performs well in this domain is capable of integrating and specializing in several competencies." - Building Human-Level AI for Real-Time Strategy Games - by Ben G. Weber, Michael Mateas, Expressive Intelligence Studio, UC Santa Cruz & Arnav Jhala Computational Cinematics Studio, UC Santa Cruz.

    Thus a good AI agent would have to have good scouting algorithms (among other things). It would have to scout well and would then react to what the human player is doing. This requirement to scout and react will move the AI Agent away from a blind script mode into a reactive, evolving mode. Learning AIs are even possible and some don't have to be all that sophisticated although some can be of course.

    If people want to start out thinking just a little technically, I will add the following and keep it as short as I can.


    The C1/C3 game model in some respects is actually very conducive to making good AI. This will be even more true if C3 removes reverse trading from the market. The main reasons are as follows;

    1. The C1/C3 economy (not counting reverse trading) is an economy that is relatively non-reactive to the evolving tactical and strategic situation. What do I mean by this? I mean that the economy is quite linear with its building dependencies and its development. Thus the standard building path is clear and not all that much affected by enemy building choices nor by enemy tactics. The enemy too has to follow this linear building path. The inflation cost model of C1/C3 buildings further entrenches this linearity. The inflating cost of barracks, for example, soon make it clear that a first stables is a better option that a 3rd barracks. This linearity means the resource and production problem can be solved at least semi-independently from the evolving army tactical and strategic problems.

    2. There are no air-forces. Apart from the scout balloon there are no forces in the air. This removes an entire layer of complexity which WW2 RTS games, or later games including futuristic games, must contend with.

    3. Speed disparities for units, even on the ground, are much less than in later era games. This again reduces algorithmic and heuristic complexity.

    4. High unit numbers. This is counter-intuitive but high unit numbers actually simplify some aspects of the strategic equation. It would take a long, complex discussion to fully explain why. Suffice it to say that the potential to get to high unit numbers makes the game less tactical and more strategic as the unit numbers rise. When unit numbers are low tactics are critical as are execution of tactics (micro). When unit numbers are high, tactical finesse (and fancy tactical plans requiring extensive heuristics and feed-backs) mean less and strategic management of forces means more. Large forces can be managed logically in a more algorithmic fashion using force concentration, internal lines, defense geometry and so on. Defence geometry refers to issues like fields of view, fields of influence, potential attack routes, military center of gravity and resource center of gravity. Many of these requirements could (at least in theory) be inter-related by equations. What is more, the equations can be re-weighted by extensive testing. (I envisage different versions of AI playing each other over and over in test games whereby the winner's and loser's heuristics, algorithms and evaluation function weightings are noted and adjusted incrementally for success or failure. This is just one example.)

    None of the above is to say that good AI will be easy to make. It won't be. We can continue this discussion if people want to get into some more nuts and bolts. A good point to start is to discuss how tree-search algorithms will NOT be able to provide the solutions that they do in games like Chess. RTS has a far more complex move-tree and vastly more possibilities than a chess game. At the same time, I believe (for example) that tree searching for efficient builds (on their own) will still be possible to some extent. This is for the very reason that C1/C3 non-reverse-trading builds will be relatively non-reactive to the military equation which can almost be treated as a separate problem. I say "almost" because there will need to be some feedback from the Military Manager Module to the Resource Manager Module to help prioritize the decisions on military upgrades compared to economic upgrades.
    Geiserich and Loner like this.
  6. Nowy

    Nowy Well-Known Member

    I am sorry but these looks like useless proposition. More options never improve AI when basic things are spolied.
    When there are many insane glitches more options only can expand bad things isn't it. So, main thing is create well basic things which will exploit AI. National specific for strategies, tactics, order of battle, build order, army composition, units statisitcs and weapons representation are basic things I suppose.

    Then options easy, medium, hard and very hard would be enough.
  7. [KGR]-^K[o]K^-

    [KGR]-^K[o]K^- Moderator Staff Member

    There might they improving the AI to infinity and you'll still know it's AI, if AI does not think like a human. If they do a really good adaptive (flexible) AI, which may well react to what you are doing.

    If it were up to me, I'd AI by real players, like in Starcraft 2, "AI build" is such extensions, which is actually from the best players, what i mean ( building construction, creating units, and timing attacks)

    For example: AI build: Full rush
    AI just builds, doing units and attack as a real player, there is not just one BO (build order) or just this one a mix of units. AI knows all the build orders, mix of units, and timmings attacks. AI will randomly choose one of the ten "full rush" BO, and accordingly makes the units and attack at a specific time.

    It's probably the best way, how to improve AI.
  8. Ftoomsh

    Ftoomsh Well-Known Member

    That is one way to make better AI. Give it good attack heuristics and attack window heuristics. And in your suggestion for AI styles, this will be a rushing or attack AI.

    There will also be another fundamental way to make the AI play well. This would be to make a defending AI which uses accurate internal lines defense. There is every possibility that a very mathematically and geometrically accurate defensive AI could be made. This would revolve around adopting almost pure defense for a long period. Thus it would seek to grow its economy as fast as possible, to make resource upgrades before military upgrades, to post out sight-range scouts and to keep the main army concentrated well within the sight range. This is termed "internal lines" defence in strategic military terms. It is technically the most accurate way to play, rather than seek to rush or make timing-window attacks.

    Why is this method technically more accurate in the strategic sense? It keeps the main army near the main resource base and always defends it. It depends on internal lines and short reinforcement lines. This means it will always have more troops at each battle site (as the enemy attacks with long reinforcement lines) unless it gets fooled about the incoming main attack direction and thus ends up with a main force out of position. How would it ever go on attack? What it would be programmed to do would be to count its own troops production and estimate the enemy troop production. It would do the latter not by cheating but by making reasonable estimates. Because of the inflating cost model for buildings it pretty easy to guess enemy troop production (although if the game allows fast diplo mercenaries this makes such estimates trickier). It would also accurately count casualties. Being a program module it can make completely accurate counts of deaths at all battle sites.

    If it plays accurately using internal lines and short reinforcement lines it should have superior numbers at each battle site . It should attrit the enemy faster (cause more casualties) by winning these battles. From the casualty numbers and total production estimates, it will estimate how much bigger its remnant army is compared to the opponent's remnant army. When it decides the disparity is great enough it will go on the attack.

    If an opponent never attacks when it is in this mode, it will simply continue to build up to maximum numbers and maximum upgrades. Then it will seek to slowly expand influence and sooner or later provoke battles. It will always seek battle where it calculates it holds a terrain advantage or local numerical advantage or some other tactical advantage like more cannon at a major battle site. It will always decline the engagement and melt away when it determines it is at a disadvantage. One thing it will be is inhumanly patient. It will also suffer no fatigue or thought-clouding emotion like a human player can. Properly programmed, such an AI would be tremendously difficult to overcome. However, for the top human players it would still be interesting because the key to beating it would be indirection; using feints and other such strategems to fool it. There will also be subtle positional and terrain influences on strategy which an imaginative human player will always understand better than a computer AI. But if you fall into the trap of making piecemeal rushes and piecemeal attacks it will bleed your army dry and then attack when you have little army left.

    As a final note, it would not be inconsistent for this above model to make early raids or later raids with minimal forces just to test and probe the opponent and maybe do some cheap damage. But it would never risk its main army until it calculated it had an overwhelming superiority.
    Last edited: Sep 18, 2015
  9. [KGR]T-yph]oOo[n

    [KGR]T-yph]oOo[n New Member

    As there are already a lot of good inputs, here is the only one i would like to add:

    * The hardest AI-level was still very weak. As someone else mentioned, there could be done at least some human build up from an experienced player (like KGR catweazel or 1nt VRV or or or...),

    From my point of view: i played single-mode-campaign just 2 times or so before starting to play online. Are there really so many people that care about AI at all? If your budget is low, removing the online-bugs might be the first to do.
  10. Nowy

    Nowy Well-Known Member

    Did you ever noticed that C1 game bought 4 million customers and how many players did you met in MP scene?
    I am certain you never met all these customers playing on-line games. There you can met only loudly minority.
    This can suggest that silent majority customers bought C1 for single player mode.

    So, it looks that many of them were interested in SP games where AI is very important.
    Last edited: Jan 25, 2016
    Loner likes this.
  11. [KGR]T-yph]oOo[n

    [KGR]T-yph]oOo[n New Member

    Thank you for your update.
    Alright, so there should be a bunch of improvements.
    Nowy likes this.
  12. [KGR]T-yph]oOo[n

    [KGR]T-yph]oOo[n New Member

    How many of this ~4 million single-players are in this forum now?
  13. Nowy

    Nowy Well-Known Member

    There are less than 1,000 members and many are not active now.
    So, it is hard to say how many single-players are in this forum.

    Nevertheless you can notice that silent majority of 4 million customers were not multi-players.
    This could mean they were mainly single-players, therefore creating good AI for the game is important.
    Loner likes this.
  14. Loner

    Loner Well-Known Member

    I'm here.:p
  15. Daddio

    Daddio Moderator Staff Member

    The AI is one of the truly new and updated aspects of C3. They have stated that the AI is all new, and nothing like the one used in BTW.

    As to the importance of whether single player or multiplayer are more important, there is no answer only opinions.

    My opinion is that they are both important. They both make the game better with their input. And they both support the game and as such make the game available to all of us.

    If the developers did not show strong support for both factions, surely it would fail. Causing a lot of disappointment in both factions.
    Loner likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice