Windyplains 说:
Setherythe 说:
Could you point out the relevant python file in native where the campaign AI behaviour is coded, so I can better understand the existing conditions for hiring/spending decisions of the AI? And then I'll develop/share some ideas (this would help me learn some things to start my own mod too, so I'd do it gladly).
Probably the most central part is "
script_decide_faction_ai" found in module_scripts.py. Though I will say if you're brand new to using the module system this is not a great starter script to learn from as it is very long and somewhat complex. The "reference book" of the module system can be found in header_operations.py for most commands and header_trigger.py for triggers specifically. The system itself isn't python, even though you have to install that, which is used to translate the module files into text files. The module system language is fairly readable and fun to learn once you get a few basic concepts down. Caba'drin's
introduction to the module system syntax really is the best place to start for picking those concepts up.
Technically, yes, this seems to be the central part for faction AI, thanks; but I think the AI we should consider for building orders would be more suitable to integrate into
插入代码块:
script_troop_does_business_in_center
. But I wasn't planning to get into the code and syntax myself, merely to put forth something plausible in "pseudocode" and analytical style, as per Caba`drin's request.
Now, my general ideas (AI-wise):
Note: in the below, "order" is used to designate any society/guild/troupe envisioned by OP
1. AI decision to build an order
1.1 Discussion
This could be either a faction object, or a lord's object. Let's consider the pros and cons of either approach
a) If it's a lord's object: PROs - can decide this simply by adding a decision 'checklist'
插入代码块:
script_troop_does_business_in_center
, that is, we only need to worry about whether the lord in question wants to found an order, has the money to, is in a city where he can (probably defaulting to one that he owns, or a friendly town for lords that do not have a town fief, in the AI's case); CONs - excessive amounts of orders could theoretically spawn if this is not balanced properly (the cost for the order has to be sufficiently high, lord's reputation with the town should be taken under consideration or somesuch serious limitations to ensure that most lords will not be able to start a knightly order)
b) If it's a faction's object: PROs - there will at most ever be 6 orders in addition to one potential player founded order; also, this could be decided in the same manner as accepting peace with reparations: does the king have money, does it suit the current global needs of the faction - e.g. does the faction need more military might? - which would be the case if the faction's AI state is currently set as offensive or defensive campaign. CONs - (i) these would spawn almost at the very beginning of the game, so long as the faction is in any sort of war - might as well start the game with them already constructed in the faction capitals (the king owned towns); (ii) it would be somewhat unbecoming for the player to found one before he/she is at least war marshal if not leader of a faction when as far as the AI is concerned, it can only do so by faction decision.
Personally, I'd go with a), because it suits the spirit of Ogrecorps's suggestion - notably, that a knight/warrior should be able to found a knightly order/warrior society, regardless of nobility.
1.2 Suggestion - in pseudocode
note: operated/called from within
插入代码块:
script_troop_does_business_in_center
, where other 'business in center' is also called from, namely courting, recruiting, and collecting taxes.
Center is a city?
if Y: Center is the party leader's city?
if Y: Party leader meets conditions for wanting and able to build order? (I really don't care so much about the actual conditions, someone else fill in these
blanks, they should be the same conditions as for the player as much as possible; Ogrecorps's and Deis's suggestions are quite good for filling in the
blanks here in terms of "able to build")
if Y: does this town already have a chapter house of the party leader's order?
if Y: Can't build.
if N: Start building!
if N: Cannot and will not build an order in this center
if N: Center is a friendly city AND liege of center is a friendly lord? (numbers should be played with and balanced for rarity of order spawning, probably a
50+ relationship with lord, and a 10+ relationship with city would be sufficient... if these numbers even exist for AI lords, which I'm not sure they do,
so if they don't, then default to considering whether lord counts as 'friend' and city is part of same faction as the party leader)
if Y: Party leader meets conditions for wanting and able to build order?
if Y: does this town already have a chapter house of the party leader's order?
if Y: Can't build.
if N: Start building!
if N: Cannot and will not build an order in this center
if N (to both friendly city and friendly lord conditions): Cannot and will not build an order in this center
if N: Cannot and will not build an order in this center
Define "Start building!" => A given amount of money is reduced from party's wealth, and all martial lords (and honourable lords?) in the party leader's faction get a boost in relationship with the party leader; a timer for the construction of the order's chapter house is set; party leader becomes master of order; order is named according to a random mix of two words the first from an adjective list, the second from a noun list, perhaps limited by culture considerations, if not too much trouble.
2. AI decisions on troop tree design for order
2.1 Discussion
Since the point for the player is customizing troops, the point for the AI founded orders should be the same. Customization allows for a set of troops that would enrich the player's army balance and tactical possibilities, but for the AI it should also be limited by cultural-tactical preferences. To simplify things, there should be a tactical theme for the AI founded order basically creating a troop tree with increasingly better troops of pretty much the same type (so ranging from, say, an order recruit that is an archer to an order elite that is also an archer; or from an order recruit that is a blunt melee troop to an order elite that is also a blunt melee troop - the quality of weapons, shileds and armour increasing with each tier of the tree, as do the attributes, skills, and proficiencies); or the AI could pick from among a number of templates. Mind the cultural limitations! Khergits Noyans would hardly ever pick to found a chapterhouse based on an infantry template, or Rhodoks on a cavalry template, etc. Also, the templates would be adaptable to cultural item selection - so for example, if the template specifies mail for the tier 4 troop, when a Sarranid AI lord picks to implement the template, the mail will be Sarranid mail; imodbit 'guarantees' can be used for the highest tiers, so that the highest troops of the order will have knightly or master-crafted stuff only. Anyway, this should be discussed by someone with suggestions for template design, I'm just gonna suggest how the AI uses such information. It would make sense that the AI would build an order corresponding to the current troop distribution in their party - so that either the AI will want to specialize the party (i.e. if 50% of party is infantry, well, pick an infantry themed order troop tree), or supplement a lack therein (i.e. if 10% is cavalry, pick a cavalry template to boost that proportion).
So technically, yes, the troop trees would be premade - a good number of them, which requires a lot of work, but I think far less than actually programming the AI to pick each item of equipment and each attribute/skill/proficiency for each level of the order's troop tree... Doing so randomly would be easy, but doing so with some degree of artificial "intelligence" would be an insane task.
2.2 Suggestion - in pseudocode
(this script is triggered when the first chapter house is built, regardless of where the order master is)
Get chapter master's faction
Consider troop composition for chaptermaster's party (get % infantry, % archers, %cavalry)
Randomly choose between specialization or diversification (consider that specialization means picking a template favouring the troop type with highest %, and diversification means picking a troop type with the lowest %,
so this randomization returns one of the three
)
Using
and
, select the first template that matches both by using a try for range loop or some such to consider whether the templates fit the need.
Adapt template to cultural equipment.
3. AI decisions on troop recruitment/upgrading - including order troops
3.1 Discussion
Let's consider what recruitment into an order means. Basically, this depends on the nature of this order. If, like the historical crusader orders, or a thief's guild, the membership criterion is ideological (religion, or willingness to convert to religion, or the (im)moral prerequisite for commiting crimes), then recruits are apprentices, in no ways skilled in the ways of the order. If, like the Special Ops forces of various countries today or a fantasy-RPG stereotyped assasin's guild, membership in the 'order' is on the basis of ability and skill, this means a recruit is already a force to be reckoned with. I would suggest the former be true for all orders, because it simplifies things in terms of who can hire, and when can they hire.
(Alternatively, if we like complicated, there can be two kinds of orders - ideological and skill based orders; for skill-based orders, recruitment is moot: you wouldn't recruit order members, you would upgrade your high tier levy troops into order members, so for example, a Swadian Knight could be upgraded into a Knight of the Thundering Steed, then into a Sergeant Knight of the Thundering Steed, etc.; you would only have access to these upgrades if you are the order master.)
Now back to simple. If the order's lowest tier troops are apprentices of the order - so basically peasants that have been inducted to learn the ways of the order, and thus are no better than levy recruits (e.g. Swadian recruit, Rhodok tribesman, etc.) - then the recruiting is theoretically done through the order: the commander wanting to hire order members would ask the order to provide some fresh men from their order, and the order would give him a number of apprentices with a much smaller number of journeymen or the order who could instruct these apprentices in their development. So, you would never get only recruits, but rather a proportion of tier 1 troops to a proportion of tier 2 troops - let's say 5:1. Recruits are available in the same number as levy troops, because, basically, instead of the commander taking a peasant and telling him to get whatever weapons he has ready and wear his colours to war, the order is taking the same peasant, giving them the order's standard equipment for his tier, and sending him to fight under that commander. So practically, the AI lord is picking to recruit from a pool of available recruits in any village that is associated with the town with the/a chapterhouse, and the AI lord is either favouring levy recruits or order recruits.
3.2 Suggestion in pseudocode
(this is triggered under the
section of the existing
插入代码块:
script_troop_does_business_in_center
)
Is party leader on recruiting business in a village associated to a town (as opposed to one associated to a castle)?
If Y: Is that town housing the chapterhouse of (at least) an order? #see how this gets complex with multiple chapter houses and multiple orders spawning
chapter houses all over?
If Y: Is the party leader the chapter master?
If Y: The party leader will recruit between 50% and 60% (randomly) of available recruits as order recruits (e.g. Neophyte of the Thundering Steed),
and the rest as levy recruits (e.g. Swadian recruits).
(optional: even if not the order master, a party leader who is of honourable personality will be happy to have members of an honourable order join
him/her; this additional condition dould be implemented, but would require that the order have an honour rating, most likely one equal to the master's
honour rating).
If N: The party leader will recruit between 0% and 10% (randomly) of available recruits as order recruits, and the rest as levy recruits.
If N: The party leader will recruit 100% levy recruits
If N: The party leader will recruit 100% levy recruits
4. AI decisions on order master prioritizing the defense of chapterhouse(s)
Basically, if a chapter house is under siege, how will the order master react? Considering that the loss of cities is a serious threat, and that the faction AI already takes city defense very seriously, the whole faction would probably be defending any given chapter house indirectly, mainly because the defense of cities is super important. So I wouldn't worry about actually making any AI determinants for whether the order master should rush to the aid of his chapter house(s)'s towns when they are besieged, because either the faction will take care of it with a serious army-wide campaign, or his party alone won't be able to make a difference.
Well, I'm done, for now. Hope this helps.