Facilities, super facilities, and AI |
Okay, so I've made 3 different flavors of some facilities. We have the standard facility, the mega, and the super. The mega takes up 5x the space, produces 10x the resources, and costs 50x as much (but gets a maintenance break). The super takes up 15x the space, produces 45x the resources, and costs 1125x(!) as much (but gets a similar maintenance break). Now the trick is, how do I get the AI to build these facilities remotely intelligently? I took a quick glance at the existing AI and as far as I can tell, it would look at this facility, see the massive mineral output, and attempt to build it above all other mineral facilities.
I imagine it might take a total rewrite of the construction queue AI to properly manage such a facility (by first considering space available, cost and time to build, and expected return on investment). But short of starting from scratch, I thought I would ask here if anyone had any ideas first.
Re: Facilities, super facilities, and AI
Hey Mylon,
I had a similiar problem teaching the AI to use mineral scanners and system mineral scanners. The AI will always choose mineral scanners and never use the system mineral scanner.
I ended up just calling directly with:
set lng_facility_id_min_scanner := Sys_Get_Facility_ID("Minner Scanner")
set lng_facility_id_sys_min_scanner := Sys_Get_Facility_ID("System Mineral Scanner")
and in the Get_Ground_Constructions_Percentages function I just conditioned it for when I wanted it used:
if (num_mineral_facils > lng_min_scanner_cutoff) then
call Add_Facility_Construction_Percentage(lng_facility_id_min_scanner, 100, 1)
endif
For the mineral scanner it checks the number of mineral facilities on the planet against the formula that determines the minimal number of mineral facilities needed for the scanner to be worthwhile. I did the same thing with the system mineral scanner, though with different conditions. Ultimately I called the facilities directly and avoided the function to get the facility with the best ability.
-unnamed

Re: Facilities, super facilities, and AI
Master of Orion II has a brilliant design, you can built whatever you wish as far as you have the tech and resources (or credits) and output depends on population, I fail to understand why noone isn't even attempting to copy that game... it's just simple and brilliant - not to mention realistic because planets never run out of space for facilities, but population capacity yes is a valid obstacle. This would make things much easier for the AI too.
Re: Facilities, super facilities, and AI
It builds it properly for the logic I have in place right now. I'm still upgrading it. Currently the script checks to see if there is a system scanner in the system, if not, it is allowed to build one. However, it does not check queue's of the other planets in the system, so while the first one is being built, other planets may start one too. Once the first one is built though, no more are built. Enough of that problem though.
The Construction Script works more or less like this:
Under Get_Ground_Constructions_Percentages there is a case for everytype of colony (research, spaceyard, farming, etc.) Each type has its own list of Add_Facility_Construction_Percentage functions. Looks like this:
AI_STR_COLONY_TYPE_SPACEYARD:
call Add_Facility_Construction_Percentage(lng_facility_id_space_yard, 100, 1)
call Add_Facility_Construction_Percentage(lng_facility_id_storage_space_amount, 100, 2)
call Add_Facility_Construction_Percentage(lng_facility_id_ship_training, 100, 1)
Add_Facility_Construction_Percentage puts those items into a longlist (the first parameter being the facility, the second is the percent of space the facility can use, and the third parameter is the max number of that type of facility). The Construction script will then go down that long list and try to build each facility if it can. It checks what is on the ground and if there is already the max amount allowed or over the percent space allowed. If so it moves onto the next one. Each turn the list is made anew, and the construction script will go down the list checking what is on the ground against what is on the list.
What is at the end of the list gets built last, many planets never get to the end of the list (especially smaller ones). You could also put the building up farther on the list and put conditions on it. Ideas for conditions might include only build when the planet is in a core system (no enemies in system, or surrounding systems), only on planets with high construction rates, when not at war, create your own expected return on investment formula, etc. The current system already checks to make sure there is space available (for facilities, not units).
-unnamed





Re: Facilities, super facilities, and AI
Wouldn't be the game over before you ever built one of these super facilities??