Announcement

Collapse
No announcement yet.

Looking for that perfect governor

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

  • Looking for that perfect governor

    Hi, all! I'm new to the forums and I've recently reinstalled ctp2. (because I love stacked combat and public works) I like the game, but after a while it gets tedious to fill every queue with a newly discovered building since I run public works at 0% and just have idle cities produce infrastructure. I'd like to just turn that over to the governor, but it tends to produce units I dont like, buildings I dont want, and tile improvements all wrong.

    I'm looking to mod the mayor (just for me not for ai's) to do the following:
    -build only the buildings I want (no units)
    -build infrastructure when it's done and check every 5 turns or so if a new building is ready
    -not change any orders I've manually put in (I think it already does this)
    -build tile improvements/terraform like I want (or if it's too hard, just not change any tiles)

    Also less critically but conveniently:
    -have a setting to produce capitalization instead of pw when idle
    -have a setting to produce attack units instead of pw when idle
    -Sell buildings I dont want (for captured cities or when all tech is researched)
    -Manage happiness and possibly other specialists
    -rush buy stuff if I have enough gold sitting around
    -Maaaaaaybe trust it to build exactly the right garrison

    Thats my dream, but right now I'm just starting and I'm having trouble wading through the text files and slc files to find out where to even start.

    Could someone direct me to where the guv' decides what to produce and what tiles to improve?

    Oops, edit: Right now I mostly play regular patched ctp, but I think I may start playing with the apolyton mod soon
    Last edited by Arkay; June 8, 2005, 12:56.
    Ford Prefect: Just believe everything I tell you and it will all be very, very simple.
    Arthur Dent: Ah, well I'm not sure I believe that.

  • #2
    I think changes such as these would need more than simply text file alterations - this would need to be done by altering the source code. Getting a better governer is something I've had at the back of my mind that I'd like to try to implement, but I doubt I'll be doing so at any time soon. It might be a substantial task, or it might turn out to be surprisingly simple - I suspect the UI side would be the biggest problem.

    Nevertheless, some changes to the game data files might have an impact, for example the build lists, which are, IIRC, somewhere in gamedata\ai.

    Comment


    • #3
      Originally posted by J Bytheway
      Getting a better governer is something I've had at the back of my mind that I'd like to try to implement, but I doubt I'll be doing so at any time soon. It might be a substantial task, or it might turn out to be surprisingly simple - I suspect the UI side would be the biggest problem.
      Actual the user interface is the easiest part, the big problem is the part inside the game. Modified governor code is already inside the playtest version. You can use the the optimize speacalist button to check how well the AI does on assigning specealists. However the behaviour is far from optimal and has some inconsitencies. I am already happy that the AI can now grow its not growing cities with the help of specialists.

      But to get the AI really doing what it should do is a huge task, one problem is that they weree no means to estimate all the falues if you do this and that for instance adding one farmer.

      Originally posted by J Bytheway
      Nevertheless, some changes to the game data files might have an impact, for example the build lists, which are, IIRC, somewhere in gamedata\ai.
      The only thing you can change about the governor behaviour via the text files are the build queues nothing else. In fact the different governors are just the build queues.

      -Martin
      Civ2 military advisor: "No complaints, Sir!"

      Comment


      • #4
        My progress so far:
        Based on a tutorial I put this code in scenario.txt
        //part of the governor project
        //Files modded: scenario, APOL_strategies, APOL_Improvement_lists
        //buildlistsequences, buildingbuildlists
        HandleEvent(NextStrategicState) 'ChangeHumanMayorStrategy' pre {

        int_t db_index;

        int_t ss_priority;

        db_index = StrategyDB(STRATEGY_GOOD_GOVERNOR);

        ss_priority = 500;



        if (db_index >= 0 && IsHumanPlayer(player[0])) {

        ConsiderStrategicState(player[0], ss_priority, db_index);

        }

        }

        Followed by this code in APOL_strategies.txt at the end which I modified from the default strat

        //part of the governor project
        STRATEGY_GOOD_GOVERNOR {

        // amount of public works (materials) to keep in reserve
        PublicWorksReserve 9000000

        // only consider building best n tile improvements
        MaxEvalTileImprovements 50

        // rounds to wait before fixing roads
        TimeToFixRoads 2

        // rounds to wait before fixing polluted tiles
        TimeToFixPollution 2

        // stored PW must exceed cost to fix + threshold
        FixPollutionThreshold 1000

        // bonus for building road tile improvements
        RoadUtilityBonus 300

        // bonus for building production tile improvements
        ImproveProductionBonus 1

        // bonus for building growth tile improvements
        ImproveGrowthBonus 300

        // bonus to apply to cells with goods
        ImproveGoodBonus 75

        // bonus for growth improvements in smallest 20% of our cities
        ImproveSmallCityGrowthBonus 100

        // bonus for production improvements in most productive 20% of our cities
        ImproveLargeCityProductionBonus 1

        // ordered list of terrain improvements that increase growth
        ImproveGrowthList IMPROVEMENT_LIST_GROWTH2

        // ordered list of terrain improvements that increase production
        ImproveProductionList IMPROVEMENT_LIST_PRODUCTION
        }

        The high public works keeps the guv from messing around with tile improvements, but in games where I've put the reserve low, it doesn't seem to use the growth2 list to pick improvements. (As a test I set it to just mega mines and it builds other things) I'm also not sure if any of the other parameters I changed have any effect?

        I was able to change what the guv builds by hijacking the science building build list (I wanted to nab the wonder list but it kicked up a fuss when I put buildings in the wonders txt) I think it also accepted mods to the building build sequence, but I got an error when I tried to make an entirely new build list (not even a sequence, just a list)

        In effect this satisfies my desire for what buildings the governor builds (minus needing to replace a list to do it) with one important exception:

        I cant get a guv to build infrastructure from a build list or a list I've manually created and loaded. (I think this is a widely known problem) and even if I could I wouldnt know how to have it stop every once in a while to look for new buildings.

        I'm sad to hear we may never get a guv to manage citizens, but I will be trying to set the %citizens to 0 (or 1 if it doesnt like that) I'm going to poke around the slic code in apol pack they used to get the ai to build economic things and see if I can teach it to terroform/improve. If anyone has ideas for getting governors to start/stop infrastructure I'd love to hear about it.

        Now a couple questions about apol pack: What is that deal at the start when the second settler goes crazy? it's hard to move him away from the first city. Also I lost the ability to terraform desert. Whats up with that? And where does the ai get all those huge stacks of units in your territory so early in the game? Yeesh!

        edit: oh and one more thing.. any idea how I could get the governor code to load mid-game? Based on how I have it now it seems to only change when I start a new game.
        Last edited by Arkay; June 10, 2005, 19:11.
        Ford Prefect: Just believe everything I tell you and it will all be very, very simple.
        Arthur Dent: Ah, well I'm not sure I believe that.

        Comment


        • #5
          Hope for progress!

          Oo! Oo! I was just toying around with the compimpsforAI slic code and I'm confident I can write a seperate routine to place tile improvements for the player. (Thanks goes to the original coder for this routine, Martin Gühmann) I was thinking of using a threshold system, where more lavish improvement projects could be undertaken as the player's stockpile of PW increases. At low thresholds, imps could put put on deserving spots right next to city borders. After a bit more stockpiling, improvements could be put on tiles anywhere in city limits. Next, undesirable terrains could be replaced. Then old improvements could be replaced by the newest best ones. Finally, all terrain could be modified to the optimum type if you had a bunch of excess pw's. A short, easy-to-understand section of declarations at the start could allow players to customize their favorite terains and desired thresholds.

          But for now, I'm curious: if you could have an automated terrain placing system, what would you want it to do for you? How do you normally handle your own tile improvements? As a side note, I dont think I could get it to place roads intelligently, but the rest could be helpful once a person's empire gets huge. Please send a couple ideas my way
          Ford Prefect: Just believe everything I tell you and it will all be very, very simple.
          Arthur Dent: Ah, well I'm not sure I believe that.

          Comment


          • #6
            I generally place food improvements on the inner ring when the city has size at least 3, and then commerce improvements in all outer rings, when they are at full usage.

            Comment


            • #7
              An ideal mayor for me would place all food improvements, terraform everything to plains and use quite a few scientist specialists, until it becomes more profitable to use lots of Shopping Malls/Drilling Platforms on outer rings for science and no more specialists.

              I doubt this is really very flexible though, applying the same rules to every city wouldnt work. Like in cities close to mountains it would require a whole different plan, such as mining, very quick growth, and not using scientists.
              Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
              CtP2 AE Wiki & Modding Reference
              One way to compile the CtP2 Source Code.

              Comment


              • #8
                Some snags

                Things are progressing well, overall (just a little slow) but I have hit a couple of snags. Does anyone know how to find out what a city's production is? Once someone has the proper techs a city will have an empty queue if someone puts capitalization or infrastructure in the queue and I'd like to have a slic routine to create pw or gold in an idle city depending on need. This will eliminate one of the key bits of busywork: switching cities between infrastructure and new buildings as they become available.
                Ford Prefect: Just believe everything I tell you and it will all be very, very simple.
                Arthur Dent: Ah, well I'm not sure I believe that.

                Comment


                • #9
                  Well the easiest way is to remove capitilsation and infrastructure from the build lists sequences. That way the builds units to strengthen its millitary.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • #10
                    Just a little status update: right now CTP2 is out of style with me (SMAC, baby!) and I'm not working on it, but I may pick up again in the future. Also, sadly, I was playing a game with pollution and realized it was completely neccesary to manage your own specialists, as the governor does not do a good enough job. Since the specialists cant be managed by macro, this means that it is no longer feasible to make an automatic governor. Thus the scope of my project has changed from an auto-governor to an automatic tile improvement and terraforming system.

                    Happily, I have found a couple features that break up the monotony that I was concerned with. Under the F2 production menu, all cities can be sorted by a few properties: most importantly time to production completion and item being built. From this menu, multiple cities can be selected at once and production can be hurried (a grand total is available right on the screen) or the production queues can be changed. The production menu change is a little obtuse: you can only completely overwrite a queue by making a queue and pressing the overwrite button, or by loading a pre-made queue (which also overwrites everything in favor of the loaded queue)

                    Changing the queue of 10 or more cities can cause a stall of 1-60 seconds depending on number of cities and queue complexity, but it's still tons better then editing the queue of all cities one by one. For example: If it is later in the game and 47 of your 60 cities are producing an orbital science facility and you discover arcologies, you can select those 47 cities by sorting by the production item, then make a build queue that has the orbital station and then the arcologies in it and select overwrite. Wait while it chugs away for a bit and presto! The queues are modified without 10 minutes of micro, and you didnt lose any production to a switch.

                    You can try making a 'master list' that you just load up at all your peacetime cities once one of them goes empty, but the list has trouble with prerequisites. That is, it would queue an acadamy, but not a university (because it's not buildable without an acadamy) and then a mill or something like that, and you may lose some production if the mill is being built and you reload the list which would switch it to a universtiy.

                    I may still try to write a routine that gives empty cities the right amount of pw or gold if they are empty and you have the right tech, but this is slightly less important to me now that I have noticed infrastructure only gives half as much as 100% pw tax. These days I dont usually rely on finishing all projects in my top cities and then using infrastructure instead of a pw tax for that reason.

                    I do actually have a pretty-much working version of the auto tile-improver. It doesnt work exactly as I'd like but it's pretty good. Its for the apolyton pack, so if anyone has any interest I could upload the current version.
                    Ford Prefect: Just believe everything I tell you and it will all be very, very simple.
                    Arthur Dent: Ah, well I'm not sure I believe that.

                    Comment

                    Working...
                    X