IT IS FINISHED! (not really)
rough outline of management ai decision tree:
A. The initial prep work for a site1. town/settlement 1. town/settlement
a. general location already in place, reuse settlement algorithm
b. first building will be either shelter or food production, and can probably be hard coded.
c. placement of first buildings,
i. as discussed in the template storage thread, will be largely based on pathfinding access. a central trail through the town will have to be established to maintain connectivity to the outside world. this will be true of all types of "settlements" be they town, trade or military.
a). the ai needs to be made aware of paved roads, dirt roads and unconstructed trails
b). if the ai is going to be able to generate a long term plan for the settlement trails should be laid out to define the basic layout for the town.
ii. first buildings should be primarily made from resources that are brought with the settlers, and for this reason should be very small. tents should be erected for shelter and farm plots should be laid.
a). tents should be added as a workshop like construction, for ease of placement and construction
d. the ai needs to establish resources
i. the ai needs to be made aware of resources such as trees and stone, and be able to designate such items for gathering. it also needs to be able to keep track of the currently available resources (the ones already dug/cut). for simplicities sake on the woodcutting side, i would just have it auto designate a large area around the settlement for cutting, and mark the time it did so. a season or so after it could count the logs in inventory. if no logs are in inventory then it orders some from the caravan. the same can be done for plant gathering. stone is a harder question, with most of a players stone coming from megaproject digging and exploratory mining, and while stone is not normally lacking, that may not be the case for a human town built over an aquifer. Perhaps if boulders were ever implemented as a stone they could be gathered and used in the same way.
ii. another issues is how the ai will tally resources. Does it only count resources in stockpiles? Or does it count all resources on its “local map”? both of them provide problems, but I think only counting resources in stockpiles is a better idea, as it will prevent inaccessible resources from being counted, and underestimating your resources is better than overestimating. Job queues and constructions should be based off of available resources, and for this reason the ai should be told to make heavy use of stockpiles (the building layouts should all have large, well set up stockpiles defined in them ahead of time).
2. Combat remember that combat ai does not have to actual be smart, it just has to fake it well enough to pass
a. siege site a. siege site
i. site location is easy, your enemy picked it for you.
ii. the first buildings will most definitely be tents, followed by simple walls.
iii. first building location will be a tricky thing to figure out, as it will be based off of local site map data. i think that it is obvious that the first few "Sieges" will be nothing more than raiding parties, which can be used to build up a general idea of the map. i rather like the idea of the computer watching traffic patterns on the map to get an idea where entrances are located. i would like to expand it to include "kill zones" that the manager will forbid, so that areas around towers will be pathed around instead of through. the problem with this is that it will take quite a few casualties for the manager to get an idea of where not to go, where not to build and where not to station troops. it also does nothing to prevent the ai from building around an obvious, but unoccupied tower (accessed from the underground perhaps, and used to wipe out the camp once it is set up), nor does it really help with unused choke points, such as a map perimeter wall that is never pathed out of save for caravans. i also do not know what to do about the artificial boundary created by the map edge. what about the case where that one guy flooded the entire edge of the map with magma? will a true siege in this scenario simply be impossible? should the map be expanded by one or more local squares during a siege, then shrink back down afterward?
unfortunately building locations are going to have to be based heavily on pathing information. we can probably cheat a little and have the ai prefer to build away from things like built or smoothed walls, fortifications, ballista and catapults etc. and also prefer to fortify around roads and doors, but once those mechanics are identified they lend themselves easily to abuses. we will also have to teach the ai which constructions belong to it, which may be extremely simple, or extremely hard.
a). based on previous scouting missions, choose a location x spaces away from used fortifications, doors and floodgates (used fortifications defined as fortifications that were occupied by ammunition of some sort, and used doors and floodgates defined as being pathed over). the computer should also prefer to set up on unguarded but heavily trafficked areas, to maximize the chance of blocking access to resources and caravans.
b). when possible destroy surrounding unused fortifications, doors and floodgates. light siege equipment can be quickly set up for this, also see other threads regarding door/wall strength and damage.
1). if destroyed buildings allow access to dorfs, attack, otherwise continue with camp set up.
iv. Resources are going to be primarily brought from off map, and will be composed mostly of finished goods. building materials like wood and stone will have to designated to be collected on site, and the ai should not designate in the "kill zone." the ai should also be able to identify the materials it has gathered, and be able to differentiate between its resources, stockpiles and structures from that of the current site owner. this will prevent such stupidity as queuing up jobs in hostile workshops. a mechanism for claiming unguarded resources and workshops could be implemented, but an easy way to do so escapes me.
b. military encampment b. military encampment
since the army arc will have armies moving over the world map, they wil need a place to camp.
i. site location will more or less be determined by where the army is marching
ii. the first buildings will be tents, and possibly palisades. a simple trail or four wil need to lead out of the camp to keep pathing options open for the units ai.
iii. first building location will be relatively simple, assuming no hostiles are around. if possible the ai should choose a place on high ground. more advanced placement in hostile territory would prefer low ground, assuming the army is undetected. that may be to advanced to start with though.
iv. resources will be brought with the army, and building resources will not be a real issue, since the site is extremely temporary. possibly only wood for a small palisade would be gathered.
3. tradea. trade camp a. trade camp
i. similar to the military encampment, a trade encampment would be set up wherever the caravan happened to be
ii. the first buildings will be tents
iii. first building location will be in a convenient location, by a brook for example, or just off the road
iv. resource gathering will be minimal. constructions, even defensive, will be largely unnecessary. perhaps the guards would conduct some hunting or gathering to procure fresh food, but other than that the caravan should be self contained.
b. trade outpost b. trade outpost
i. similar to a siege, a trade outpost would be founded on the doorstep of an existing settlement.
ii. the first buildings will be housing related, as well as a trade depot
iii. as discussed earlier, on a player controlled map a liaison could request building spot for the ai. a request for a certain amount of space that the ai would stay in could also be requested, as well as future expansions to that space. placement of this site by a host ai (at a non-player controlled site) would be more difficult, but could be simplified to an x by y sized plot close to an existing building.
iv. resources, again, would be mostly external. the plot that the ai was on would be cleared, and any wood or stone gathered could be claimed by the ai. the ai may also be able to request resources from the player or the host ai. the response from this could affect relations between the entities, but that is another arc entirely.
B. expansion 1. town/settlement expansion town and settlement expansion will be largely based off what kind of settlement it is. is it a settlement formed by people fleeing overpopulated cities? is it founded to be a fortified outpost on a trade route? is it founded to claim and gather resources? a combination of the above or even something entirely different? each one of these scenarios will require its own tweaks to the management ai. i will try to list most of the basic types here. please expand on these.
a. population expansion
i. resource gathering
a). expansion of a population center should focus around food production and building resource gathering. towns like this should expect large immigration waves and the ai should be programmed to keep large stockpiles of food on hand, and keep a large surplus of housing on hand.
b). since a large population inevitably leads to large amounts of trade, other resources should also be expanded, though not emphasized.
ii. building expansion
a). the ai should emphasis building housing and food production and processing. industry should also be built, to keep the masses occupied. as a large population can easily strip and area of natural resources, trade will become essential. the ai should set aside space for a future trading outpost early on, to be gifted to a suitable guest ai. the ai should select building based on high housing and food production numbers, to help keep things fairly dense without having to have the building placement algorithm be too much of a tettris player. perhaps based on population size and number of deaths the ai could be triggered to recruit a military and designate defensive structures to be built.
iii. population management
a). population probably will not be an issue with a site like this. the ai should assign jobs on an as needed basis.
b. outpost settlement/ fortress
i. resource gathering
a). since this settlement could expect frequent siege resource gathering should be geared twords stockpiling military oriented supplies. when no hostiles are present resources should be gathered from outside the town and brought inside to large stockpile rooms.
b). a fortress or outpost would probably be relatively dependent on supply caravans, so a lot of the "nicer" things could come in that way.
ii. building expansion
a). should be geared primarily to defensive structures and housing, as well as storage facilities and military industry like forges. a trade outpost or three should also be set up, to facilitate cross border trade with friendly civs.
iii. population management
a). the population of this type of fort will be mostly military, with a large amount of artisans to support it. a few farmers/ food producers will also be needed to help maintain the forts food supplies.
c. resource outpost
i. resources gathering
a). since a resource outpost was founded because of a local abundance of a particular kind of resource, efforts should be made to gather as much of that resources as possible. other local resources should also be gathered, but only enough to satisfy local needs.
b). trade will likely bring in quite a few essentials for this settlement, but will primarily be for export
ii. building expansion
a). since this type of outpost will probably never grow very big, food production and housing should be kept fairly minimal. instead the ai should focus on trade buildings and industry. if the site is primarily focused with producing stone, masonry shops should be built to crank out blocks and stone furniture for export. minor defensive structures should also be built.
iii. population management
a). this form of outpost will focus heavily on laborers and artisans, with a small compliment of support staff and defensive military. the artisans should probably be permanently assigned, so as to maximize exported wealth.
2. military the only applicable site here is a siege site, as a military camp is inherently temporary. if a military site (siege or camp) gets to the point where it could be considered permanent, it should resort to an outpost/fortress style ai.
a. resource gathering
i. a siege site should mainly gather resources that it can use immediately, such as logs and stone for palisades, food to satisfy immediate needs for fresh food (most food should be of the "hard tac" variety imported from off site) and loot and plunder, for "export" or use. stockpile use should be at a minimum, as resources should be used as they are gathered.
ii. "trade" will mostly bee in the form of imports. no manufacture goods (such as arrows) should leave the map until the army as a whole leaves. captured valuables can be shipped out.
b. building expansion
i. buildings ata siege site should mainly consist of expanding the defensive and offensive fortifications, as well as the construction of additional temporary housing. housing should by and large only be constructed after a need for it is established, as a military camp has no need of surplus housing. expansion of offensive structures should follow the outline of the defenders fortifications, and defensive structures should concentrate on surrounding the campsite. most structures should be relatively simple, so no elaborate fully enclosed towers should be built. with that in mind a tag should probably be placed in the building raws for siegeworks. . .
c. population management
i. population is going to exclusively come in the form of immigrants. primarily of the military sort, but a smattering of artisans will also arrive. job designations should never really be changed, and the artisans that do arrive should only be of types that are immediately needed. population numbers are going to be more unstable and the ai should be able to cope with this. this all assumes that soldiers will be able to do basic work like hauling and construction when they are not fighting. if the siege is broken the ai is disbanded, the camp is abandoned and the singers flee. if the siege ai decides that continuing the siege is pointless (however it will determine that is up in the air, is it even something the management ai should be in control of?) then the invaders should pack up and take everything that isn't nailed down, including stuff from past failed sieges.
3. trade similar to military, the only applicable settlement type here is the trade outpost. if a trade camp ever gets to the point were it could be considered permanent it should resort to either a type of "unrestricted trade outpost" or a resource settlement style ai.
a. resource gathering will be virtual nil, as the area that will be occupied will likely be very limited. all resources will be brought in from off site, or donated by the hosing ai/player. the ai should be able to make requests of its host for needed items.
b. building expansion will also likely be very limited, also due to space constraints. what expansion there actually is should be relegated to housing and stockpiles for trade, as well as a few basic supplies. the housing should be able to contain temporary units (like an inn)
c. the ai will likely only have a handful of permanent units that will actually be under its control. a few guards, some haulers/artisans and some merchants of some stripe. all other units will either be under the control of the host ai or traveling merchants looking for a place to stay. as such population management should really be a "set and forget" kind of deal. oh, and don't forget about the bartender.
this whole spiel make several large assumptions about units in the future. on is that they will require food, of course. 2 is that each ai will have knowledge of its own units and resources, and be able to assign jobs that only its faction will be able to see. resource conflicts need to be solved in an intelligent way: does that stone in the middle of the field get blocked when one side assigns it to a job? or can both sides assign a job for it and whoever gets their first wins? how does the other side deal with that if they are friendly or hostile?
also i know the format is horrid, i defined things as i needed them, so there is no real template to the outline. things ar nested funny. maybe i will clean it up later, but if someone wants to go and reorder it in a more logical way i wont complain :-)
i did a quick and dirty spell check, if there is anything that makes no sence quote it and i will correct it.
edited for readability, sort of. still looks horrid. . .
edit: link to unit ai thread:
http://www.bay12games.com/forum/index.php?topic=41382.0