Author Topic: Efficient Governors Script (updated 5/1/2011)  (Read 6204 times)

CheaterEater

  • Newbie
  • *
  • Posts: 14
  • Karma: +4/-0
    • View Profile
Efficient Governors Script (updated 5/1/2011)
« on: April 23, 2011, 01:07:14 AM »
So, I put together a script for more efficient governors. The script will analyze tech levels and choose the most efficient ratio of mines/factories/cities/space ports. It will also change the ratio as tech levels change.

These are the early versions, so I'm still working on improving the governors and making sure everything works right. I intend to keep updating it with better a build order and better usage of buildings besides the production buildings, as well as ironing out a few bugs, but this should be helpful for now. So, to install, just unzip the file and place the contents in your "Mod" folder and you should be good to go. The governors that have been updated so far are:

1. Metal planets, which are set to get as much refining capability as possible while still being able to export it all
2. Electronics worlds, which try to sustain as much manufacturing ability without importing raw materials while still being able to export it all
3. Advanced parts worlds, which operate the same way as electronics worlds
4. Economic worlds, which were changed to focus on metal, electronics or advanced parts depending on the amounts in the galactic bank. If they're all about equal, it defaults to research.
5. Research worlds, which seek to maximize the number of labs
6. Farming worlds, which seek to maximize the number of farms
7. Goods & luxuries worlds, which seek to maximize the number of goods and luxury factories at a calculated ratio
8. Militarized worlds, which seek to have two fuel depots, two ammo depots, one shipyard, one planetary shield generator (if available), planetary cannons and lasers (at a ratio of one cannon for two lasers, if available) and then enough bunkers instead of cities (if available, otherwise it defaults to cities) for all the worker needs.

All the other governors are the same as vanilla

A few things to keep in mind when using these governors:
1. No planets but farming worlds will build farms (for various reasons), so make sure to have enough food output. As long as you pay attention, it shouldn't be a problem
2. They will not be as efficient on the homeworld; they are set to use the normal planet capitals
3. Higher-tier production worlds are set to mine their own raw materials instead of importing it
4. The governors will renovate before they build anything new, to avoid shortages when they update based upon the tech level
5. The governors will automatically remove buildings to make room for more efficient layouts
6. The governors will demolish everything but the following items: planet cannons, planet lasers, planet shields, bunkers, fuel depots, ammo depots and cargo stores. Neither will they build these (except for the outpost governor), so if you want some defense, make sure to build some or modify the scripts (ask me for help with that if you need it).

Right now the script is very ugly, so I’ll be cleaning it up in later versions. If you have any questions about specific parts, just ask, as I’m more than happy to explain anything. I’ve tested the different governors a great deal, and I’ve noticed the occasional bug with ratios, but nothing too dramatic. If something big does happen, such as it getting caught in a destroy/build loop or the game crashing, let me know so I can fix it. Your tech levels and the log file are helpful for that.

Everyone is welcome to use this for any modding they do, just please don't take credit for the work.

Changelog from V1.0 -> V1.1:
-Added the militarized world governor
-Changed the goods to luxuries ratio for goods/luxuries worlds, it should no longer build way too many goods factories
-Added empire traits in, so it should take into account fast metabolism and capitalism traits as well as the happy/depressed traits for luxuries
-Fixed a bunch of conversion and signed/unsigned mismatches so that the log isn't cluttered
-Fixed a bug with how military buildings were kept on planets (the planets should build up to the right levels again now)
-Fixed economic worlds to default to electronic before advanced parts

To do:
-Add new world types for a few more situations
-A readme file
-General cleanup of the code
-Have some sort of basic defense for each planet (maybe)
-Take into account mood of workers (currently difficult due to possible flip-flopping of mood levels)
-Emergency farms in case you suddenly lose your food stocks/worlds
-Improve the default worlds
-Make use of shipyard/forge worlds or remove them entirely
-Improve AI choice of governor
« Last Edit: May 27, 2011, 09:11:05 AM by CheaterEater »

PunkiBastardo

  • Newbie
  • *
  • Posts: 42
  • Karma: +3/-0
    • View Profile
Re: Efficient Governors Script
« Reply #1 on: April 23, 2011, 09:04:26 AM »
Really cool stuff here! Been waiting for something like this.

One question though, here you say:
4. Economic worlds, which were changed to focus on metal, electronics or advanced parts depending on the amounts in the galactic bank. If they're all about equal, it defaults to research.

and later you say:
5. The governors will automatically remove buildings to make room for more efficient layouts

Does this mean that if my resources are leveled and it defaults to research and later I get a shortage on say Adv Parts, will my economic worlds start making adv parts factories to compensate dynamically for it?

Thanks

CheaterEater

  • Newbie
  • *
  • Posts: 14
  • Karma: +4/-0
    • View Profile
Re: Efficient Governors Script
« Reply #2 on: April 23, 2011, 02:35:41 PM »
Does this mean that if my resources are leveled and it defaults to research and later I get a shortage on say Adv Parts, will my economic worlds start making adv parts factories to compensate dynamically for it?

That is correct, and it will also go back to a research world after your resources level out. To explain a bit more, it checks the store of resources in the order: metals, advanced parts, electronics (I will be changing it to metals, electronics, advanced parts in the next version). If any are less than the average of the other two, it will switch to that type of world. It defaults to the first one it finds, so if both metals and electronics are low, it defaults to a metal world. If all are about the same, it defaults to a research world. I hope that makes it more clear. The turn-around time on changing resource production should be long enough to avoid any need for hysteresis for now.

PunkiBastardo

  • Newbie
  • *
  • Posts: 42
  • Karma: +3/-0
    • View Profile
Re: Efficient Governors Script
« Reply #3 on: April 24, 2011, 05:29:52 AM »
Awesome! now they behave as real governors should.

I've already been playing a bit with these governors and they work pretty good, I'll let you know if I find any bugs.

Thanks for a great script!

Panpiper

  • Sentient
  • **
  • Posts: 172
  • Karma: +12/-0
    • View Profile
Re: Efficient Governors Script
« Reply #4 on: April 24, 2011, 11:06:49 AM »
The problem I have with governors in general, and I expect the same is with these as well, is that they do not manage planets the way I would as a player. Certainly I have research worlds in that many planets will be largely devoted to just that, but even on those planets, there is some metal ore. Governors on planets not designated 'mining' worlds tend to utterly ignore that ore, so your empire instead of getting a very gradual use of all of it's ore, is instead rapidly depleting it's ore rich worlds and leaving the rest idle.

This is also wasteful of the spaceport your colony starts with. If the only thing on that world is science labs, the port is doing nothing other than importing a tiny bit of food. On the other hand, if your research world has a metal mine or two (or more in the case of ore rich worlds), that initial space port is being made good use of. Basically I build one metal mine per 25M ore available (rounding down) and an additional spaceport if necessary, and 'then' fill up remaining spaces with science labs.

Other than that standard science/metal world, I have two other types of worlds, a geothermal world and a shipbuilder world. I will have one or two farming worlds when I find a planet with dense fauna, but my ships do not typically need much if any fuel and population does not seem need much food either. As often as not, those farming worlds will have plenty of science labs in addition to farms, and the requisite metal mine or more.

In each star system I colonize, I will select one world that will be the designated shipbuilder for that system. That planet will be good for building other colony ships, defensive warships and such, and also serves as a refit station. I find it useful having one such per system. That world may in fact wind up having some science labs on it as well. I'll choose the best world in the system based on size and metal ore content. It will get the one metal mine per 25 ore, then one or two electronics and a couple of advanced parts. This is as much for the storage as for the production. The planet will also get two or three shipyards and extra spaceports. Any space left after this will go to science labs.

Any geothermal world will of course be devoted to electronics and advanced parts. However I do not specialize worlds into one for electronics and another for advanced parts. This is again wasteful of space port resources. Why have spaceports devoted to the export and re-import of electronics for the manufacture of advanced parts when there is absolutely no reason to not manufacture both on the same planet and not need the extra space ports?

My geothermal worlds will start off with metal mines again equal to one per 25M metal ore, as metal is needed for electronics, and I'd as much rather get that on planet, sparing the space ports, and thereby also not wasting the ore potential of the geothermal world. I then build electronics 'and' advanced parts in appropriate quantities so as to keep their export potential roughly equal.

I forgot goods and luxuries, as I am playing with a custom race that doesn't use them. I will have of course (in older games where I needed them) a few planets that manufacture a few of them, obviously, but those planets too would have the standard metal mines so as to not waste ore. And as often as not, they have a bunch of science labs as well.

The above is a brutally efficient use of planet space that both the standard governors are woefully incapable of matching, and the attempts I have seen from others to address the problem with automated governors come nowhere close to it either. Obviously I am having to micromanage the development of all my planets, but most typically once the planet has been colonized and I have put down the build queue, I rarely revisit it. At some point once my tech has climbed a bit, I might go back once or twice to all my planets to see if I can't scrap a city or two to free up space, but other than that, any changing needs of my empire will be handled by newly colonized worlds. If you are not expanding in this game, you are loosing.

My default governor is 'Renovate Only'.

CheaterEater

  • Newbie
  • *
  • Posts: 14
  • Karma: +4/-0
    • View Profile
Re: Efficient Governors Script
« Reply #5 on: May 01, 2011, 02:36:27 PM »
Panpiper, adding in a few metal mines per planet is very easy to do, and I can send you another version if you'd like one that has that in there. As well, my script already forces electronics and advanced parts worlds to try and make up their own metal/electronics needs before importing anything. The ship building world you describe is very similar to the construction world governor; I would suggest learning a bit of scripting and then you can make the governors do everything you want, exactly as you describe.

In other news, the script has been updated, so I encourage people to try out the new version. There is a change to build_queues.xml, so a new game is required for everything to work right. As well, I changed the numbering system to avoid some compatibility issues in the future.

exelsiar

  • Sentient
  • **
  • Posts: 105
  • Karma: +5/-0
  • A good meow solves everything.
    • View Profile
    • My Facebook
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #6 on: May 01, 2011, 09:20:42 PM »
loving the idea of this script, i'll definitely have to grab it once steam updates to the newest patch ^_^
__________________
Thats what she said..

exelsiar

  • Sentient
  • **
  • Posts: 105
  • Karma: +5/-0
  • A good meow solves everything.
    • View Profile
    • My Facebook
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #7 on: May 27, 2011, 04:35:38 AM »
I've just gotten around to trying out these governors, their awesome. though i have an issue.. the outpost governor isn't showing up :S
__________________
Thats what she said..

CheaterEater

  • Newbie
  • *
  • Posts: 14
  • Karma: +4/-0
    • View Profile
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #8 on: May 27, 2011, 09:10:39 AM »
I've just gotten around to trying out these governors, their awesome. though i have an issue.. the outpost governor isn't showing up :S

Whoops, they're actually called militarized worlds in the game. They're internally called outpost worlds in the code, so that's what I'm used to seeing. I'll fix my posts so it's clear.

exelsiar

  • Sentient
  • **
  • Posts: 105
  • Karma: +5/-0
  • A good meow solves everything.
    • View Profile
    • My Facebook
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #9 on: May 27, 2011, 09:48:53 PM »
ahh thanks muchly, had wondered why the 'militarized world' was acting a bit more optimally than normal :P
__________________
Thats what she said..

exelsiar

  • Sentient
  • **
  • Posts: 105
  • Karma: +5/-0
  • A good meow solves everything.
    • View Profile
    • My Facebook
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #10 on: May 29, 2011, 04:40:05 AM »
ive found that the Outpost/Militarized governor has trouble with getting a hold of labour. it appears that when bunkers are unlocked it scraps citys first when making way for other items, and leaves bunkers till the very end, so production crawls to a near halt as it ends up with just 1 labour :S
__________________
Thats what she said..

pixnaps

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Efficient Governors Script
« Reply #11 on: June 26, 2011, 10:16:30 PM »
Panpiper, adding in a few metal mines per planet is very easy to do, and I can send you another version if you'd like one that has that in there.

I'd welcome this too!  (Is there a tutorial somewhere for learning scripting ourselves?)

PunkiBastardo

  • Newbie
  • *
  • Posts: 42
  • Karma: +3/-0
    • View Profile
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #12 on: June 27, 2011, 06:03:24 AM »
I'd be interested too, if there's anyone willing to script it.

CheaterEater

  • Newbie
  • *
  • Posts: 14
  • Karma: +4/-0
    • View Profile
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #13 on: June 27, 2011, 11:51:10 AM »
I haven't had the time lately to work on this mod much lately, but I was working on a new version recently. I'll see if I can put it together with an option for X many metal mines per planet, or some easy way to enable it.

As for learning scripting, the scripting is done in AngelScript, which is pretty similar to the C languages. You can look up the syntax online, but most of what I've done is based on the scripts included in the game, so starting there might be a good way to see how it's done.

I'm changing the scrapping order to match the build order in the next version, so the problem with no labor should be fixed (cities will be the first built and the last scrapped).

daniwes

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #14 on: June 18, 2012, 12:37:38 PM »
I know it's a long time ago and perhaps the reason: The mod doesn't work. Whenever I have a planet that gets a type to which one of your scripts should work, nothing happens.

First I had your mod in the mod folders and secondly I tried it by overwriting the build_queues.xml with yours and adding the script file in the correct folder, but still the specific governors aren't building anything...

seronis

  • Distracted
  • ***
  • Posts: 338
  • Karma: +25/-0
    • View Profile
    • Steam Profile Link
Re: Efficient Governors Script (updated 5/1/2011)
« Reply #15 on: June 18, 2012, 12:47:32 PM »
Time isnt as big of an issue as 'version'.   The two downloads above are for star ruler versions 1.0 and 1.1 i believe.  If you are using the latest star ruler  (1.2.0) then it would be incompatible with this mod.

Jyins ministry mod is up to date and works great. You should try it out.  Its posted in the 'modding' section not the 'released mods' section though.  Page 1 or 2
Any code/mods I post on this site should be considered Public Domain. Borrow it, steal it, shred it into little pieces to your hearts content. I dont require credit but I appreciate bug fixes and suggestions.