AI coding overview

Discussion in 'General Discussion' started by Sithuk, Oct 15, 2016.

  1. Adam Solo

    Adam Solo Developer Administrator Grand Admiral

    Posts:
    4,846
    Joined:
    Sep 9, 2016
    I see what you mean, but it's tricky, because they are playable races. As you say, this would work easily with NPC races, but that's not the direction that we're taking here.

    However, it's still a helpful thought on how one could disperse bonuses throughout the game, giving little spikes of advantage, instead of giving a constant +X% to Research since turn 1.
     
  2. Neil

    Neil Ensign

    Posts:
    30
    Joined:
    Oct 20, 2016
    Fair point. One question. Have you considered providing support for users to create their own AI modules for the game? I assume the design is quite modular and the AI modules will interact with the game via some defined interface, so you wouldn't need to expose too much of the games internal workings. Of course, I fully understand if you wouldn't want to allow this.
     
  3. Adam Solo

    Adam Solo Developer Administrator Grand Admiral

    Posts:
    4,846
    Joined:
    Sep 9, 2016
    No, that's not envisaged right now. However, we'll see if there are parts of the AI that we can expose via XML files that could be tweaked to influence the AI behavior. We'll figure that out as we go.
     
    Last edited: Oct 27, 2016
  4. dayrinni

    dayrinni Ensign

    Posts:
    45
    Joined:
    Oct 14, 2016
    FYI, Paradox Games usually expose some of their AI via LUA. May be something to consider :)
     
  5. aReclusiveMind

    aReclusiveMind Developer Grand Admiral

    Posts:
    3,040
    Joined:
    Sep 24, 2016
    I don't envy 4X developers when it comes to creating a balanced AI. This is a task even the best in the business still struggle with in the eyes of the players. It seems likely nearly every other genre gets off a bit easier in this regard. Hopefully we can all play a part in making suggestions and in letting our voice be heard during the pre-release period to assist with plugging the holes we find in the AI.
     
  6. Neil

    Neil Ensign

    Posts:
    30
    Joined:
    Oct 20, 2016
    OK. I was thinking more along the lines of, say for example, a user written dll, which would interact with the game via some well defined interface. This would enable users to experiment with arbitrary AI methodologies and, if they achieve good results, provide these back to the community. Anyway, looks like the answer to my question is a no. Which is fair enough!
     
    • Agree Agree x 1
  7. Neil

    Neil Ensign

    Posts:
    30
    Joined:
    Oct 20, 2016
    I have a lot less sympathy for huge developers, like Firaxis, which have the resources to employ a team of AI experts to devote man-years to the task, yet deliver AI which has hardly advanced since Civ 1.

    Other genres, for what ever reason, seem to make a lot more effort to keep up to date with research and treat the AI as something important. In the RTS genre, there has been definite improvements to pathing, due to developers actually bothering to read up on research work. And not just utilising improved pathing algorithms, but even exploring more experimental approaches such as gestalt behaviour and flocking.

    It seems to me that the 4X developer community, on the other hand, are happy to stay in the dark ages with regards AI.

    Please note again, that this criticism applies to so-called triple A developers, who have the resources to at least make an effort.
     
  8. IvanK

    IvanK Lieutenant

    Posts:
    138
    Joined:
    Oct 17, 2016
    That's how I do it in my pet project :). The code is divided in two major C# projects: game core and user interface. Core has all of the business logic of the game and interface for interacting with it, it's basically model and controller from MVC pattern. User interface is view part of that pattern. So is the AI plugin project, it too "sees" the game through same controllers as human's UI. The difference between the two is that AI assembly is much thinner, with only AI's game playing logic while user interface project has to cover all the administrative stuff like settings, loading plugins, starting game, saving, loading, etc.

    It's not so difficult to do IF you divide the code like in MVC pattern and you can leverage all the goodness about C# (great IDE, powerful strictly typed language which won't blow up on syntax errors during runtime). Unfortunately Unity3D likes to tempt developers to put game logic on the display objects and discourages the usage of namespaces which may challenge disciplined code architecture.
     
    Last edited: Oct 28, 2016
    • Agree Agree x 1
  9. Konstantine

    Konstantine Grand Admiral

    Posts:
    2,200
    Joined:
    Oct 19, 2016
    There is another way to handle this.
    Granted the work, focus and resources available in creating the AI is key but you can create a great game even if your AI is only competent at best.
    Events.
    If used correctly, events (randomized but with predetermined triggers) could easily assist the AI in creating a satisfying game experience for the player. The trick is balance as in all things. No event should cause rage quit but should present the occasional un-planed for challenge that will throw some good obstacles at the player.
    Barring a full 4x campaign, a number of events (from minor to major) can allow the developers to create a sandbox 4x that cannot be easily beaten as the player will have to react at times to threats that were not anticipated.
    The idea is to level the playing field as needed, not make it impossible to win.
     
  10. gja102

    gja102 Cadet

    Posts:
    26
    Joined:
    Oct 27, 2016
    Thanks Adam, glad to see you "get" it in regards to the difficulty curve. It's quite telling that one of the earliest user mods for Civ 6 is called "Smoother Difficulty" (to quote the creator - I didn't like that the AI got insane bonuses at the start, which meant the #1 way to lose a game was to just get DoW'd in ancient or classical and get killed by more units than you could possibly handle. This mod smooths the difficulty curve of the AI, so now they have about the same start you do, but get better constant bonuses so they can keep up with tech and production throughout the entire game.) So the lop-sided cheating is clearly an issue across the 4x genre.

    The ideal end result is an AI that feels like the same kind of challenge as a competent player would. I wonder if it would be possible to create some kind of save game analysis tool, that measures the amount of infrastructure, colonies, and military that a player has at each point of the game - and use that information to structure the AI cheats. So a top level AI would be getting handouts to put it on a par with a top level player, etc etc.

    Although handouts work well for shoring up strategic AI, I can't see an elegant approach to boosting the tactical battle AI in such a straightforward way. That's one area where you might need to consider *slight* but brazen AI cheating in terms of to-hit bonuses, etc. Because although it can be frustrating to face "superhuman" opponents, it's probably preferable to having situations where an outgunned human can effortlessly carve through waves of AI ships.
     

Share This Page