Page 1 of 3 123 LastLast
Results 1 to 30 of 72

Thread: How to improve the tactical AI

  1. #1
    Senior Member Senior Member Cheetah's Avatar
    Join Date
    Dec 2001
    Location
    Hungary
    Posts
    2,085

    Default How to improve the tactical AI

    The weakness of the tactical AI is an ever returning problem. What I would like to do here to get some ideas together how to improve the situation. I have been playing the TW series ever since Shogun and I am a bit afraid to say but the tactical AI seems to be the weakest in MTW2 (though I have to add that I have not played RTW SP that much). First of all one have to find the reasons, second we have to find a cure.

    I suggest the following reasons: (a) variety of unit choice, (b) bad composition of AI armies, (c) wrong priorities for the tactical AI.

    (a) Variety of unit choice: thinking about the weakness of the tactical AI Shogun often came to my mind, for the obvious reason that SP battles seemed to be much difficult and challenging. Thinking about the reasons I came to the conclusion that there are two major factors: (i) restricted availability of cavalry, (ii) same –and restricted- unit roster with AI.
    (i) Cavalry needless to say favours the human player as the AI is unable to do the same cav tricks as the human player. In Shogun especially in the early stages armies were composed of only yari samurai and samurai archers (you had to have the master swordsmen event to get nodachi, and all types of cav units were further down on the road). I remember that as Shimazu I fought the Imagawa armies with only YS and SA, often my armies were only 4 or 5 units strong (and that was much!). I still remember that in my first battle vs. Mori my YS/SA army was soundly defeated by a nodachi heavy Mori army (and I had to restart the campaign realising that there is no way that I can beat that nodachi heavy army with only YS/SA). As opposed to this scenario high quality cavalry is highly available for the human player early on (jinettes, magyar cav, hunagrian nobles, vardariotai, kazaks, dvor, all kind of knights). There is hardly a faction with which it would be difficult to field a cav heavy army even in the early game. Needless to say most of the players are happy to live with this opportunity and soundly beat the militia/archer heavy AI armies with their choice of cavalry.
    (ii) The variety of available units also favours the human player. Not just because it includes all kind of cavalry but because it is not hard to find a counter unit to the actual AI armies. Some factions have elite archers or elite infantry early on, it is not difficult to field superior armies compared to the AI even if someone would restrict himself/herself to inf heavy setups. As opposed to this in Shogun human and AI were fighting with the same units: YS and SA, there was no way to gain the upper hand in the quality of troops, and often AI factions got the elite units first (Mori: nodachi, monks, Takeda: cavalry). As a side effect, but important one, the AI could not go wrong with its army builds: it could produce only YS and SA, same as the human player. As opposed to this in MTW2 the AI can build all kind of silly armies and unfortunately too often it lives with this choice. This leads to our second point.

    (b) Bad composition of AI armies. The AI often mass produces armies of cheap units even when it has all the city/castle upgrades to produce high quality units. For example in my recent Hungarian campaign I too often had to beat spearmen/ byz inf/militia garrisons in Byzantine Citadels’ that had fully upgraded barracks, stables, archery ranges. The Byzantine Citadels’ were better upgraded than mine (actually Barn was only a Fortress) yet I had higher quality troops (FK, DFK, Hungarian nobles) than the poorly manned garrisons. Also the AI will often mass produce any unit available in its cities. So, for example if a city can train militia spearmen and catapults then you can bet to meet AI armies composed of these two units without any archer or cavalry supporting them.

    (c) Wrong priorities for the tactical AI: The AI often either tries to mimic aggressive cavalry tactics with the result of losing all of its cavalry leaving its infantry/archers open to be flanked/surrounded by the human player, or remains utterly passive to be shot to pieces.

    Cure:

    (a) Well, there is not much cure for this. CA will not decrease unit choice and it would be naïve to expect human players to stick to town militia to give a fair fight to the AI. It is a kind of an unfair situation to the AI but the unit diversity of MTW2 (which is IMO a welcomed feature) is partly responsible for the downfall of the tactical AI.
    (b) The situation could be improved though if the AI would focus on producing high quality troops. More than that, the AI should focus on producing high quality all-rounder troops. For example the advantage of YS/SA system is not just that both human and AI had the same armies but that YS is a reasonable all-rounder unit useful both vs. cavs and infantry. So even in the later stages of the game when the human player had more advanced units (nodachi, naginata,etc) YS was still useful. As opposed to this militia spearmen (except perhaps the Italian ones) became obsolete very early in the game, and even some high end units such as DFK can be obsolete, especially in the hands of the AI. The AI should produce all-rounders that can be useful later in the game. Given the unit choice available to most factions IMO there is only one such early available all-rounder unit: heavy cavalry. Elite spears could be such units in theory, but given the inability of the AI to handle the shooting game and that only a few factions have truly elite spears/pikes early on (Papal states, Scotland) IMO it is a bad choice. DFK, DCK is a bad choice too given their vulnerability to cav charges. Light cav is a bad choice given that the AI is unable to handle the skirmishing game. So really only heavy cav remains. Actually it would be quite historical. Of course, given the faction, elite spearmen and elite archer could be produced to support the cavalry. DFK, DCK (swords in general) should be used only for sieges. All other troops should have a supporting / cannon fodder role. In another thread I will give examples for preferred AI army compositions but I don’t want to mess up this thread with that.
    (c) The tactical AI should be treated as a beginner. When I fought Shogun MP and had allies with little experience our priorities were as follows: stick together, stick to the high ground. IMO the tactical AI should have these same priorities in that order. In MTW2 that AI too often wants to fight an aggressive cav fight which it cannot handle. Also it just simply ignores height advantage. It is happy to sit in the bottom of a valley even if surrounded on three sides with archers/ cav archers. IMO (1) the AI should keep all its troops together and engage in a very conservative orderly fashion starting from center moving to the flanks. That is, engaging in the center with its strongest infantry units then gradually covering both flanks with cavs, spears, flanker units (axemen). It is predictable, but it would be safe. Also it would keep the human player busy at both flank (as opposed to the current situation when the human player can do whatever he wants on the flank, either because the AI just ignores it, or because the AI has already lost all its cavs). (2) The AI should always seek the high ground. In MTW2 even when I start in the bottom of a valley I can manoeuvre my army into a position where I have the high ground. The AI should never allow this. I remember that in MTW the AI often changed its position when it felt its flank threatened. I never saw this in MTW2. I don’t think (though ofc I can be wrong) that it would be that difficult to program the AI to seek the high ground while keeping all its forces together (especially in the light that it was capable to do something similar in MTW). IMO such behaviour would give a much greater challenge and would create the impression of a more intelligent AI (which ofc it won’t be but still … ).

    All in all IMO the weakest link in MTW2 is the tactical AI, I guess most of us would agree. With some relatively simple changes suggested above the situation could be improved. I definitely would like to see a more challenging tactical AI when the Kingdoms come out or even earlier if possible …
    Lional of Cornwall
    proud member of the Round Table Knights
    ___________________________________
    Death before dishonour.

    "If you wish to weaken the enemy's sword, move first, fly in and cut!" - Ueshiba Morihei O-Sensei

  2. #2
    Master Procrastinator Member TevashSzat's Avatar
    Join Date
    Nov 2006
    Location
    University of Pennsylvania
    Posts
    2,367

    Default Re: How to improve the tactical AI

    IMHO, the best way to solve the ai problem is to model the ai's behavior and tactics off of people of varying skills for different difficulty, but have different styles of player that will be modeled after. For example, there could be a blitzer or a turtler and the ai could randomly pick a tactic at the beginning of every campaign.
    "I do not know what I may appear to the world; but to myself I seem to have been only like a boy playing on the seashore, and diverting myself in now and then finding a smoother pebble or a prettier shell than ordinary, whilst the great ocean of truth lay all undiscovered before me." - Issac Newton

  3. #3
    Masticator of Oreos Member Foz's Avatar
    Join Date
    Dec 2006
    Posts
    968

    Default Re: How to improve the tactical AI

    I don't think getting the AI to field a lot of cavalry is a solution. As you pointed out, Cheetah, cavalry clearly gives the edge to the player since he is far more adept at maneuvering and using it. Much of this is down to the mobility of the unit, so clearly we want a less mobile unit favored. The only problem with heavy infantry like DFK is that they are somewhat disadvantaged to cavalry (note that working shields make them better than you'd expect - 21 armor goes a long way). The idea then shouldn't be to make the AI rely on heavy cav and try to match the player... but rather, I think it should be to severely limit heavy cavalry, so as to narrow the player's advantage from it, and make core infantry units like DFK viable as the basis for an army. In one move, you'll have put a leash on the human's ability to go nuts with all-heavy-cavalry armies, and allowed the AI to lean on a unit that really ought to be a viable mainstay of any army.

    As for the overall implementation of this idea, I'm recommending rebalancing the recruitment pools. This is where ideal army composition comes into play. It's obvious that the AI will recruit 24/7 as much as possible, so the best way to control composition is to control availability. If you know what you want the army to look like, you can make the units available in those ratios, and I'm betting AI armies will come out looking largely like the recruitment ratios. The trick will be lowering overall availability enough to keep the AI producing units fairly regularly, but also to run out of the units it would otherwise overbuild. As such, I have a few guidelines:

    1. Overall unit availability for a given settlement should be based on its number of recruitment slots. Ideally if a castle has 3 slots, then the total of all available units there should be 3.0 each turn. That would mean that exactly the right number of troops would enter the pool each turn... just not whole units in any given category. What I hope to have happen, then, is that the partial unit each unit type gets each turn translates into a different selection of 3 units each turn... and over a few turns, the correct composition should be achieved. Obviously it will never work out that ideally, but it seems a good place to start. In reality I think some breathing room is necessary - extra unit replenishment to allow the human player some choice. Just how much can be allowed without wrecking the AI composition, though, is something to toy with.

    As a simple example of #1, lets say a castle can make 6 different units. If we want them in equal amounts, we'll set each to receive 0.5 unit every turn. They'll all hit 1.0 at the same time, and the AI selects 3 to build. Next turn, though, those three will only have 0.5 unit, and can't be built - the AI will have to build from the remaining three units, each at 1.5. If the AI keeps recruiting the max allowed, it would cycle turns recruiting the first 3, then the second 3, and end up with even amounts of everything.

    One possible extension of this is placing lower caps on the pools. This is likely required, as the recruitment queue can't run constantly, so units could build up and allow too much choice, thus ruining the plan. The exact amounts would likely come from simple trial and error.

    2. Cities may need sharper cuts than outlined above. One major problem is that the AI recruits militia in particular too heavily, so it may be useful to consider limiting army availability in cities to less than the number of slots per turn. Perhaps about half the number of slots to try to keep it under control. Obviously some factions get great army units from their cities though, so the more drastic measures are only really intended for factions where it's horrible to be recruiting tons of city troops, and castle troops should be emphasized. One additional benefit of this is that it could alleviate AI money troubles - if recruitment is more limited, the AI may find more money to invest in good buildings, and thus end up with a better economy.

    3. Availability of lower-tier troops should actually go down as tech level goes up. This is something the vanilla game fails to accomplish. The way I've proposed to fix things, this would be necessary to promote recruitment of the better units that become available. In essence the idea would be to set ideal army composition for each city/castle tech level, and then pattern the recruitment allotments directly from that composition. For instance when England gets Armored Swordsmen at Fortress level, that settlement would shift from filling Billmen and Levy Spearmen faster to producing Armored Swordsmen more quickly. It may take a few turns for the adjustment to show, but in the end those lower units would quickly run out of stock and be replaced frequently by recruitable Armored Swordsmen.

    So to wrap up, the essence of this is choice - If you can limit the AI's choices, you should be able to more or less determine what it recruits. Note that I haven't thought about this further than that: I don't know if this would be horrible for the player to deal with, or anything else... just that it's probably the best approach to getting the AI to recruit what you want it to. Of course the best thing would be direct control of the AI's recruitment policies, but it seems we can't have that. Anyway, feedback, as always, is appreciated.


    See my Sig+ below! (Don't see it? Get info here)

  4. #4

    Default Re: How to improve the tactical AI

    As mentioned, army composition has to be the first step. No point talking about flanking etc if the AI has all catapult armies. As the AI will spam units, controlling what each faction can spam to suit their particular advantages will make a lot of difference. It should be fairly easy to do now with the recruitment pools etc.

    edit: giving all the units the same "walk" speed would help too so their formation didn't break up allowing cav/skirmishers/infantry to stay in formation.
    Last edited by nikolai1962; 04-12-2007 at 06:27.
    It's not a map.

  5. #5

    Arrow Re: How to improve the tactical AI

    Army composition is not that big of a problem, the problem is and has been since MTW (in Shogun it wasn't so much of a problem due to the limited unit roster) that the AI is unable to disband outdated troops. As such it always operates at the upper limit of its upkeep capabilities which it maxes out early on in the campaign with weak units simply because it can't build better ones at that time. Given the fact that the AI often does try to retreat instead of fight when facing a superior army and the fact that AI vs AI fights rarely see the losing army destroyed but rather just weakened, the AI WILL usually retrain these units, thus again preventing itself from producing any better units (well, at least in significant numbers) that might now be available.
    Solution is either implementing a smart disband ability for the AI, or the player attacking and wiping out AI stacks without taking that faction's settlements. I usually do this and let the AI rebuild, which, at least in my experience, makes them produce armies with better troops (e.g. many varangian guards and elite archers as well as heavy cav for the Byzantines or lots of Papal guards and xbows for Papacy). Another solution would be to give the AI more income by gifting them provinces, however, that's good only as a temporary fix for maybe one or two factions, given the limited amount of settlements available.
    Ignoranti, quem portum petat, nullus suus ventus est. -Seneca, Epistulae Morales, VIII, 71, 3

  6. #6
    Senior Member Senior Member Carl's Avatar
    Join Date
    Dec 2006
    Posts
    1,461

    Default Re: How to improve the tactical AI

    Lots to say here.

    I want to reply to several people, so I'll go in order.

    Bear in mind a lot of what I have to say is colored by my experiences with both of my ProblemFixer Mods.


    First, @ Cheetah, (in answer to your cure suggestions):

    (a) This IS a problem, but only because of poor recruitment and tactical AI programming, and games these days HAVE to have verity if they are to sell. Thats why I tend to be dismissive to a certain degree of Puzz3D's comments about this. If they removed the verity, (as Puzz3D seems to want), then the game would not sell well and the series he so loves could easily cease to exist. Greater unit verity is something you have to accept for good or ill if you want to be able to play TW games at all.

    HOWEVER their is one area of unit verity that DOES need an improvement, and that is unit duplication.

    DFK, (although they DO perform worse than their stats suggest), are nearly identical to Dismounted Chivalric Knights/Armored Swordsmen/Noble Swordsmen e.t.c. The difference just isn't enough to justify any faction getting both. That REALLY hurts the AI IMHO as it leads to too many units of a similar type showing up, killing army verity.

    (b) I don't agree with your assessment here as it is an assessment mired in STW thinking IMHO, (no offense BTW)and it had low verity and thus used a moderate counters system. In effect the units where largely similar to each other, the bonuses each unit got against other units that it was the counter to where small enough that whilst it might beat it's target it would only do so by a small amount. In effect the bonuses where just enough to make them important from a cost vs. power perspective, but not so great that they couldn't be overcome by intelligent use of the overall army.

    With the increased unit verity this is no longer possible. The greater unit verity means a greater variance within each class type, (S & S being an example of a class type), this means that the gaps between the various class types have had to be increased creating a hard counters system.

    In this system an all rounder unit simply doesn't work because it is so powerful just for it's all rounder abilities that it has to have an insane price tag. it's possible, but it becomes far too expensive to form the core of an army. What you have to do is make the AI use a balanced army and use it well.

    The closest thing to an all-rounder however is S & S units as these units are able to resist light Cav, hold Medium Cav to a draw, beat any other non-pike/2-hander infantry available head on, and lastly they are very missile resistant. Their biggest issue is that Heavy Cav and 2-Handers can destroy them badly, and Medium Cav may get destroyed itself, but said medium Cav will also destroy them.

    However their high defense makes them relatively resistant to mistakes and as a result they make excellent line infantry.


    (c) The problem with the tactical AI is that it's programmed in a way that is appropriate to STW where units where not hard counters, and where the variance within a single class was much lower. It treats all missile units as the same in priority term, all Cav as the same, and all infantry as the same, it doesn't even differentiate between Spears, 2-handers, Pikes, and S & S infantry.

    The AI needs much better target priority if it's to do ANYTHING right now as it considers border Horse the equal of Gothic Knights ATM.

    Here's how I would do it.

    Their would be a separate Target Priorities file, here's a notation based version.


    Code:
    File Header
    
    Faction Name: ; this Section should contain the name of the faction to which the subsequent entries are relevant.
    
    Target Faction Name: ; this line should contain the target faction to which this data is relevant, every faction should have it's own entry vs. every other faction including itself, (for use when facing rebels).
    
    Unit Name: ; this line should contain the name of a unit that is part of the unit lineup of the Faction listed in the relevant Faction Name line of code. Each unit a faction has MUST have exactly ONE entry in each entry group.
    
    Target Unit Class: ; which class, (S & S, 2-Hander, Pike, Heavy Cav, Medium Cav, Light Cav, Light FA, Heavy FA, Composite FA, Light HA, Heavy HA, Composite HA, Spear, Peasants, Anti-Personnel Artillery, and Anti-Building Artillery are the default classifications. New classes can be added at the top of the file).
    
    Target Priority [S & S]: ; the target priority of the named unit against units in the named class, (S & S in this case). The units must be listed by unit name, and must be listed in descending order of priority, (i.e. the first listed entry is the unit it will look for first when attempting to match the listed unit up against the listed unit class). Each Class of unit must have it's own target Priority entry but their is no requirement to list these target Priority Entries in any particular order.

    And Below an example entry:

    Code:
    Faction Type: England
    
    Target Faction Type: Byzantium
    
    Unit Name: Billmen
    
    Target Unit Class: 2-Hander
    
    Target Priority [S & S]: Dismounted Byzantine Lancers, Byzantine Infantry, Dismounted Latinkon, Town Militia
    Target Priority [Spears]: Byzantine Spearmen, Spear Militia
    Target Priority [Light FA]: Archer Militia, Peasant Archers
    Target Priority [Heavy FA]: Trebizond Archers
    Target Priority [Composite FA]: Byzantine Guard Archers
    Target Priority [HA]: Sythikon, Byzantine Cav
    Target Priority [Composite HA]: Vardariotai
    Target Priority [Medium Cav]: Byzantine Lancers, Militia Cav
    Target Priority [Heavy Cav]: Latinkon, Kataphraktoi
    Target Priority [Anti-Personnel Artillery]: Ballista
    Target Priority [Anti-Building Artillery]: Trebuchets, Catapult

    The above Target Priority is just part of the mix however. this gives the main AI a good idea of what to use against what in particular faction vs. faction lineups. Which of the various categories of Target Priority should be used and 50 other factors still need to be dealt with.


    The first thing about the new master battle AI file is that it will need to have separate entries for EACH of the Factions as different factions will tend towards different army compositions and fighting battles with a mostly HA force is very different to fighting them with a mostly FA force, or a mostly Spear force.

    In addition each faction will need several AI sub sections itself.

    You'll need separate entries for Offensive and defensive Field and Bridge battles as well as separate entries for attacking and defending sieges and sallies.

    For each of these AI setups their will then need to be a section listing what order to reference the Target Priority entries of a given unit class in.

    For example for English 2-handers in most situations it should try to have them go after S & S units first, Followed by Spears, followed by other 2-handers, Followed By Composite FA, followed by Heavy FA, followed by Light FA, e.t.c. This list is known as The Target Priority Order


    After that part their should be a series of Formation rules. These in effect are used to cause 2 things to happen. First they make sure the units stay in formation and close to each other. Second they modify The Target Priority Order in such a way that they prevent the various units moving in a fashion that causes them to leave themselves or others vulnerable.

    For example Schlitrom Capable spears in Schiltrom should be placed on the Flanks whenever possible. SO even if the unit match-ups dictate that perhaps the Billmen should go on the extreme left to counter a unit of Dismounted Byzantine Lancers out that way, they will not in fact put them further out than the spears.

    Likewise it is a very BAD idea to place anything but spears/pikes in the front rank of your formation as otherwise the enemy Cav can simply charge straight through your line. The 2-Handers/S & S should however be placed in the second line, preferably with the 2-handers towards the flanks.


    Likewise, the target Priority order may be altered based on what the enemy is doing and what type of battle is being fought.

    For example 2-Handers should normally target S & S units first with Heavy Cav being right near the bottom of their list and they should form the second line of a formation behind the Pikes/Spears. If Fighting an offensive battle battle and you are near the enemy and their are not enemy heavy Cav close enough to react in time it would not be inadvisable to have the 2-Handers, (and S & S units), charge through the spearmen and engage their targets whilst the spear do a 180 turn and present their spear points to the rear and sides, thus guarding the flanks and rear of the ongoing infantry fight from the enemies flanking attempts.

    You could include reserves in the formations too and these could be accommodated inside the spear shell where they can either reinforce the ongoing battle, or help the spears out as they become engaged. The Heavy Cav could also be programmed to come in at some point, either to attack anyone that tries to flank, to try to flank themselves, or to attack forces attempting to attack their own flanking forces.

    Lastly the exact plan of attack/defense and deployment position should take account of both the existing terrain, weather, and the direction from which reinforcements, both friendly and enemy will enter.


    The core of the system however is a detailed target Priority system that is then coupled with an equally detailed formations system that takes complete account of terrain effects and specific unit capabilities. Lastly, BOTH, of these elements can then be modified on the fly by the enemies actions and reactions allowing the AI to adapt.

    The current AI has no adaption ability, and only very basic target priority and formation systems. As a result it totally fails to accomplish ANY of the 3 points above.


    @Foz:

    1. This isn't a bad point Foz, but it's my experience you can set the replenish rate up as high as 0.7 and still get decent variation. You may be able to go higher but I haven't tried bigger numbers.


    2. I find that if you add + 1 to the number of recruitment slots in castles the AI concentrates much more on castle units so long as they are actually better than the city units available.


    3. Totally agree and that is precisely what I've done in my re-build ProblemFixer. Give me a few minutes and I'll upload and post a link to the modified file for you.


    @Brutal_DLX: your comments are only true so long as it's easy for the AI to recruit large quantities of the trash, if you follow Foz's suggestion 3 I find that you'll see massive amounts of high quality units. In my Rebuild ProblemFixer I've faced Danish Armies utilizing mostly Dismounted Chivalric Knights, Huscarls, Dismounted Huscarls, Scouts, Obudshaer's, and Norse Archers, with the odd unit of Viking Raiders/Norse Swordsmen mixed in. Yes Town Garrisons still tend to be Spear/Town Militia a lot, but that has a lot to do with the fact that these seem to take longer to update, but they eventually do update too. That and the later units are pike units which the current recruitment AI treats as the worst units in the game.

    A much better Recruitment AI and Garrison AI needs to be created IMHO.
    Find my ProblemFixer Purehere.

    This ProblemFixer fixes the following: 2-Hander bug, Pike Bug, Shield Bug, Chasing Routers, Cav not Charging, Formation Keeping Improved, Trait Bugs, and Ancillary Bugs.

    BETA Testers needed for the current version of RebuildProblemFixer. Thread here

  7. #7

    Default Re: How to improve the tactical AI

    I think the problem has been improved somewhat for 1.2

    If the AI is given time it eventually starts fielding better troops; by that I mean once it starts upgrading. HRE started fielding Gothic knights along with DFK and pikes. Portugal started fielding armies of DPK supported by muskets. The AI also focuses its armies better for more full stacks running around than multiple small stacks(Which were annoying).

    Though I can't say the same for Egypt strangely.

    I ran a test and the Turks had no problem fielding cavalry armies (Light and heavy) but the Egyptians kept making siege weapons. Same with Milan and their crossbowmen. The rest of the other factions builds whatever they were geared for with a variety in siege, knights, and spearmen.

    Since HRE was the most powerful, typical army I saw included gothic knights, DFK, Imperial knights, crossbowmen, and handgunners.
    Last edited by nameless; 04-12-2007 at 16:04.

  8. #8

    Arrow Re: How to improve the tactical AI

    Quote Originally Posted by Carl

    @Brutal_DLX: your comments are only true so long as it's easy for the AI to recruit large quantities of the trash, if you follow Foz's suggestion 3 I find that you'll see massive amounts of high quality units. In my Rebuild ProblemFixer I've faced Danish Armies utilizing mostly Dismounted Chivalric Knights, Huscarls, Dismounted Huscarls, Scouts, Obudshaer's, and Norse Archers, with the odd unit of Viking Raiders/Norse Swordsmen mixed in. Yes Town Garrisons still tend to be Spear/Town Militia a lot, but that has a lot to do with the fact that these seem to take longer to update, but they eventually do update too. That and the later units are pike units which the current recruitment AI treats as the worst units in the game.

    A much better Recruitment AI and Garrison AI needs to be created IMHO.
    That Foz' suggestion would work, there is no doubt. But in 3. he specifically talks about the availability of weak units in the latter stages of the game. This has in my experience never been THE problem, e.g. if you'd delete all forces one sizable AI faction has in late-game, I hold that you'd see them recruit better troops even in vanilla 1.1. The problem is rather, which was my main point, that it cannot afford to train strong units while it most of the times has an almost maxed-out army that never gets seriously depleted.

    That an additional smarter recruiting and stack-building AI would be beneficial is true without doubt, but it doesn't quite fix the problems at the beginning of the game. If the AI had to wait longer to assemble its stacks, it would at the same time invite the human player to rush them even more. The only other "quick" fix I can think of would be increasing the starting money and the starting buildings in all important settlements, so the AI has better troops available right away.

    Besides, the basic problem was about improving the tactical AI, and while better army composition does help, i'm afraid only better battlefield AI scripting as Cheetah suggested would truly change the mostly one-sided battles.
    Ignoranti, quem portum petat, nullus suus ventus est. -Seneca, Epistulae Morales, VIII, 71, 3

  9. #9
    Senior Member Senior Member Carl's Avatar
    Join Date
    Dec 2006
    Posts
    1,461

    Default Re: How to improve the tactical AI

    All good points DLX, I also use a money script in my Rebuild ProblemFixer and because of my buffed rebels it's quite a strong one at that, so it's easier for the AI to recruit good troops. On top of that the AI does tend to build the big nasty stacks in my mod and simply relegates the outdated stuff to Garrison duty.

    I never see any issues with the AI being stuck with an upkeep limits worth of trash.

    This may also be down to the fact that the AI tends to throw more big stacks around too, so as a consequence it tends to lose entire units worth of stuff, (it merges before it retrains), and as a result will steadily replace lost trash with better stuff.


    Your last point is certainly true, but the existing A can still beat you if it outnumbers you 2 to one with equal or better quality troops.

    In one battle I faced, (Spread amongst several stacks, and approximate numbers only):

    15 DCK
    4 Mounted Huscarls
    4 Dismounted Huscarls
    2 Gens
    2 Scouts
    Half a stack of assorted Peasant Archers, Norse Archers, Spear Militia, and Town Militia.
    4-6 total assorted units of Viking Raiders/Norse Swordsmen
    6 Obudshaer's

    I had 2 Mercenary Frankish Knights
    1 Gen
    and an even split from the other 17 units between Highland Archers, Noble Swordsmen, and Highland Nobles, (considerably buffed from vanilla to bring them into line with other fixed 2-handers).

    Total Numbers where a Little over double mine and I had a good deployment position, but they still managed to rip me to pieces in spite of it for the loss of about half their forces.

    Give the AI good enough forces in large enough quantities and they can really challenge the player. Yes they could do better, but I outlined the current AI issues above.

    The simple truth is however that until the AI starts building balanced armies it doesn't matter what we do with the battlefield AI, it's still borked.
    Find my ProblemFixer Purehere.

    This ProblemFixer fixes the following: 2-Hander bug, Pike Bug, Shield Bug, Chasing Routers, Cav not Charging, Formation Keeping Improved, Trait Bugs, and Ancillary Bugs.

    BETA Testers needed for the current version of RebuildProblemFixer. Thread here

  10. #10
    has a Senior Member HoreTore's Avatar
    Join Date
    Jan 2005
    Location
    Norway
    Posts
    12,014

    Default Re: How to improve the tactical AI

    Another point, is the AI generals. They have a huge impact when trained properly, while little to no if not. That's really one of the key reasons the Mongols are so hard - they have a huge morale boost from 8-10 stars, while you get a huge morale loss because of 8-10 dread.

    However, back in europe, the AI never trains their generals properly, and so have only a couple of stars and a couple points of chivalry/dread, while you have 5+ stars and 5+ chivalry/dread. What it means, is that their troops rout very easily. If they have a good general however, that wont happen. One of the battles I remember best, was against a French ex-crusader stack, with a very good general, with a lot of chivalry. His forces were the same number, but a little less quality than mine. If it hadn't been for the general, I would have routed his army in no time, but that time, his troops kept on fighting even when I slammed my cavalry into the back of his engaged troops. I won in the end, but I suffered about 60%+ casaulties, and they didn't rout until I killed the general.

    If they can learn how to train their generals properly, things would get harder.
    Still maintain that crying on the pitch should warrant a 3 match ban

  11. #11
    Corrupter of Souls Member John_Longarrow's Avatar
    Join Date
    Dec 2006
    Location
    Be it ever so humble, there's no place like the Abyss...
    Posts
    267

    Default Re: How to improve the tactical AI

    Two things I can see that would address the army composition would be pretty simple triggers (theoretically).

    1) If the AI can replace a unit in a castle or city with something better, it creates the new unit then disbands the old one. This would start removing trash from the AI's army

    2) Limit siege weapon recruiting. I've encountered too many stacks composed of 6 peasants, 8 catapults, and a few balista. It doesn't make any sence for any army to have more than 20% of its units being seige weapons. Yep, that means the AI should produce an "Assault" stack with 4 siege weapons and a bunch of heavy infantry, but it shouldn't produce a stack of 4 infantry with the rest siege weapons.

    2 actually applies to any kind of specialty unit, but siege toys seem to be the most abused. About the only reason I can see for an army composed mostly of building smashers would be if you were going to attack a city, tear it up, and leave. As the AI doesn't do that...

  12. #12

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Carl
    (b) I don't agree with your assessment here as it is an assessment mired in STW thinking IMHO, (no offense BTW)and it had low verity and thus used a moderate counters system. In effect the units where largely similar to each other, the bonuses each unit got against other units that it was the counter to where small enough that whilst it might beat it's target it would only do so by a small amount. In effect the bonuses where just enough to make them important from a cost vs. power perspective, but not so great that they couldn't be overcome by intelligent use of the overall army.
    This just isn't true. There is only one unit matchup bonus in STW, and that is the anti-cav bonus provided by the spear. This is a large bonus of 400% for spear infantry vs cavalry. It's 200% for spear cavalry vs non-spear cavalry. This allows considerable space in the combat system for unit differentiation between the low end spear units and the high end cav units. For instance, the strongest infantry unit (cost 1000) is 250% better than the strongest spear unit (cost 400) and no bonuses are needed to achieve that. That means this strong unit will kill at least 2.5 spearmen for each man it looses, and the spearmen under such stress of casualties will rout before reaching half strength. Worst case for the standard 60 man units, would be the strong infantry unit loosing 12 men when the spear unit lost 30 men and then routed. In fact, the strong unit won't even loose that many men because of the pushback effect and the effect of multiple strikes within a combat cycle once the stronger unit gets about a 15% advantage in men. The heavy cav is an effective counter unit to this strong infantry unit while at the same time loosing to the spear unit. I don't recall the typical losses sustained by a heavy cav unit in beating the strong infantry unit, but the cav units are full size 60 man units and retain effectiveness allowing them to defeat multiple strong infantry units. Cav does better than it's melee stat would suggest due to the charge bonus.

    The relationship of the melee units' combat power is approximately:

    weak spear = x (4x anti-cav)
    strong spear = 1.9x (8x anti-cav)
    weak sword = 2.5x
    defensive sword = 4.7x
    offensive sword = 4.7x
    light cav = 3.5x (5.3x anti-cav)
    medium cav = 4.2x
    heavy cav = 5x

    There is plenty of differentiation in there. Plenty for both the AI and humans to utilize when choosing matchups.


    Quote Originally Posted by Carl
    With the increased unit verity this is no longer possible. The greater unit verity means a greater variance within each class type, (S & S being an example of a class type), this means that the gaps between the various class types have had to be increased creating a hard counters system.
    I don't see much of an increase in the dynamic range of the combat system. They went from a range of -20 < x < +20 with 20% steps in the old engine to -64 < x < +64 with 10% steps in the new engine. That's a 1.6 increase in dynamic range. So, yes you could have more units fit into the system, but certainly not the ten fold increase of MTW over what was in STW. A few more parameters have been added, but if the AI doesn't know how to utilize those parameters, then they will only benefit the human player. I don't foresee the game's AI being improved enough to handle what it's currently being asked to handle.

    _________Designed to match Original STW gameplay.


    Beta 8 + Beta 8.1 patch + New Maps + Sound add-on + Castles 2

  13. #13
    Senior Member Senior Member Carl's Avatar
    Join Date
    Dec 2006
    Posts
    1,461

    Default Re: How to improve the tactical AI

    This just isn't true. There is only one unit matchup bonus in STW, and that is the anti-Cav bonus provided by the spear. This is a large bonus of 400% for spear infantry vs cavalry. It's 200% for spear cavalry vs non-spear cavalry. This allows considerable space in the combat system for unit differentiation between the low end spear units and the high end Cav units. For instance, the strongest infantry unit (cost 1000) is 250% better than the strongest spear unit (cost 400) and no bonuses are needed to achieve that. That means this strong unit will kill at least 2.5 spearmen for each man it looses, and the spearmen under such stress of casualties will rout before reaching half strength. Worst case for the standard 60 man units, would be the strong infantry unit loosing 12 men when the spear unit lost 30 men and then routed. In fact, the strong unit won't even loose that many men because of the pushback effect and the effect of multiple strikes within a combat cycle once the stronger unit gets about a 15% advantage in men. The heavy Cav is an effective counter unit to this strong infantry unit while at the same time loosing to the spear unit. I don't recall the typical losses sustained by a heavy Cav unit in beating the strong infantry unit, but the Cav units are full size 60 man units and retain effectiveness allowing them to defeat multiple strong infantry units. Cav does better than it's melee stat would suggest due to the charge bonus.

    The relationship of the melee units' combat power is approximately:

    weak spear = x (4x anti-Cav)
    strong spear = 1.9x (8x anti-Cav)
    weak sword = 2.5x
    defensive sword = 4.7x
    offensive sword = 4.7x
    light Cav = 3.5x (5.3x anti-Cav)
    medium Cav = 4.2x
    heavy Cav = 5x

    There is plenty of differentiation in there. Plenty for both the AI and humans to utilize when choosing matchups.
    I was basing my comments on statements you had made in past posts and what they implied. Namely several statements about 2 units of unit X being able to beat 1 unit of unit Y even though Unit Y is a counter for Unit X.

    Bearing in mind that most Hard counters systems have 2-1 kill rates in favor of the countering unit and the flank/rear bonuses for attack it implied that the difference between the total combat power was not very great since those same posts implied that the 2 units would only win by a small amount. Bearing in mind you have a Little over 2 times the combat power between numbers and flank/rear bonuses this implied that the total extra combat power, (measured in terms of kill rates), of the counter unit was less than double that of the unit it was countering. Most M2TW counter systems have 2-1 or greater kill rate differences.

    Now of course I've probably just misunderstood some of your statements and misinterpreted others, but i'm not sure what I've got wrong specifically. Thus how is it that such big combat differences don't produce a situation where a unit that counters unit X cannot be beaten by 2 units of unit X.


    I don't see much of an increase in the dynamic range of the combat system. They went from a range of -20 < x < +20 with 20% steps in the old engine to -64 < x < +64 with 10% steps in the new engine. That's a 1.6 increase in dynamic range. So, yes you could have more units fit into the system, but certainly not the ten fold increase of MTW over what was in STW.
    Alright, a quick question, what is this combat points system you mention? I assumed at first it was a straightforward attack vs. defense comparison between the attacker and defender, but i get the impression i'm miles off right now...



    As to what i was driving at. I'll try to explain what I meant with my comments. Please bear in mind that all the text in italics is simply an explanation for my stance in your quoted text based on my apparently erroneous understanding of STW. The argument will be subject to revision or even totally discarded nice i understand where I went wrong in understanding STW. Thus the text in question is not an attempt to dispute your reply, merely to explain myself.


    In my experience you need at least a 4 point difference between the total attack+defense scores before the difference is really noticeable on the battlefield. Bearing in mind we want several different S & S unit, several different 2-Hander units, Several different Spears, e.t.c. and considering their are upper and lower limits on the attack/defense values of various units if they are to fall into a given category you need a VERY large range of values if things are to work.

    In effect you need a very large range of values for each unit class, and most unit classes should not overlap with other unit classes. In M2TW for example the used values range from about 5 attack to nearly 30 attack, with similar values for defense, although i think defense tops out at about 25, but goes as low as 1.

    The 3 major infantry classes have mostly distinct sections of those ranges assigned to them with Little overlap. That means the in combat differences are often no less than a 2-1 kill rate in favor of the countering unit, and can easily be higher. The only time it tend to be lower is either when the units are both of the same class, or it is a high end unit in one class up against a low end unit in another class.

    For clarification the 3 major infantry classes are: 2-Handers, Spears, S & S.


    In effect I felt based on my erroneous understanding of STW that the difference in kill rates between the best STW and M2TW would have grown so much as to make the kind of system present in STW difficult if not impossibbile to achieve. In effect i did not believe that by an large the system of STW where a unit that counters something else could ever be beaten by the unit it counter in an economical way as thought you had implied was possible in STW. That would require a completely different type of AI and it was my opinion the AI as currently programmed would probably work much better in the STW environment because of it's counters system.
    Find my ProblemFixer Purehere.

    This ProblemFixer fixes the following: 2-Hander bug, Pike Bug, Shield Bug, Chasing Routers, Cav not Charging, Formation Keeping Improved, Trait Bugs, and Ancillary Bugs.

    BETA Testers needed for the current version of RebuildProblemFixer. Thread here

  14. #14

    Default Re: How to improve the tactical AI

    For a start, I would make the AI protect it's ranged units a lot more. The AI too often allows archers to move far ahead of its army or leave them behind. Siege weappns and cannons are also commonly left behind.

  15. #15

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Carl
    I was basing my comments on statements you had made in past posts and what they implied. Namely several statements about 2 units of unit X being able to beat 1 unit of unit Y even though Unit Y is a counter for Unit X.
    That was for two YS (total cost = 800) which start out side by side beating 1 WM (cost = 1000) by maneuvering 1 YS to attack the WM from the rear after the first YS engages. Straight up the two YS would loose to the WM, but by utilizing flanking they can win. It demonstrates that the rate of kills in this match up is slow enough and the morale of the YS high enough for it to hold long enough for the flanking maneuver to be carried out, that the combat bonus for rear attack is large enough for the flanking maneuver to work and that the morale of the WM is not too high.

    I just tried WM vs YS, and the WM won loosing only 8 men while the YS lost 35 men and then routed. That's about a 4 to 1 kill ratio. I did the HC (cost = 1200) vs WM (cost = 1000) test and the WM routed at 30 men while the HC had 47 men left. That's the best cav vs the best infantry unit with a 2.5 kill ratio (the cav got 9 or 10 kills in the charge).

    This was the test result we did in March 2005 for the two YS flanking test:

    Quote Originally Posted by Puzz3D
    To check the flanking we matched two YS vs one WM. The YS are side by side and the WM attacks one which is in hold formation while the other YS, in engage at will, moves forward and makes a couple of turns to flank from behind. The timing starts when the WM makes contact with the blocking YS. The two YS beat the WM in 55 seconds. The blocking YS had 27 men left and the flanking YS had 33 men left. The WM routed at 9 men. It took 20 seconds for the flanking YS to make the maneuver and contact the rear of the WM.


    Quote Originally Posted by Carl
    Bearing in mind that most Hard counters systems have 2-1 kill rates in favor of the countering unit and the flank/rear bonuses for attack it implied that the difference between the total combat power was not very great since those same posts implied that the 2 units would only win by a small amount. Bearing in mind you have a Little over 2 times the combat power between numbers and flank/rear bonuses this implied that the total extra combat power, (measured in terms of kill rates), of the counter unit was less than double that of the unit it was countering. Most M2TW counter systems have 2-1 or greater kill rate differences.
    Well the two YS have twice as many men so that takes off a factor of 2, and the flanking bonus is 2.5x. So that's enough to offset the 4 to 1 kill ratio the WM gets against the YS. This is for the stronger spear unit. If you tried this with two of the weak spear units it won't work against the strong sword unit. However, it may work against the weak sword unit.


    Quote Originally Posted by Carl
    Now of course I've probably just misunderstood some of your statements and misinterpreted others, but i'm not sure what I've got wrong specifically. Thus how is it that such big combat differences don't produce a situation where a unit that counters unit X cannot be beaten by 2 units of unit X.
    It's just the way the system was designed. The flanking bonus is large enough that two weaker units can win using that maneuver, but you have to be prompt or else it will be too late. If the holding unit is beaten before the flanking unit strikes, the enemy unit will just turn and beat the flanking unit. You also don't want weaker units to hold unnecessarily long because then support units have time to come from long distances which tends to negate a local superiority.



    Quote Originally Posted by Carl
    Alright, a quick question, what is this combat points system you mention? I assumed at first it was a straightforward attack vs. defense comparison between the attacker and defender, but i get the impression i'm miles off right now...
    It's 1.9% * 1.2 ** (attack - defense + combat bonus) with every unit having the same 1 second combat cycle.
    In the new engine, the algorithm appears to have an additional lethality multiplier, and the base for the exponential is probably 1.1 rather than 1.2. In addition you have a variable combat cycle depending on the particular animation, and the collision detection which is apparently affected by the length of the weapon.



    Quote Originally Posted by Carl
    In my experience you need at least a 4 point difference between the total attack+defense scores before the difference is really noticeable on the battlefield. Bearing in mind we want several different S & S unit, several different 2-Hander units, Several different Spears, e.t.c. and considering their are upper and lower limits on the attack/defense values of various units if they are to fall into a given category you need a VERY large range of values if things are to work.

    That's consistent with the 2 point needed in the old engine to see a significant difference in melee performance where the step per point is apparently twice as large.



    Quote Originally Posted by Carl
    In effect you need a very large range of values for each unit class, and most unit classes should not overlap with other unit classes. In M2TW for example the used values range from about 5 attack to nearly 30 attack, with similar values for defense, although i think defense tops out at about 25, but goes as low as 1.
    You want to leave room for the combat bonuses. In SW, the attack value for units ranges from -7 to +7, and the defend value from -4 to +6 in a system that cuts off at -20 and saturates at +20.


    Quote Originally Posted by Carl
    The 3 major infantry classes have mostly distinct sections of those ranges assigned to them with Little overlap. That means the in combat differences are often no less than a 2-1 kill rate in favor of the countering unit, and can easily be higher. The only time it tend to be lower is either when the units are both of the same class, or it is a high end unit in one class up against a low end unit in another class.


    For clarification the 3 major infantry classes are: 2-Handers, Spears, S & S.
    Sounds good if you have enough dynamic range to handle it along with all the bonues.


    Quote Originally Posted by Carl
    In effect I felt based on my erroneous understanding of STW that the difference in kill rates between the best STW and M2TW would have grown so much as to make the kind of system present in STW difficult if not impossibbile to achieve. In effect i did not believe that by an large the system of STW where a unit that counters something else could ever be beaten by the unit it counter in an economical way as thought you had implied was possible in STW. That would require a completely different type of AI and it was my opinion the AI as currently programmed would probably work much better in the STW environment because of it's counters system.
    Well the AI in STW makes match ups based on the difference in combat points. Combat points are nearly all that matters in determining the outcome in STW, although not quite but I don't want to get into that. In the new engine, you have the variable combat cycle and collision detection apparently affected by the length of the weapon. If the AI isn't aware of these factors it will make mistakes in choosing a match up.
    Last edited by Puzz3D; 04-13-2007 at 02:22.

    _________Designed to match Original STW gameplay.


    Beta 8 + Beta 8.1 patch + New Maps + Sound add-on + Castles 2

  16. #16
    Masticator of Oreos Member Foz's Avatar
    Join Date
    Dec 2006
    Posts
    968

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Carl
    3. Totally agree and that is precisely what I've done in my re-build ProblemFixer. Give me a few minutes and I'll upload and post a link to the modified file for you.
    Help me Carl-Wan Kenobi, you're my ONLY HOPE!!!

    I hope I didn't just miss the file being posted somewhere in the mess that follows this post of yours...

    While you're at it, can you briefly outline what you've changed in the file? I have my own mods in the EDB, though they don't include the recruitment as of yet, so it'd be good to know what pieces are non-vanilla in your EDB (including the recruitment changes) so I can try to merge them somehow.

    That, plus I'm just plain interested to hear what you changed and your reasoning.


    See my Sig+ below! (Don't see it? Get info here)

  17. #17

    Default Re: How to improve the tactical AI

    Army composition is not that big of a problem, the problem is and has been since MTW (in Shogun it wasn't so much of a problem due to the limited unit roster) that the AI is unable to disband outdated troops
    Which is unbalanced army composition from a different angle.

    Plus the AI doesn't just not disband the outdated units, it builds more. The AI spams units to fit in with the shotgun non-strategy it uses. If on a particular turn it can't afford to build dismounted knights, it won't save up for them on the next turn it will build peasants. You need to change all the recruitment pools to make each faction build to its strengths. One thing is to reduce the number of the outdated units as the barracks upgrade and not increase them.

    ~~~

    They should aim to get the simple stuff right before trying anything clever.

    1. Sensible army composition.
    2. Identical walk speed
    3. Stick together.

    If an army with a solid core of heavy infantry with protected missiles and decent cav on the flanks sticks together and moves as a whole then it's a tough fight whatever the player does. Save fancy tricks for high-command generals then if they don't work it won't notice so much :)

    (or an HA army or a heavy knight army, various combos that fit particular factions.)

    ~~~

    also, the battle AI itself is only going to work if the AI army has some resemblance to the army composition the script was based on. It's like darth's formation mods, works great if the AI macedonians have something close to a "macedonian" style army but will act very weird if it it is all catapults or all phalanxes or all peasants. Army composition is the bedrock on which everything else has to rest.
    Last edited by nikolai1962; 04-13-2007 at 06:31.
    It's not a map.

  18. #18
    Senior Member Senior Member Carl's Avatar
    Join Date
    Dec 2006
    Posts
    1,461

    Default Re: How to improve the tactical AI

    That was for two YS (total cost = 800) which start out side by side beating 1 WM (cost = 1000) by maneuvering 1 YS to attack the WM from the rear after the first YS engages. Straight up the two YS would loose to the WM, but by utilizing flanking they can win. It demonstrates that the rate of kills in this match up is slow enough and the morale of the YS high enough for it to hold long enough for the flanking maneuver to be carried out, that the combat bonus for rear attack is large enough for the flanking maneuver to work and that the morale of the WM is not too high.

    I just tried WM vs YS, and the WM won loosing only 8 men while the YS lost 35 men and then routed. That's about a 4 to 1 kill ratio. I did the HC (cost = 1200) vs WM (cost = 1000) test and the WM routed at 30 men while the HC had 47 men left. That's the best Cav vs the best infantry unit with a 2.5 kill ratio (the Cav got 9 or 10 kills in the charge).

    This was the test result we did in March 2005 for the two YS flanking test:
    AND

    Well the two YS have twice as many men so that takes off a factor of 2, and the flanking bonus is 2.5x. So that's enough to offset the 4 to 1 kill ratio the WM gets against the YS. This is for the stronger spear unit. If you tried this with two of the weak spear units it won't work against the strong sword unit. However, it may work against the weak sword unit.
    Thanks for that explanation, for some reason I assumed the situation between WM and YS, (Warrior Monks and Yari Spearmen Correct?), was duplicated elsewhere. I also previously wasn't aware that their where several units within the sword and spear classes, or as many in the Cav class. Your statement about just 11 different units meant I thought their where only 1 spear, 1 swords, 2 types of Cav, (one heavy one light), A general's unit and some missile units, plus the odd extra here and their. So STW has far more verity than I believed which also helped confuse me. However since their IS more than one type o sword, I wouldn't honestly expect weak spears to beat strong swords in the manner you described anyway. That would be like pitting Bill militia up against DFK in M2TW, the Bill Militia are a very-weak 2-Hander, whilst the DFK are a very-strong sword in STW terms, thus the DFK even head on will win, but they're going to lose a third to a half the unit doing it.


    It's 1.9% * 1.2 ** (attack - defense + combat bonus) with every unit having the same 1 second combat cycle.
    In the new engine, the algorithm appears to have an additional lethality multiplier, and the base for the exponential is probably 1.1 rather than 1.2. In addition you have a variable combat cycle depending on the particular animation, and the collision detection which is apparently affected by the length of the weapon.
    Just to check a few points.

    1.9% is meant as % correct. Which makes it 0.019 in decimal terms.

    1.2** is 1.2 squared, so 1.44 after the squaring.

    The term "combat bonus" applies to any bonus to any specific bonuses against a particular target, for example the anti-Cav bonuses of spears.

    Thus to use an example from M2TW, (ignoring the probably changed 1.2 value), of Spear Militia, (5 Attack, 7 defense, +8 attack vs. Cav), we would get:

    0.019*1.44*(5-7+8)=0.16416. A bit low looking, (hence why i asked if the 1.9% was meant to be percent).

    It's just the way the system was designed. The flanking bonus is large enough that two weaker units can win using that maneuver, but you have to be prompt or else it will be too late. If the holding unit is beaten before the flanking unit strikes, the enemy unit will just turn and beat the flanking unit. You also don't want weaker units to hold unnecessarily long because then support units have time to come from long distances which tends to negate a local superiority.
    Thanks, I hadn't realized the flanking bonus was so high. That helps explain matters. It's definitely been reduced in M2TW.


    That's consistent with the 2 point needed in the old engine to see a significant difference in melee performance where the step per point is apparently twice as large.
    I was suspecting that, but thanks for the clarification.


    You want to leave room for the combat bonuses. In SW, the attack value for units ranges from -7 to +7, and the defend value from -4 to +6 in a system that cuts off at -20 and saturates at +20.
    Makes sense of course, but thanks for pointing it out.


    Sounds good if you have enough dynamic range to handle it along with all the bones.
    Thanks.


    Well the AI in STW makes match ups based on the difference in combat points. Combat points are nearly all that matters in determining the outcome in STW, although not quite but I don't want to get into that. In the new engine, you have the variable combat cycle and collision detection apparently affected by the length of the weapon. If the AI isn't aware of these factors it will make mistakes in choosing a match up.
    TBH the issue with animations, (as CA themselves have admitted), is down to a too low attack delay value. Since individualistic combats quickly end up with every individual in both units fighting out of sequence with both other members of their unit and the members of enemy units, the attack animation speed isn't necessarily important, (as an individual with a slower animation may well start his attack before someone with a faster animation), so long as the total attacks per minute from both sides is the same. Neither is getting more damage per minute in that way. Likewise a large delay also gives models with short reach weapons the time to close into range without the long reach guy being able to make an attack and capitalize on his reach. Of course this doesn't apply with Spear-wall units, but they have such low attack and defense values at close range that it doesn't really matter if they are unbeatable from the front, they simply crumble from the flank/rear.

    The big one that messes things up IMHO is the AP attribute as it gets more or less effective depending on the target, so it's nearly impossibbile to write a simple algorithm that takes account of it.

    Another matter that messes things up is the variation in missile units and how they work as a part of the RPS system, and likewise the way other new units have been added to the RPS system.

    I Believe that in STW the archers countered all infantry and where countered by all Cav correct?

    In M2TW all Melee Cav still counter FA, but HA are now countered BY FA, Likewise we have Composite FA which are half melee infantry and half FA. Then their is the way some types of infantry now counter FA, (Swords), whilst FA only counter specific types of Infantry now, (2-Handers and Pikes Mostly), and no Combat Point system can explain to the AI how Pikes work and should be used. Lets not even get into how HA and Artillery get into this.


    In effect they've added new units to the RPS system and in the process greatly changed it meaning no simple algorithm can generate accurate target Priority Data. That's why I suggest a manually written and edited Target Priority file so that you can quite clearly give the AI a long list of what it should attack and what it should avoid.

    Yes their probably ARE IMBA between units and elements of the RPS system, but in general you can't identify those without a good AI if you rely on the AI for much of your basic testing.


    Help me Carl-Wan Kenobi, you're my ONLY HOPE!!!

    I hope I didn't just miss the file being posted somewhere in the mess that follows this post of yours...
    I uploaded it but forgot to post the link.


    While you're at it, can you briefly outline what you've changed in the file? I have my own mods in the EDB, though they don't include the recruitment as of yet, so it'd be good to know what pieces are non-vanilla in your EDB (including the recruitment changes) so I can try to merge them somehow.

    That, plus I'm just plain interested to hear what you changed and your reasoning.
    I'll try, I'll post it in code format on the forums and I'll edit out the bits that don't cover unit recruitment, then I'll re-upload it and post a link to the full file.


    Code:
    ;This file is generated from a spreadsheet
    ;Please do not modify by hand
    
    
    
    
    hidden_resources sparta rome italy america atlantic explorers_guild swordsmiths_guild woodsmens_guild teutonic_knights_chapter_house knights_of_santiago_chapter_house crusade jihad arguin horde_target no_pirates no_brigands
    
    building core_building
    {
        convert_to core_castle_building
        levels wooden_pallisade wooden_wall stone_wall large_stone_wall huge_stone_wall 
        {
            wooden_pallisade city requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 0
                    tower_level 1
                    free_upkeep bonus 4
                    happiness_bonus bonus 1
                    recruitment_slots 1
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material wooden
                construction  1 
                cost  600 
                settlement_min village
                upgrades
                {
                    wooden_wall
                }
            }
            wooden_wall city requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Conquistadores"  1   0.4   3  0  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Dismounted Conquistadores"  1   0.4   3  0  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 1
                    gate_strength 1
                    tower_level 1
                    free_upkeep bonus 5
                    happiness_bonus bonus 1
                    recruitment_slots 2
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material wooden
                construction  1 
                cost  1200 
                settlement_min town
                upgrades
                {
                    stone_wall
                }
            }
            stone_wall city requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Conquistadores"  1   0.4   3  0  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Dismounted Conquistadores"  1   0.4   3  0  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 2
                    tower_level 1
                    gate_strength 1
                    free_upkeep bonus 6
                    happiness_bonus bonus 1
                    recruitment_slots 3
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material stone
                construction  2 
                cost  2400 
                settlement_min large_town
                upgrades
                {
                    large_stone_wall
                }
            }
            large_stone_wall city requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Conquistadores"  1   0.4   3  1  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Dismounted Conquistadores"  1   0.4   3  1  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 3
                    tower_level 1
                    gate_strength 2
                    free_upkeep bonus 7
                    happiness_bonus bonus 2
                    recruitment_slots 3
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material stone
                construction  2 
                cost  4800 
                settlement_min city
                upgrades
                {
                    huge_stone_wall
                }
            }
            huge_stone_wall city requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Conquistadores"  1   0.5   4  1  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Dismounted Conquistadores"  1   0.5   4  1  requires factions { spain, portugal, }  and hidden_resource america
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 4
                    tower_level 1
                    gate_strength 2
                    free_upkeep bonus 8
                    happiness_bonus bonus 3
                    recruitment_slots 3
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material stone
                construction  3 
                cost  9600 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building core_castle_building
    {
        convert_to core_building
        levels motte_and_bailey wooden_castle castle fortress citadel 
        {
            motte_and_bailey castle requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 0
                    tower_level 1
                    free_upkeep bonus 1
                    law_bonus bonus 1
                    recruitment_slots 2
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material wooden
                construction  1 
                cost  600 
                settlement_min village
                upgrades
                {
                    wooden_castle
                }
            }
            wooden_castle castle requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 1
                    gate_strength 1
                    tower_level 1
                    free_upkeep bonus 2
                    law_bonus bonus 2
                    recruitment_slots 2
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material wooden
                construction  1 
                cost  1200 
                settlement_min village
                upgrades
                {
                    castle
                }
            }
            castle castle requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, }  
                    wall_level 2
                    tower_level 1
                    gate_strength 1
                    free_upkeep bonus 3
                    law_bonus bonus 3
                    recruitment_slots 3
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                 }
                material stone
                construction  2 
                cost  2400 
                settlement_min town
                upgrades
                {
                    fortress
                }
            }
            fortress castle requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, }  
                    wall_level 3
                    tower_level 2
                    gate_strength 2
                    free_upkeep bonus 4
                    law_bonus bonus 4
                    recruitment_slots 3
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material stone
                construction  2 
                cost  4800 
                settlement_min large_town
                upgrades
                {
                    citadel
                }
            }
            citadel castle requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Aztec Peasants"  1   1   9  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spearmen"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Archers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Spear Throwers"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Aztec Warriors"  1   0.7   6  0  requires factions { aztecs, } 
                    recruit_pool "Jaguar Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Eagle Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Cuahchiqueh"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Coyote Priests"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Arrow Warriors"  1   0.4   3  0  requires factions { aztecs, } 
                    recruit_pool "Peasants"  0   2   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "Highland Rabble"  0   2   6  0  requires factions { scotland, } 
                    recruit_pool "Southern Peasants"  0   2   6  0  requires factions { sicily, byzantium, } 
                    recruit_pool "EE Peasants"  0   2   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "ME Peasants"  0   2   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    wall_level 4
                    tower_level 2
                    gate_strength 2
                    free_upkeep bonus 5
                    law_bonus bonus 5
                    recruitment_slots 4
                    law_bonus bonus 10 requires factions { mongols, timurids, aztecs, }
                }
                material stone
                construction  3 
                cost  9600 
                settlement_min city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building equestrian
    {
        levels stables knights_stables barons_stables earls_stables kings_stables 
        {
            stables castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Turkomans"  1   0.7   6  0  requires factions { turks, timurids, }
                    recruit_pool "Arab Cavalry"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Hobilars"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Border Horse"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Mounted Sergeants"  1   0.7   6  0  requires factions { france, hre, milan, venice, papal_states, sicily, } 
                    recruit_pool "Scouts"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Jinetes"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Polish Shooters"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Kazaks"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Magyar Cavalry"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Skythikon"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Desert Cavalry"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkish Horse Archers"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Horse Archers"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { Normans, } 
                }
                material wooden
                construction  2 
                cost  1200 
                settlement_min town
                upgrades
                {
                    knights_stables
                }
            }
            knights_stables castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Byzantine Lancers"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Broken Lances"  1   0.7   6  0  requires factions { milan, }
                    recruit_pool "Mamluk Archers"  1   0.7   6  0  requires factions { egypt, }
                    recruit_pool "Sipahis"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "English Huscarls"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { england, scotland, france, hre, spain, portugal, venice, papal_states, sicily, } 
                    recruit_pool "Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Polish Nobles"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Boyar Sons"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Hungarian Nobles"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Byzantine Cavalry"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Arab Cavalry"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkomans"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Light Lancers"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Hobilars"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Border Horse"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Mounted Sergeants"  1   0.7   6  0  requires factions { france, hre, milan, venice, papal_states, sicily, } 
                    recruit_pool "Scouts"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Jinetes"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Polish Shooters"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Kazaks"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Magyar Cavalry"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Skythikon"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Desert Cavalry"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkish Horse Archers"  1   0.2   2  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Horse Archers"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { Normans, } 
                }
                material wooden
                construction  3 
                cost  2400 
                settlement_min large_town
                upgrades
                {
                    barons_stables
                }
            }
            barons_stables castle requires factions { scotland, denmark, hre, france, england, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Latinkon"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Broken Lances"  1   0.7   6  0  requires factions { milan, }
                    recruit_pool "English Knights"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Portuguese Knights"  1   0.7   6  0  requires factions { portugal, }
                    recruit_pool "Cossack Cavalry"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Italian MAA"  1   0.7   6  0  requires factions { milan, venice, papal_states, }
                    recruit_pool "Imperial Knights"  1   0.7   6  0  requires factions { hre, }
                    recruit_pool "Chivalric Knights"  1   0.7   6  0  requires factions { france, }
                    recruit_pool "Polish Retainers"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "English Huscarls"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Feudal Knights"  1   0.7   6  0  requires factions { denmark, spain, hungary, } 
                    recruit_pool "Norman Knights"  1   0.7   6  0  requires factions { sicily, } 
                    recruit_pool "Druzhina"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Lancers"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Granadine Jinetes"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Mamluk Archers"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Sipahis"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Mongol Heavy Archers"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Mailed Knights"  1   0.5   4  0  requires factions { england, france, hre, spain, portugal, venice, papal_states, sicily, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { scotland, }
                    recruit_pool "Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Polish Nobles"  1   0.7   6  1  requires factions { poland, } 
                    recruit_pool "Boyar Sons"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Hungarian Nobles"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Byzantine Cavalry"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Arab Cavalry"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkomans"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Light Lancers"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Hobilars"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Border Horse"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Mounted Sergeants"  1   0.7   6  0  requires factions { france, hre, milan, venice, papal_states, sicily, } 
                    recruit_pool "Scouts"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Jinetes"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Polish Shooters"  1   0.5   4  0  requires factions { poland, } 
                    recruit_pool "Kazaks"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "Magyar Cavalry"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Skythikon"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Desert Cavalry"  1   0.5   4  0  requires factions { moors, }
                    recruit_pool "Desert Cavalry"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Turkish Horse Archers"  1   0.2   2  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Horse Archers"  1   0.5   4  0  requires factions { mongols, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { Normans, } 
                }
                material wooden
                construction  4 
                cost  4800 
                settlement_min city
                upgrades
                {
                    earls_stables
                }
            }
            earls_stables castle requires factions { scotland, denmark, hre, france, england, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Kataphractoi"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Broken Lances"  1   0.7   6  0  requires factions { milan, }
                    recruit_pool "Demi Lancers"  1   0.6   6  0  requires factions { england, }
                    recruit_pool "Polish Knights"  1   0.7   6  0  requires factions { poland, }
                    recruit_pool "Italian MAA"  1   0.7   6  0  requires factions { milan, venice, papal_states, }
                    recruit_pool "Gothic Knights"  1   0.5   4  0  requires factions { hre, }
                    recruit_pool "Polish Retainers"  1   0.5   4  0  requires factions { poland, }
                    recruit_pool "English Huscarls"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Noble Knights"  1   0.7   6  0  requires factions { france, }
                    recruit_pool "Hussars"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Dvor Cavalry"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "English Knights"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Chivalric Knights"  1   0.5   4  0  requires factions { france, }
                    recruit_pool "Chivalric Knights"  1   0.7   6  0  requires factions { spain, sicily, denmark, } 
                    recruit_pool "Imperial Knights"  1   0.7   6  0  requires factions { hre, } 
                    recruit_pool "Portuguese Knights"  1   0.7   6  0  requires factions { portugal, } 
                    recruit_pool "Cossack Cavalry"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "E Chivalric Knights"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Latinkon"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Granadine Lancers"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Mamluks"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Sipahi Lancers"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Mongol Heavy Lancers"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Feudal Knights"  1   0.5   4  0  requires factions { denmark, spain, hungary, } 
                    recruit_pool "Norman Knights"  1   0.5   4  0  requires factions { sicily, } 
                    recruit_pool "Druzhina"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Lancers"  1   0.2   2  0  requires factions { byzantium, } 
                    recruit_pool "Granadine Jinetes"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Mamluk Archers"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Sipahis"  1   0.5   4  0  requires factions { turks, } 
                    recruit_pool "Mongol Heavy Archers"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Boyar Sons"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Cavalry"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Arab Cavalry"  1   0.5   4  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkomans"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Light Lancers"  1   0.5   4  0  requires factions { mongols, } 
                    recruit_pool "Hobilars"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Border Horse"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Mounted Sergeants"  1   0.7   6  0  requires factions { france, hre, sicily, papal_states, milan, venice, }  
                    recruit_pool "Scouts"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Jinetes"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Polish Shooters"  1   0.5   4  0  requires factions { poland, } 
                    recruit_pool "Kazaks"  1   0.2   2  0  requires factions { russia, } 
                    recruit_pool "Magyar Cavalry"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Desert Cavalry"  1   0.5   4  0  requires factions { moors, }
                    recruit_pool "Desert Cavalry"  1   0.7   6  0  requires factions { egypt, }
                    recruit_pool "Turkish Horse Archers"  1   0.2   2  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Horse Archers"  1   0.5   4  0  requires factions { mongols, } 
                    recruit_pool "Elephants"  1   0.4   3  0  requires factions { timurids, } 
                    recruit_pool "Mailed Knights"  1   0.2   2  0  requires factions { england, france, spain, sicily, hre, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { scotland, }
                    recruit_pool "Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Polish Nobles"  1   0.7   6  2  requires factions { poland, } 
                    recruit_pool "Hungarian Nobles"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { Normans, }
                    recruit_pool "Mailed Knights"  1   0.5   4  0  requires factions { venice, papal_states, portugal, } 
                }
                material wooden
                construction  5 
                cost  9600 
                settlement_min large_city
                upgrades
                {
                    kings_stables
                }
            }
            kings_stables castle requires factions { denmark, hre, france, middle_eastern, eastern_european, greek, venice, } 
            {
                capability
                {
                    recruit_pool "Broken Lances"  1   0.7   6  0  requires factions { milan, }
                    recruit_pool "Polish Retainers"  1   0.2   2  0  requires factions { poland, }
                    recruit_pool "English Huscarls"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Noble Knights"  1   0.5   4  0  requires factions { france, }
                    recruit_pool "Lancers"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Gothic Knights"  1   0.7   6  0  requires factions { hre, } 
                    recruit_pool "Stradiots"  1   0.7   6  0  requires factions { venice, } 
                    recruit_pool "Polish Guard"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Tsars Guard"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Royal Banderium"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Kataphractoi"  1   0.7   6  1  requires factions { byzantium, } 
                    recruit_pool "Christian Guard"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Royal Mamluks"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Quapukulu"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Khan's Guard"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Reiters"  1   0.7   6  0  requires factions { hre, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "English Knights"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Chivalric Knights"  1   0.7   6  0  requires factions { denmark, spain, sicily, }
                    recruit_pool "Chivalric Knights"  1   0.2   2  0  requires factions { france, }  
                    recruit_pool "Imperial Knights"  1   0.5   4  0  requires factions { hre, } 
                    recruit_pool "Portuguese Knights"  1   0.7   6  0  requires factions { portugal, } 
                    recruit_pool "Italian MAA"  1   0.7   6  0  requires factions { milan, venice, papal_states, } 
                    recruit_pool "Polish Knights"  1   0.5   4  0  requires factions { poland, } 
                    recruit_pool "Dvor Cavalry"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "E Chivalric Knights"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Latinkon"  1   0.5   4  1  requires factions { byzantium, } 
                    recruit_pool "Granadine Lancers"  1   0.5   4  0  requires factions { moors, } 
                    recruit_pool "Mamluks"  1   0.5   4  0  requires factions { egypt, } 
                    recruit_pool "Sipahi Lancers"  1   0.5   4  0  requires factions { turks, } 
                    recruit_pool "Mongol Heavy Lancers"  1   0.5   4  0  requires factions { mongols, timurids, } 
                    recruit_pool "Druzhina"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "Byzantine Lancers"  1   0.2   2  1  requires factions { byzantium, } 
                    recruit_pool "Granadine Jinetes"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Mamluk Archers"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Sipahis"  1   0.2  2   0  requires factions { turks, } 
                    recruit_pool "Mongol Heavy Archers"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Boyar Sons"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Cavalry"  1   0.7   6  1  requires factions { byzantium, } 
                    recruit_pool "Arab Cavalry"  1   0.2   2  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkomans"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Light Lancers"  1   0.5   4  0  requires factions { mongols, } 
                    recruit_pool "Hobilars"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Border Horse"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Mounted Sergeants"  1   0.5   4  0  requires factions { milan, venice, papal_states, }
                    recruit_pool "Mounted Sergeants"  1   0.7   6  0  requires factions { france, hre, sicily, }
                    recruit_pool "Scouts"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Jinetes"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Polish Shooters"  1   0.5   4  0  requires factions { poland, } 
                    recruit_pool "Kazaks"  1   0.2   2  0  requires factions { russia, } 
                    recruit_pool "Magyar Cavalry"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Skythikon"  1   0.5   4  1  requires factions { byzantium, } 
                    recruit_pool "Desert Cavalry"  1   0.5   4  0  requires factions { moors, }
                    recruit_pool "Desert Cavalry"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Turkish Horse Archers"  1   0.2   2  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Horse Archers"  1   0.5   4  0  requires factions { mongols, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { Normans, } 
                    recruit_pool "Hussars"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Elephants"  1   0.4   3  0  requires factions { timurids, } 
                    recruit_pool "Elephant Artillery"  1   0.4   3  0  requires factions { timurids, } 
                    recruit_pool "Feudal Knights"  1   0.5   4  0  requires factions { denmark, spain, hungary, }
                    recruit_pool "Feudal Knights"  1   0.2   2  0  requires factions { hungary, } 
                    recruit_pool "Feudal Knights"  1   0.7   6  0  requires factions { papal_states, }
                    recruit_pool "Norman Knights"  1   0.5   4  0  requires factions { sicily, }  
                    recruit_pool "Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Polish Nobles"  1   0.7   6  3  requires factions { poland, } 
                    recruit_pool "Hungarian Nobles"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Mailed Knights"  1   0.7   6  0  requires factions { Normans, }
                    recruit_pool "Mailed Knights"  1   0.5   4  0  requires factions { venice, portugal, }
                    recruitment_slots bonus +1 
                }
                material wooden
                construction  6 
                cost  9600 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building barracks
    {
        convert_to castle_barracks
        levels town_watch town_guard city_watch militia_drill_square militia_barracks army_barracks royal_armoury 
        {
            town_watch city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Town Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Town Militia"  1   0.7   6  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Archer Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "SE Town Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Town Militia"  1   0.7   6  0  requires factions { moors, turks, mongols, timurids, } 
                    recruit_pool "ME Archer Militia"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                    law_bonus bonus 1
                }
                material wooden
                construction  2 
                cost  600 
                settlement_min town
                upgrades
                {
                    town_guard
                }
            }
            town_guard city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }
                    recruit_pool "SE Spear Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    recruit_pool "Town Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Town Militia"  1   0.7   6  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Archer Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "SE Town Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Town Militia"  1   0.7   6  0  requires factions { moors, turks, mongols, timurids, } 
                    recruit_pool "ME Archer Militia"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                    law_bonus bonus 2
                }
                material wooden
                construction  3 
                cost  1200 
                settlement_min large_town
                upgrades
                {
                    city_watch
                }
            }
            city_watch city requires factions { denmark, hre, france, scotland, england, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 3
                capability
                {
                    recruit_pool "Papal Guard"  1   0.7   6  0  requires factions { papal_states, }
                    recruit_pool "Archer Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Scots Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Crossbow Militia"  1   0.7   6  0  requires factions { france, hre, denmark, spain, portugal, } 
                    recruit_pool "Genoese Crossbow Militia"  1   0.7   6  0  requires factions { milan, } 
                    recruit_pool "Pavise Crossbow Militia"  1   0.7   6  0  requires factions { venice, papal_states, sicily, hungary, } 
                    recruit_pool "EE Crossbow Militia"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "S Archer Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Crossbow Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Saracen Militia"  1   0.7   6  0  requires factions { egypt, turks, } 
                    recruit_pool "Sabadar Militia"  1   0.7   6  0  requires factions { timurids, } 
                    recruit_pool "Spear Militia"  1   0.5   4  0  requires factions { france, hre, }
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, denmark, portugal, spain, Normans, } 
                    recruit_pool "Italian Spear Militia"  1   0.5   4  0  requires factions { papal_states, }
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, sicily, } 
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }
                    recruit_pool "SE Spear Militia"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "ME Spear Militia"  1   0.5   4  0  requires factions { egypt, turks, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  1  requires factions { mongols,  moors, timurids, } 
                    recruit_pool "Town Militia"  1   0.5   4  0  requires factions { england, scotland, france, hre, denmark, spain, Normans, portugal, } 
                    recruit_pool "Italian Militia"  1   0.5   4  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Town Militia"  1   0.5   4  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Archer Militia"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "SE Town Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Town Militia"  1   0.5   4  0  requires factions { moors, turks, timurids, } 
                    recruit_pool "ME Archer Militia"  1   0.5   4  0  requires factions { egypt, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                    recruit_pool "ME Town Militia"  1   0.5   4  0  requires factions { mongols, } 
                    recruit_pool "Town Militia"  1   0.5   4  0  requires factions { Normans, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                    law_bonus bonus 3
                }
                material wooden
                construction  4 
                cost  2400 
                settlement_min city
                upgrades
                {
                    militia_drill_square
                }
            }
            militia_drill_square city requires factions { denmark, hre, france, scotland, england, timurids, moors, egypt, turks, eastern_european, greek, southern_european, } 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Varangian Guard"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Janissary Archers"  1   0.7   6  0  requires factions { turks, }
                    recruit_pool "Tuareg Camel Spearmens"  1   0.7   6  0  requires factions { moors, }
                    recruit_pool "Papal Guard"  1   0.7   6  0  requires factions { papal_states, } 
                    recruit_pool "Bill Militia"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Heavy Pike Militia"  1   0.5   4  0  requires factions { scotland, } 
                    recruit_pool "Partisan Militia"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Halberd Militia"  1   0.5   4  0  requires factions { hre, sicily, poland, hungary, }
                    recruit_pool "Halberd Militia"  1   0.5   4  0  requires factions { papal_states, } 
                    recruit_pool "Swordstaff Militia"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Swordsmen Militia"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.5   4  0  requires factions { milan, venice, } 
                    recruit_pool "EE Cavalry Militia"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "ME Halberd Militia"  1   0.5   4  0  requires factions { egypt, turks, timurids, } 
                    recruit_pool "Archer Militia"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Scots Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Crossbow Militia"  1   0.7   6  0  requires factions { france, hre, denmark, spain, portugal, } 
                    recruit_pool "Genoese Crossbow Militia"  1   0.7   6  0  requires factions { milan, } 
                    recruit_pool "Pavise Crossbow Militia"  1   0.7   6  0  requires factions { venice, papal_states, sicily, hungary, } 
                    recruit_pool "EE Crossbow Militia"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "EE Crossbow Militia"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "S Archer Militia"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "ME Crossbow Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Saracen Militia"  1   0.7   6  0  requires factions { egypt, turks, } 
                    recruit_pool "Sabadar Militia"  1   0.7   6  0  requires factions { timurids, } 
                    recruit_pool "Spear Militia"  1   0.2   2  0  requires factions { france, hre, }
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, denmark, portugal, spain, Normans, }
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, sicily, } 
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }  
                    recruit_pool "SE Spear Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Spear Militia"  1   0.5   4  0  requires factions { egypt, turks, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  1  requires factions { mongols, timurids, moors, } 
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { Normans, } 
                    recruit_pool "Town Militia"  1   0.2   2  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Militia"  1   0.2   2  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Town Militia"  1   0.2   2  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Archer Militia"  1   0.2   2  0  requires factions { russia, } 
                    recruit_pool "SE Town Militia"  1   0.2   2  0  requires factions { byzantium, } 
                    recruit_pool "ME Town Militia"  1   0.2   2  0  requires factions { moors, turks, mongols, timurids, } 
                    recruit_pool "ME Archer Militia"  1   0.2   2  0  requires factions { egypt, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Italian Spear Militia"  1   0.5   4  0  requires factions { papal_states, }
                    law_bonus bonus 4
                }
                material wooden
                construction  5 
                cost  4800 
                settlement_min large_city
                upgrades
                {
                    militia_barracks
                }
            }
            militia_barracks city requires factions { denmark, hre, france, england, timurids, moors, egypt, turks, eastern_european, greek, southern_european, scotland, } 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Voulgier"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Tuareg Camel Spearmens"  1   0.7   6  0  requires factions { moors, }
                    recruit_pool "Janissary Archers"  1   0.7   6  0  requires factions { turks, }
                    recruit_pool "Pike Militia"  1   0.7   6  0  requires factions { papal_states, }
                    recruit_pool "Swiss Guard"  1   0.5   4  0  requires factions { papal_states, } 
                    recruit_pool "Papal Guard"  1   0.7   6  0  requires factions { papal_states, } 
                    recruit_pool "Heavy Bill Militia"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Pike Militia"  1   0.5   4  0  requires factions { hre, spain, portugal, milan, venice, sicily, } 
                    recruit_pool "Berdiche Axemen"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { hungary, russia, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Varangian Guard"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Hand Gunners"  1   0.7   6  0  requires factions { moors, turks, timurids, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Tabardariyya"  1   0.5   4  0  requires factions { egypt, } 
                    recruit_pool "Hand Gunners"  1   0.7   6  0  requires factions { poland, hre, spain, portugal, milan, venice, papal_states, sicily, denmark, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Heavy Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Partisan Militia"  1   0.5   4  0  requires factions { france, } 
                    recruit_pool "Halberd Militia"  1   0.7   6  0  requires factions { hre, sicily, poland, hungary, } 
                    recruit_pool "Swordstaff Militia"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Swordsmen Militia"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.7   6  0  requires factions { milan, venice, } 
                    recruit_pool "EE Cavalry Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Urban Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "ME Halberd Militia"  1   0.7   6  0  requires factions { egypt, turks, timurids, } 
                    recruit_pool "Archer Militia"  1   0.3   2  0  requires factions { england, } 
                    recruit_pool "Scots Pike Militia"  1   0.5   4  0  requires factions { scotland, } 
                    recruit_pool "Crossbow Militia"  1   0.5   4  0  requires factions { france, hre, denmark, spain, portugal, } 
                    recruit_pool "Genoese Crossbow Militia"  1   0.5   4  0  requires factions { milan, } 
                    recruit_pool "Pavise Crossbow Militia"  1   0.5   4  0  requires factions { venice, papal_states, sicily, }
                    recruit_pool "Pavise Crossbow Militia"  1   0.2   2  0  requires factions { hungary, } 
                    recruit_pool "EE Crossbow Militia"  1   0.5   4  0  requires factions { poland, russia, } 
                    recruit_pool "S Archer Militia"  1   0.3   2  0  requires factions { byzantium, } 
                    recruit_pool "ME Crossbow Militia"  1   0.5   4  0  requires factions { moors, } 
                    recruit_pool "Saracen Militia"  1   0.7   6  0  requires factions { egypt, turks, } 
                    recruit_pool "Sabadar Militia"  1   0.7   6  0  requires factions { timurids, } 
                    recruit_pool "Italian Spear Militia"  1   0.2   2  0  requires factions { papal_states, }
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, sicily, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  1  requires factions { mongols, moors, }
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, denmark, portugal, spain, Normans, }
                    recruit_pool "Halberd Militia"  1   0.7   6  0  requires factions { papal_states, }
                    recruit_pool "SE Spear Militia"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }
                    recruit_pool "ME Spear Militia"  1   0.5   4  0  requires factions { egypt, turks, }   
                    law_bonus bonus 5
                }
                material wooden
                construction  6 
                cost  9600 
                settlement_min huge_city
                upgrades
                {
                    army_barracks
                }
            }
            army_barracks city requires factions { denmark, hre, france, england, moors, egypt, turks, poland, russia, southern_european, } 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Tuareg Camel Spearmens"  1   0.7   6  0  requires factions { moors, }
                    recruit_pool "Voulgier"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Forlorn Hope"  1   0.5   4  0  requires factions { hre, }
                    recruit_pool "Gendarmes"  1   0.7   6  0  requires factions { france, spain, }
                    recruit_pool "Janissary Heavy Inf"  1   0.5   4  0  requires factions { turks, }
                    recruit_pool "Pike Militia"  1   0.5   4  0  requires factions { papal_states, }
                    recruit_pool "Cossack Musketeers"  1   0.7   6  0  requires factions { russia, }  and event_counter gunpowder_discovered 1  
                    recruit_pool "Swiss Guard"  1   0.7   6  0  requires factions { papal_states, } 
                    recruit_pool "Papal Guard"  1   0.7   6  0  requires factions { papal_states, } 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { england, france, hre, spain, denmark, milan, venice, papal_states, sicily, poland, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Arquebusiers"  1   0.5   4  0  requires factions { russia, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Portuguese Arquebusiers"  1   0.7   6  0  requires factions { portugal, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Sudanese Gunners"  1   0.7   6  0  requires factions { moors, egypt, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Janissary Archers"  1   0.5   4  0  requires factions { turks, } 
                    recruit_pool "Heavy Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Pike Militia"  1   0.7   6  0  requires factions { hre, spain, portugal, milan, venice, sicily, } 
                    recruit_pool "Berdiche Axemen"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { hungary, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Varangian Guard"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Hand Gunners"  1   0.7   6  0  requires factions { timurids, turks, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "ME Hand Gunners"  1   0.5   4  0  requires factions { moors, }  and event_counter gunpowder_discovered 1
                    recruit_pool "Tabardariyya"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Hand Gunners"  1   0.5   4  0  requires factions { denmark, spain, portugal, milan, venice, poland, hre, sicily, papal_states, }  and event_counter gunpowder_discovered 1
                    recruit_pool "Bill Militia"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Heavy Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Partisan Militia"  1   0.5   4  0  requires factions { france, } 
                    recruit_pool "Halberd Militia"  1   0.7   6  0  requires factions { hre, sicily, poland, hungary, } 
                    recruit_pool "Swordstaff Militia"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Swordsmen Militia"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.7   6  0  requires factions { milan, venice, } 
                    recruit_pool "EE Cavalry Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Infantry"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Urban Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "ME Halberd Militia"  1   0.5   4  0  requires factions { egypt, }
                    recruit_pool "ME Halberd Militia"  1   0.7   6  0  requires factions { turks, timurids, }  
                    recruit_pool "Scots Pike Militia"  1   0.2   2  0  requires factions { scotland, } 
                    recruit_pool "Crossbow Militia"  1   0.2   2  0  requires factions { france, hre, denmark, spain, portugal, } 
                    recruit_pool "Genoese Crossbow Militia"  1   0.2   2  0  requires factions { milan, } 
                    recruit_pool "Pavise Crossbow Militia"  1   0.2   2  0  requires factions { venice, papal_states, sicily, hungary, } 
                    recruit_pool "EE Crossbow Militia"  1   0.2   2  0  requires factions { poland, russia, } 
                    recruit_pool "ME Crossbow Militia"  1   0.2   2  0  requires factions { moors, } 
                    recruit_pool "Saracen Militia"  1   0.7   6  0  requires factions { egypt, turks, } 
                    recruit_pool "Sabadar Militia"  1   0.7   6  0  requires factions { timurids, } 
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, sicily, }  
                    recruit_pool "ME Spear Militia"  1   0.7   6  1  requires factions { mongols, timurids, moors, }
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, denmark, portugal, spain, Normans, }
                    recruit_pool "Halberd Militia"  1   0.5   4  0  requires factions { papal_states, }
                    recruit_pool "SE Spear Militia"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }
                    recruit_pool "ME Spear Militia"  1   0.5   4  0  requires factions { egypt, turks, } 
                    law_bonus bonus 6
                }
                material wooden
                construction  7 
                cost  12000 
                settlement_min huge_city
                upgrades
                {
                    royal_armoury
                }
            }
            royal_armoury city requires factions { turks, venice, milan, portugal, spain, } 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Famiglia Ducale"  1   0.7   6  0  requires factions { milan, } 
                    recruit_pool "Tercio Pikemen"  1   0.7   6  0  requires factions { spain, }
                    recruit_pool "Gendarmes"  1   0.7   6  0  requires factions { france, spain, }
                    recruit_pool "Janissary Heavy Inf"  1   0.7   6  0  requires factions { turks, }
                    recruit_pool "Cossack Musketeers"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Swiss Guard"  1   0.7   6  0  requires factions { papal_states, } 
                    recruit_pool "Papal Guard"  1   0.7   6  0  requires factions { papal_states, }
                    recruit_pool "Musketeers"  1   0.7   6  0  requires factions { spain, portugal, milan, venice, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Janissary Musketeers"  1   0.7   6  0  requires factions { turks, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { england, france, hre, denmark, papal_states, sicily, poland, }  and event_counter gunpowder_discovered 1
                    recruit_pool "Arquebusiers"  1   0.5   4  0  requires factions { spain, milan, venice, russia, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Portuguese Arquebusiers"  1   0.4   4  0  requires factions { portugal, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Sudanese Gunners"  1   0.7   6  0  requires factions { moors, egypt, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Janissary Archers"  1   0.2   2  0  requires factions { turks, } 
                    recruit_pool "Voulgier"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Heavy Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Pike Militia"  1   0.5   4  0  requires factions { spain, }
                    recruit_pool "Pike Militia"  1   0.7   6  0  requires factions { hre, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "Hand Gunners"  1   0.7   6  0  requires factions { denmark, poland, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Berdiche Axemen"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { hungary, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Varangian Guard"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Hand Gunners"  1   0.7   6  0  requires factions { moors, timurids, }  and event_counter gunpowder_discovered 1
                    recruit_pool "ME Hand Gunners"  1   0.5   4  0  requires factions { turks, }  and event_counter gunpowder_discovered 1  
                    recruit_pool "Tabardariyya"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Hand Gunners"  1   0.3   2  0  requires factions { spain, portugal, milan, venice, papal_states, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Hand Gunners"  1   0.7   6  0  requires factions { hre, sicily, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Bill Militia"  1   0.3   2  0  requires factions { england, } 
                    recruit_pool "Heavy Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Partisan Militia"  1   0.3   2  0  requires factions { france, } 
                    recruit_pool "Halberd Militia"  1   0.7   6  0  requires factions { hre, papal_states, sicily, poland, hungary, } 
                    recruit_pool "Swordstaff Militia"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Swordsmen Militia"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.7   6  0  requires factions { venice, }
                    recruit_pool "Italian Cavalry Militia"  1   0.5   4  0  requires factions { milan, } 
                    recruit_pool "EE Cavalry Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Infantry"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Urban Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "ME Halberd Militia"  1   0.7   6  0  requires factions { timurids, }
                    recruit_pool "ME Halberd Militia"  1   0.5   4  0  requires factions { egypt, turks, } 
                    recruit_pool "Crossbow Militia"  1   0.3   2  0  requires factions { france, hre, denmark, spain, portugal, } 
                    recruit_pool "Genoese Crossbow Militia"  1   0.3   2  0  requires factions { milan, } 
                    recruit_pool "Pavise Crossbow Militia"  1   0.3   2  0  requires factions { venice, papal_states, sicily, hungary, } 
                    recruit_pool "EE Crossbow Militia"  1   0.3   2  0  requires factions { poland, russia, } 
                    recruit_pool "ME Crossbow Militia"  1   0.3   2  0  requires factions { moors, } 
                    recruit_pool "Saracen Militia"  1   0.7   6  0  requires factions { egypt, turks, } 
                    recruit_pool "Sabadar Militia"  1   0.7   6  0  requires factions { timurids, } 
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, sicily, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  1  requires factions { mongols, timurids, moors, }
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, denmark, portugal, spain, Normans, }
                    law_bonus bonus 7
                    recruitment_slots bonus +1
                }
                material wooden
                construction  8 
                cost  15000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building castle_barracks
    {
        convert_to barracks
        levels mustering_hall garrison_quarters drill_square barracks armoury 
        {
            mustering_hall castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Theigns"  1   0.2   2  0  requires factions { Saxons, }
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { russia, poland, hungary, }
                    recruit_pool "SE Spear Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  0  requires factions { moors, egypt, turks, mongols, timurids, } 
                    recruit_pool "Town Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Town Militia"  1   0.7   6  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Archer Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "SE Town Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Town Militia"  1   0.7   6  0  requires factions { moors, turks, mongols, timurids, } 
                    recruit_pool "ME Archer Militia"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, }
                }
                material wooden
                construction  1 
                cost  600 
                settlement_min village
                upgrades
                {
                    garrison_quarters
                }
            }
            garrison_quarters castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "Byzantine Infantry"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Theigns"  1   0.5   4  0  requires factions { Saxons, }
                    recruit_pool "Levy Spearmen"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Highlanders"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Sergeant Spearmen"  1   0.7   6  0  requires factions { france, hre, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "Viking Raiders"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Javelinmen"  1   0.7   6  0  requires factions { spain, } 
                    recruit_pool "Lusitanian Javelinmen"  1   0.7   6  0  requires factions { portugal, } 
                    recruit_pool "Woodsmen"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "Slav Levies"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Dismounted Byzantine Lancers"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Nubian Spearmen"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Kurdish Javelinmen"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Turkish Javelinmen"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "ME Levy Spearmen"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Afghan Javelinmen"  1   0.7   6  0  requires factions { timurids, }
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, }
                }
                material wooden
                construction  2 
                cost  1200 
                settlement_min town
                upgrades
                {
                    drill_square
                }
            }
            drill_square castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Dismounted Byzantine Lancers"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Byzantine Infantry"  1   0.5   4  0  requires factions { byzantium, }
                    recruit_pool "Berber Spearmen"  1   0.7   6  0  requires factions { moors, }
                    recruit_pool "Theigns"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Billmen"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Highland Nobles"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Armored Sergeants"  1   0.7   6  0  requires factions { france, hre, milan, venice, papal_states, sicily, Normans, england, } 
                    recruit_pool "Norse Swordsmen"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Almughavars"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "EE Spearmen"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "Croat Axemen"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Nubian Spearmen"  1   0.7   6  0  requires factions { egypt, }
                    recruit_pool "Nubian Spearmen"  1   0.5   4  0  requires factions { moors, } 
                    recruit_pool "Azabs"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Mongol Infantry"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Afghan Javelinmen"  1   0.7   6  1  requires factions { timurids, } 
                    recruit_pool "Dismounted Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Levy Spearmen"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Highlanders"  1   0.5   4  0  requires factions { scotland, } 
                    recruit_pool "Sergeant Spearmen"  1   0.5   4  0  requires factions { france, hre, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "Viking Raiders"  1   0.5   4  0  requires factions { denmark, } 
                    recruit_pool "Javelinmen"  1   0.5   4  0  requires factions { spain, } 
                    recruit_pool "Lusitanian Javelinmen"  1   0.5   4  0  requires factions { portugal, } 
                    recruit_pool "Woodsmen"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "Slav Levies"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Byzantine Spearmen"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Kurdish Javelinmen"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Turkish Javelinmen"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "ME Levy Spearmen"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                }
                material wooden
                construction  3 
                cost  2400 
                settlement_min large_town
                upgrades
                {
                    barracks
                }
            }
            barracks castle requires factions { denmark, hre, france, scotland, england, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Noble Swordsmen"  1   0.7   6  0  requires factions { scotland, }
                    recruit_pool "Dismounted Latinkon"  1   0.7   6  0  requires factions { byzantium, }
                    recruit_pool "Dismounted E Chivalric Knights"  1   0.7   6  0  requires factions { hungary, }
                    recruit_pool "Dismounted Italian MAA"  1   0.7   6  0  requires factions { venice, papal_states, }
                    recruit_pool "Sword and Buckler Men"  1   0.7   6  0  requires factions { spain, }
                    recruit_pool "Dismounted Imperial Knights"  1   0.7   6  0  requires factions { hre, }
                    recruit_pool "Dismounted Chivalric Knights"  1   0.7   6  0  requires factions { france, denmark, }
                    recruit_pool "Heavy Billmen"  1   0.7   6  0  requires factions { england, }
                    recruit_pool "Zweihander"  1   0.7   6  0  requires factions { hre, } 
                    recruit_pool "Dismounted Boyar Sons"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Dismounted Arab Cavalry"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Dismounted Sipahi Lancers"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Dismounted Heavy Archers"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Dismounted Broken Lances"  1   0.7   6  0  requires factions { sicily, milan, } 
                    recruit_pool "Dismounted Feudal Knights"  1   0.7   6  0  requires factions { portugal, } 
                    recruit_pool "Dismounted Polish Nobles"  1   0.7   6  0  requires factions { poland, }
                    recruit_pool "Theigns"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Dismounted Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Armored Swordsmen"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Highland Pikemen"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Norse Axemen"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Venetian Heavy Infantry"  1   0.7   6  0  requires factions { venice, } 
                    recruit_pool "Dismounted Druchima"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Pavise Spearmen"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Lamtuna Spearmen"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Naffatun"  1   0.7   6  0  requires factions { egypt, turks, mongols, timurids, } 
                    recruit_pool "Billmen"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Highland Nobles"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Armored Sergeants"  1   0.7   6  1  requires factions { france, hre, milan, papal_states, sicily, england, venice, Normans, } 
                    recruit_pool "Norse Swordsmen"  1   0.5   4  0  requires factions { denmark, } 
                    recruit_pool "Almughavars"  1   0.7   6  1  requires factions { spain, portugal, } 
                    recruit_pool "EE Spearmen"  1   0.7   6  1  requires factions { russia, }
                    recruit_pool "EE Spearmen"  1   0.5   4  0  requires factions { poland, } 
                    recruit_pool "Croat Axemen"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Dismounted Byzantine Lancers"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Berber Spearmen"  1   0.5   4  0  requires factions { moors, }
                    recruit_pool "Nubian Spearmen"  1   0.5   4  0  requires factions { egypt, }
                    recruit_pool "Nubian Spearmen"  1   0.2   2  0  requires factions { moors, } 
                    recruit_pool "Azabs"  1   0.5   4  0  requires factions { turks, } 
                    recruit_pool "Mongol Infantry"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Afghan Javelinmen"  1   0.7   6  1  requires factions { timurids, } 
                    recruit_pool "Levy Spearmen"  1   0.2   2  0  requires factions { england, } 
                    recruit_pool "Highlanders"  1   0.5   4  0  requires factions { scotland, } 
                    recruit_pool "Sergeant Spearmen"  1   0.5   4  1  requires factions { france, hre, milan, papal_states, sicily, venice, Normans, } 
                    recruit_pool "Viking Raiders"  1   0.5   4  0  requires factions { denmark, } 
                    recruit_pool "Javelinmen"  1   0.2   2  1  requires factions { spain, } 
                    recruit_pool "Lusitanian Javelinmen"  1   0.2   2  1  requires factions { portugal, } 
                    recruit_pool "Woodsmen"  1   0.7   6  0  requires factions { poland, }
                    recruit_pool "Woodsmen"  1   0.2   2  0  requires factions { russia, }  
                    recruit_pool "Slav Levies"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Byzantine Spearmen"  1   0.7   6  2  requires factions { byzantium, } 
                    recruit_pool "Kurdish Javelinmen"  1   0.5   4  0  requires factions { egypt, } 
                    recruit_pool "Turkish Javelinmen"  1   0.5   4  0  requires factions { turks, } 
                    recruit_pool "ME Levy Spearmen"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Byzantine Infantry"  1   0.2   2  0  requires factions { byzantium, } 
                }
                material wooden
                construction  4 
                cost  4800 
                settlement_min city
                upgrades
                {
                    armoury
                }
            }
            armoury castle requires factions { denmark, hre, france, scotland, england, turks, egypt, moors, hungary, greek, sicily, venice, portugal, spain, } 
            {
                convert_to 3
                capability
                {
                    recruit_pool "Varangian Guard"  1   0.7   6  1  requires factions { byzantium, }
                    recruit_pool "Tabardariyya"  1   0.7   6  1  requires factions { egypt, } 
                    recruit_pool "Janissary Heavy Inf"  1   0.7   6  1  requires factions { turks, }
                    recruit_pool "Sword and Buckler Men"  1   0.5   4  0  requires factions { spain, }
                    recruit_pool "Dismounted Gothic Knights"  1   0.7   6  0  requires factions { hre, } 
                    recruit_pool "Dismounted Noble Knights"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Dismounted Imperial Knights"  1   0.7   6  0  requires factions { hre, }
                    recruit_pool "Dismounted Chivalric Knights"  1   0.7   6  0  requires factions { spain, france, denmark, } 
                    recruit_pool "Dismounted Italian MAA"  1   0.7   6  0  requires factions { venice, papal_states, } 
                    recruit_pool "Dismounted Norman Knights"  1   0.7   6  0  requires factions { sicily, } 
                    recruit_pool "Dismounted Boyar Sons"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Dismounted E Chivalric Knights"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Dismounted Arab Cavalry"  1   0.7   6  1  requires factions { moors, egypt, } 
                    recruit_pool "Dismounted Sipahi Lancers"  1   0.7   6  1  requires factions { turks, } 
                    recruit_pool "Dismounted Heavy Archers"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Dismounted English Knights"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Dismounted Portuguese Knights"  1   0.7   6  0  requires factions { portugal, } 
                    recruit_pool "Dismounted Feudal Knights"  1   0.7   6  0  requires factions { portugal, hungary, } 
                    recruit_pool "Dismounted Polish Nobles"  1   0.7   6  0  requires factions { poland, }
                    recruit_pool "Theigns"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Noble Swordsmen"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Pikemen"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Dismounted Broken Lances"  1   0.5   4  0  requires factions { sicily, milan, } 
                    recruit_pool "Dismounted Christian Guard"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Heavy Billmen"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Noble Pikemen"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Obudshaer"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Armored Swordsmen"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Highland Pikemen"  1   0.5   4  0  requires factions { scotland, } 
                    recruit_pool "Zweihander"  1   0.5   4  0  requires factions { hre, } 
                    recruit_pool "Norse Axemen"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Aventuros"  1   0.7   6  0  requires factions { portugal, } 
                    recruit_pool "Venetian Heavy Infantry"  1   0.7   6  1  requires factions { venice, } 
                    recruit_pool "Dismounted Druchima"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Pavise Spearmen"  1   0.7   6  1  requires factions { hungary, } 
                    recruit_pool "Dismounted Latinkon"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Lamtuna Spearmen"  1   0.7   6  1  requires factions { moors, } 
                    recruit_pool "Naffatun"  1   0.7   6  1  requires factions { egypt, turks, } 
                    recruit_pool "Naffatun"  1   0.7   6  0  requires factions { mongols, timurids, } 
                    recruit_pool "Dismounted Huscarls"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Billmen"  1   0.2   2  0  requires factions { england, } 
                    recruit_pool "Highland Nobles"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Armored Sergeants"  1   0.7   6  1  requires factions { hre, milan, venice, papal_states, sicily, england, france, }
                    recruit_pool "Norse Swordsmen"  1   0.5   4  0  requires factions { denmark, } 
                    recruit_pool "Almughavars"  1   0.7   6  1  requires factions { spain, portugal, } 
                    recruit_pool "EE Spearmen"  1   0.7   6  1  requires factions { poland, russia, } 
                    recruit_pool "Croat Axemen"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Dismounted Byzantine Lancers"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Berber Spearmen"  1   0.5   4  1  requires factions { moors, } 
                    recruit_pool "Nubian Spearmen"  1   0.5   4  1  requires factions { egypt, }
                    recruit_pool "Nubian Spearmen"  1   0.2   2  1  requires factions { moors, }
                    recruit_pool "Azabs"  1   0.5   4  1  requires factions { turks, } 
                    recruit_pool "Mongol Infantry"  1   0.7   6  1  requires factions { mongols, } 
                    recruit_pool "Afghan Javelinmen"  1   0.7   6  1  requires factions { timurids, } 
                    recruit_pool "Armored Sergeants"  1   0.7   6  0  requires factions { Normans, } 
                    recruit_pool "Levy Spearmen"  1   0.2   2  0  requires factions { england, } 
                    recruit_pool "Highlanders"  1   0.2   2  0  requires factions { scotland, } 
                    recruit_pool "Sergeant Spearmen"  1   0.5   4  1  requires factions { france, hre, milan, venice, papal_states, sicily, } 
                    recruit_pool "Viking Raiders"  1   0.5   4  0  requires factions { denmark, } 
                    recruit_pool "Woodsmen"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "Slav Levies"  1   0.2   2  0  requires factions { hungary, } 
                    recruit_pool "Byzantine Spearmen"  1   0.7   6  4  requires factions { byzantium, } 
                    recruit_pool "Kurdish Javelinmen"  1   0.5   4  1  requires factions { egypt, } 
                    recruit_pool "Turkish Javelinmen"  1   0.5   4  1  requires factions { turks, } 
                    recruit_pool "ME Levy Spearmen"  1   0.7   6  1  requires factions { mongols, } 
                    recruit_pool "Sergeant Spearmen"  1   0.7   6  0  requires factions { Normans, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, }
                    recruit_pool "Byzantine Infantry"  1   0.2   2  0  requires factions { byzantium, }
                    recruitment_slots bonus +1 
                }
                material wooden
                construction  6 
                cost  9600 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building missiles
    {
        levels bowyer practice_range archery_range marksmans_range 
        {
            bowyer castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
    	        recruit_pool "Irish Kerns Mercs"  1   0.7   6  0  requires factions { scotland, }
                    recruit_pool "Peasant Archers"  1   0.7   6  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "S Peasant Archers"  1   0.7   6  0  requires factions { sicily, hungary, byzantium, } 
                    recruit_pool "EE Peasant Archers"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "Sudanese Javelinmen"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "ME Peasant Archers"  1   0.7   6  0  requires factions { egypt, turks, mongols, timurids, } 
                }
                material wooden
                construction  2 
                cost  1200 
                settlement_min town
                upgrades
                {
                    practice_range
                }
            }
            practice_range castle requires factions { denmark, hre, scotland, france, england, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Longbowmen"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Highland Archers"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Peasant Crossbowmen"  1   0.7   6  0  requires factions { france, hre, spain, portugal, milan, venice, papal_states, } 
                    recruit_pool "Norse Archers"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Sicilian Muslim Archers"  1   0.7   6  0  requires factions { sicily, } 
                    recruit_pool "Lithuanian Archers"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Bosnian Archers"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Trebizond Archers"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Desert Archers"  1   0.7   6  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkish Archers"  1   0.7   6  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Foot Archers"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Peasant Archers"  1   0.5   4  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "S Peasant Archers"  1   0.5   4  0  requires factions { sicily, hungary, byzantium, } 
                    recruit_pool "EE Peasant Archers"  1   0.5   4  0  requires factions { poland, } 
                    recruit_pool "EE Peasant Archers"  1   0.7   6  1  requires factions { russia, } 
                    recruit_pool "Sudanese Javelinmen"  1   0.5   4  0  requires factions { moors, } 
                    recruit_pool "ME Peasant Archers"  1   0.5   4  0  requires factions { egypt, turks, mongols, timurids, }
    	        recruit_pool "Irish Kerns Mercs"  1   0.7   6  0  requires factions { scotland, } 
                }
                material wooden
                construction  3 
                cost  2400 
                settlement_min large_town
                upgrades
                {
                    archery_range
                }
            }
            archery_range castle requires factions { denmark, hre, scotland, france, england, egypt, turks, moors, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Granadine CB Cav"  1   0.7   6  0  requires factions { moors, }
                    recruit_pool "Yeoman Archers"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Noble Highland Archers"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Crossbowmen"  1   0.7   6  0  requires factions { france, denmark, hungary, } 
                    recruit_pool "Pavise Crossbowmen"  1   0.7   6  0  requires factions { hre, spain, portugal, papal_states, sicily, } 
                    recruit_pool "Genoese Crossbowmen"  1   0.7   6  0  requires factions { milan, } 
                    recruit_pool "Venetian Archers"  1   0.7   6  0  requires factions { venice, } 
                    recruit_pool "Lithuanian Cavalry"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Dismounted Dvor"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Guard Archers"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Peasant Crossbowmen"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Nubian Archers"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Ottoman Infantry"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Longbowmen"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Highland Archers"  1   0.5   4  0  requires factions { scotland, } 
                    recruit_pool "Peasant Crossbowmen"  1   0.5   4  0  requires factions { france, hre, spain, portugal, milan, papal_states, venice, } 
                    recruit_pool "Norse Archers"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Sicilian Muslim Archers"  1   0.5   4  0  requires factions { sicily, } 
                    recruit_pool "Lithuanian Archers"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Bosnian Archers"  1   0.5   4  0  requires factions { hungary, } 
                    recruit_pool "Trebizond Archers"  1   0.5   4  0  requires factions { byzantium, } 
                    recruit_pool "Desert Archers"  1   0.5   4  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkish Archers"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Foot Archers"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Peasant Archers"  1   0.2  2  0  requires factions { england, france, hre, denmark, spain, portugal, milan, venice, papal_states, Normans, Saxons, } 
                    recruit_pool "S Peasant Archers"  1   0.2   2  0  requires factions { sicily, hungary, byzantium, } 
                    recruit_pool "EE Peasant Archers"  1   0.4   4  1  requires factions { russia, poland, } 
                    recruit_pool "Sudanese Javelinmen"  1   0.2   2  0  requires factions { moors, } 
                    recruit_pool "ME Peasant Archers"  1   0.2   2  0  requires factions { egypt, turks, mongols, timurids, }
    	        recruit_pool "Irish Kerns Mercs"  1   0.5   4  0  requires factions { scotland, } 
                }
                material wooden
                construction  4 
                cost  4800 
                settlement_min city
                upgrades
                {
                    marksmans_range
                }
            }
            marksmans_range castle requires factions { denmark, hre, france, england, egypt, turks, moors, southern_european, } 
            {
                capability
                {
                    recruit_pool "Peasant Crossbowmen"  1   0.5   4  0  requires factions { venice, milan, papal_states, spain, }
                    recruit_pool "Dismounted Longbowmen"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Aventurier"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Mounted Crossbowmen"  1   0.7   6  0  requires factions { hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "Camel Gunners"  1   0.7   6  0  requires factions { moors, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Granadine CB Cav"  1   0.5   4  0  requires factions { moors, } 
                    recruit_pool "Yeoman Archers"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Noble Highland Archers"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Crossbowmen"  1   0.5   4  0  requires factions { france, }
                    recruit_pool "Crossbowmen"  1   0.7   6  0  requires factions { denmark, hungary, } 
                    recruit_pool "Pavise Crossbowmen"  1   0.7   6  0  requires factions { hre, spain, portugal, papal_states, sicily, } 
                    recruit_pool "Genoese Crossbowmen"  1   0.7   6  0  requires factions { milan, } 
                    recruit_pool "Venetian Archers"  1   0.7   6  0  requires factions { venice, } 
                    recruit_pool "Lithuanian Cavalry"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Byzantine Guard Archers"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Peasant Crossbowmen"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Nubian Archers"  1   0.7   6  1  requires factions { egypt, } 
                    recruit_pool "Ottoman Infantry"  1   0.7   6  1  requires factions { turks, } 
                    recruit_pool "Longbowmen"  1   0.2   2  0  requires factions { england, } 
                    recruit_pool "Highland Archers"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Peasant Crossbowmen"  1   0.2   2  0  requires factions { france, hre, }
                    recruit_pool "Peasant Crossbowmen"  1   0.5   4  0  requires factions { portugal, } 
                    recruit_pool "Norse Archers"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Sicilian Muslim Archers"  1   0.5   4  0  requires factions { sicily, } 
                    recruit_pool "Lithuanian Archers"  1   0.7   6  0  requires factions { poland, } 
                    recruit_pool "Bosnian Archers"  1   0.7   6  0  requires factions { hungary, } 
                    recruit_pool "Trebizond Archers"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Desert Archers"  1   0.5   4  0  requires factions { moors, egypt, } 
                    recruit_pool "Turkish Archers"  1   0.5   4  0  requires factions { turks, timurids, } 
                    recruit_pool "Mongol Foot Archers"  1   0.7   6  0  requires factions { mongols, }
                    recruit_pool "ME Peasant Archers"  1   0.2   2  0  requires factions { egypt, turks, mongols, timurids, }
    	        recruit_pool "Irish Kerns Mercs"  1   0.5   4  0  requires factions { scotland, }
                    recruitment_slots bonus +1 
                }
                material wooden
                construction  5 
                cost  9600 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building siege
    {
        convert_to castle_siege
        levels ballista_range catapult_range siege_works 
        {
            ballista_range city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "NE Ballista"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Ballista"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Ballista"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Ballista"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Ballista"  1   0.5   1  0  requires factions { mongols, timurids, } 
                }
                material wooden
                construction  1 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                    catapult_range
                }
            }
            catapult_range city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "NE Catapult"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Catapult"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Catapult"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Catapult"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Catapult"  1   0.5   1  0  requires factions { mongols, timurids, } 
                    recruit_pool "NE Ballista"  1   0.5   1  1  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Ballista"  1   0.5   1  1  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Ballista"  1   0.5   1  1  requires factions { byzantium, } 
                    recruit_pool "ME Ballista"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Ballista"  1   0.5   1  1  requires factions { mongols, timurids, } 
                }
                material wooden
                construction  2 
                cost  3200 
                settlement_min large_town
                upgrades
                {
                    siege_works
                }
            }
            siege_works city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "NE Trebuchet"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Trebuchet"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Trebuchet"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Trebuchet"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Trebuchet"  1   0.5   1  0  requires factions { mongols, timurids, } 
                    recruit_pool "NE Catapult"  1   0.5   1  1  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Catapult"  1   0.5   1  1  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Catapult"  1   0.5   1  1  requires factions { byzantium, } 
                    recruit_pool "ME Catapult"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Catapult"  1   0.5   1  1  requires factions { mongols, timurids, } 
                    recruit_pool "NE Ballista"  1   0.5   1  2  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Ballista"  1   0.5   1  2  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Ballista"  1   0.5   1  2  requires factions { byzantium, } 
                    recruit_pool "ME Ballista"  1   0.5   1  2  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Ballista"  1   0.5   1  2  requires factions { mongols, timurids, } 
                }
                material wooden
                construction  3 
                cost  6400 
                settlement_min city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building castle_siege
    {
        levels c_ballista_range c_catapult_range c_siege_works 
        {
            c_ballista_range castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "NE Ballista"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Ballista"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Ballista"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Ballista"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Ballista"  1   0.5   1  0  requires factions { mongols, timurids, } 
                }
                material wooden
                construction  1 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                    c_catapult_range
                }
            }
            c_catapult_range castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "NE Catapult"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Catapult"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Catapult"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Catapult"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Catapult"  1   0.5   1  0  requires factions { mongols, timurids, } 
                    recruit_pool "NE Ballista"  1   0.5   1  1  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Ballista"  1   0.5   1  1  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Ballista"  1   0.5   1  1  requires factions { byzantium, } 
                    recruit_pool "ME Ballista"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Ballista"  1   0.5   1  1  requires factions { mongols, timurids, } 
                }
                material wooden
                construction  2 
                cost  3200 
                settlement_min large_town
                upgrades
                {
                    c_siege_works
                }
            }
            c_siege_works castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "NE Trebuchet"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Trebuchet"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Trebuchet"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Trebuchet"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Trebuchet"  1   0.5   1  0  requires factions { mongols, timurids, } 
                    recruit_pool "NE Catapult"  1   0.5   1  1  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Catapult"  1   0.5   1  1  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Catapult"  1   0.5   1  1  requires factions { byzantium, } 
                    recruit_pool "ME Catapult"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Catapult"  1   0.5   1  1  requires factions { mongols, timurids, } 
                    recruit_pool "NE Ballista"  1   0.5   1  2  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, Normans, } 
                    recruit_pool "EE Ballista"  1   0.5   1  2  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Ballista"  1   0.5   1  2  requires factions { byzantium, } 
                    recruit_pool "ME Ballista"  1   0.5   1  2  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Ballista"  1   0.5   1  2  requires factions { mongols, timurids, } 
                }
                material wooden
                construction  3 
                cost  6400 
                settlement_min large_town
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building cannon
    {
        convert_to castle_cannon
        levels gunsmith cannon_maker cannon_foundry royal_arsenal 
        {
            gunsmith city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 0
                capability
                {
                    recruit_pool "NE Bombard"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  0  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  0  requires factions { timurids, } 
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min city
                upgrades
                {
                    cannon_maker
                }
            }
            cannon_maker city requires factions { northern_european, timurids, egypt, moors, turks, eastern_european, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 1
                capability
                {
                    recruit_pool "NE Mortar"  1   0.5   1  0  requires factions { england, scotland, venice, papal_states, sicily, } 
                    recruit_pool "NE Grand Bombard"  1   0.5   1  0  requires factions { france, hre, spain, portugal, milan, } 
                    recruit_pool "NE Ribault"  1   0.5   1  0  requires factions { denmark, } 
                    recruit_pool "EE Ribault"  1   0.5   1  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Grand Bombard"  1   0.5   1  0  requires factions { russia, } 
                    recruit_pool "ME Grand Bombard"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Grand Bombard"  1   0.5   1  0  requires factions { timurids, } 
                    recruit_pool "NE Ribault"  1   0.5   1  0  requires factions { england, scotland, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "NE Bombard"  1   0.5   1  1  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  1  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  1  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  1  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  1  requires factions { timurids, } 
                    weapon_naval_gunpowder 1
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_city
                upgrades
                {
                    cannon_foundry
                }
            }
            cannon_foundry city requires factions { northern_european, egypt, timurids, moors, turks, eastern_european, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 2
                capability
                {
                    recruit_pool "NE Culverin"  1   0.5   1  0  requires factions { england, scotland, france, spain, portugal, milan, venice, papal_states, } 
                    recruit_pool "NE Cannon"  1   0.5   1  0  requires factions { hre, sicily, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  0  requires factions { denmark, } 
                    recruit_pool "EE Serpentine"  1   0.5   1  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Cannon"  1   0.5   1  0  requires factions { russia, } 
                    recruit_pool "ME Cannon"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Cannon"  1   0.5   1  0  requires factions { timurids, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  0  requires factions { france, hre, } 
                    recruit_pool "NE Cannon"  1   0.5   1  0  requires factions { denmark, } 
                    recruit_pool "EE Cannon"  1   0.5   1  0  requires factions { poland, } 
                    recruit_pool "NE Mortar"  1   0.5   1  1  requires factions { england, scotland, venice, papal_states, sicily, } 
                    recruit_pool "NE Grand Bombard"  1   0.5   1  1  requires factions { france, hre, spain, portugal, milan, } 
                    recruit_pool "NE Ribault"  1   0.5   1  1  requires factions { denmark, } 
                    recruit_pool "EE Ribault"  1   0.5   1  1  requires factions { poland, hungary, } 
                    recruit_pool "EE Grand Bombard"  1   0.5   1  1  requires factions { russia, } 
                    recruit_pool "ME Grand Bombard"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Grand Bombard"  1   0.5   1  1  requires factions { timurids, } 
                    recruit_pool "NE Ribault"  1   0.5   1  1  requires factions { england, scotland, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "NE Bombard"  1   0.5   1  2  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  2  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  2  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  2  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  2  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  2  requires factions { timurids, } 
                    weapon_naval_gunpowder 1
                }
                material wooden
                construction  3 
                cost  3200 
                settlement_min huge_city
                upgrades
                {
                    royal_arsenal
                }
            }
            royal_arsenal city requires factions { hre, france, turks, hungary, russia, venice, milan, portugal, spain, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 3
                capability
                {
                    recruit_pool "NE Basilisk"  1   0.5   1  0  requires factions { france, hre, spain, portugal, } 
                    recruit_pool "NE Monster Ribault"  1   0.5   1  0  requires factions { milan, venice, } 
                    recruit_pool "EE Basilisk"  1   0.5   1  0  requires factions { russia, hungary, } 
                    recruit_pool "ME Monster Bombard"  1   0.5   1  0  requires factions { turks, } 
                    recruit_pool "NE Culverin"  1   0.5   1  1  requires factions { england, scotland, france, spain, portugal, milan, venice, papal_states, } 
                    recruit_pool "NE Cannon"  1   0.5   1  1  requires factions { hre, sicily, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  1  requires factions { denmark, } 
                    recruit_pool "EE Serpentine"  1   0.5   1  1  requires factions { poland, hungary, } 
                    recruit_pool "EE Cannon"  1   0.5   1  1  requires factions { russia, } 
                    recruit_pool "ME Cannon"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Cannon"  1   0.5   1  1  requires factions { timurids, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  1  requires factions { france, hre, } 
                    recruit_pool "NE Cannon"  1   0.5   1  1  requires factions { denmark, } 
                    recruit_pool "EE Cannon"  1   0.5   1  1  requires factions { poland, } 
                    recruit_pool "NE Mortar"  1   0.5   1  2  requires factions { england, scotland, venice, papal_states, sicily, } 
                    recruit_pool "NE Grand Bombard"  1   0.5   1  2  requires factions { france, hre, spain, portugal, milan, } 
                    recruit_pool "NE Ribault"  1   0.5   1  2  requires factions { denmark, } 
                    recruit_pool "EE Ribault"  1   0.5   1  2  requires factions { poland, hungary, } 
                    recruit_pool "EE Grand Bombard"  1   0.5   1  2  requires factions { russia, } 
                    recruit_pool "ME Grand Bombard"  1   0.5   1  2  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Grand Bombard"  1   0.5   1  2  requires factions { timurids, } 
                    recruit_pool "NE Ribault"  1   0.5   1  2  requires factions { england, scotland, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "NE Bombard"  1   0.5   1  3  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  3  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  3  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  3  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  3  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  3  requires factions { timurids, } 
                    weapon_naval_gunpowder 1
                }
                material wooden
                construction  4 
                cost  6400 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building castle_cannon
    {
        convert_to cannon
        levels c_gunsmith c_cannon_maker c_cannon_foundry c_royal_arsenal 
        {
            c_gunsmith castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 0
                capability
                {
                    recruit_pool "NE Bombard"  1   0.5   1  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  0  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  0  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  0  requires factions { timurids, } 
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min city
                upgrades
                {
                    c_cannon_maker
                }
            }
            c_cannon_maker castle requires factions { northern_european, timurids, egypt, moors, turks, eastern_european, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 1
                capability
                {
                    recruit_pool "NE Mortar"  1   0.5   1  0  requires factions { england, scotland, venice, papal_states, sicily, } 
                    recruit_pool "NE Grand Bombard"  1   0.5   1  0  requires factions { france, hre, spain, portugal, milan, } 
                    recruit_pool "NE Ribault"  1   0.5   1  0  requires factions { denmark, } 
                    recruit_pool "EE Ribault"  1   0.5   1  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Grand Bombard"  1   0.5   1  0  requires factions { russia, } 
                    recruit_pool "ME Grand Bombard"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Grand Bombard"  1   0.5   1  0  requires factions { timurids, } 
                    recruit_pool "NE Ribault"  1   0.5   1  0  requires factions { england, scotland, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "NE Bombard"  1   0.5   1  1  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  1  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  1  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  1  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  1  requires factions { timurids, } 
                    weapon_naval_gunpowder 1
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min city
                upgrades
                {
                    c_cannon_foundry
                }
            }
            c_cannon_foundry castle requires factions { northern_european, egypt, timurids, moors, turks, eastern_european, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 2
                capability
                {
                    recruit_pool "NE Culverin"  1   0.5   1  0  requires factions { england, scotland, france, spain, portugal, milan, venice, papal_states, } 
                    recruit_pool "NE Cannon"  1   0.5   1  0  requires factions { hre, sicily, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  0  requires factions { denmark, } 
                    recruit_pool "EE Serpentine"  1   0.5   1  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Cannon"  1   0.5   1  0  requires factions { russia, } 
                    recruit_pool "ME Cannon"  1   0.5   1  0  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Cannon"  1   0.5   1  0  requires factions { timurids, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  0  requires factions { france, hre, } 
                    recruit_pool "NE Cannon"  1   0.5   1  0  requires factions { denmark, } 
                    recruit_pool "EE Cannon"  1   0.5   1  0  requires factions { poland, } 
                    recruit_pool "NE Mortar"  1   0.5   1  1  requires factions { england, scotland, venice, papal_states, sicily, } 
                    recruit_pool "NE Grand Bombard"  1   0.5   1  1  requires factions { france, hre, spain, portugal, milan, } 
                    recruit_pool "NE Ribault"  1   0.5   1  1  requires factions { denmark, } 
                    recruit_pool "EE Ribault"  1   0.5   1  1  requires factions { poland, hungary, } 
                    recruit_pool "EE Grand Bombard"  1   0.5   1  1  requires factions { russia, } 
                    recruit_pool "ME Grand Bombard"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Grand Bombard"  1   0.5   1  1  requires factions { timurids, } 
                    recruit_pool "NE Ribault"  1   0.5   1  1  requires factions { england, scotland, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "NE Bombard"  1   0.5   1  2  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  2  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  2  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  2  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  2  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  2  requires factions { timurids, } 
                    weapon_naval_gunpowder 1
                }
                material wooden
                construction  3 
                cost  3200 
                settlement_min city
                upgrades
                {
                    c_royal_arsenal
                }
            }
            c_royal_arsenal castle requires factions { hre, france, turks, hungary, russia, venice, milan, portugal, spain, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 3
                capability
                {
                    recruit_pool "NE Basilisk"  1   0.5   1  0  requires factions { france, hre, spain, portugal, } 
                    recruit_pool "NE Monster Ribault"  1   0.5   1  0  requires factions { milan, venice, } 
                    recruit_pool "EE Basilisk"  1   0.5   1  0  requires factions { russia, hungary, } 
                    recruit_pool "ME Monster Bombard"  1   0.5   1  0  requires factions { turks, } 
                    recruit_pool "NE Culverin"  1   0.5   1  1  requires factions { england, scotland, france, spain, portugal, milan, venice, papal_states, } 
                    recruit_pool "NE Cannon"  1   0.5   1  1  requires factions { hre, sicily, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  1  requires factions { denmark, } 
                    recruit_pool "EE Serpentine"  1   0.5   1  1  requires factions { poland, hungary, } 
                    recruit_pool "EE Cannon"  1   0.5   1  1  requires factions { russia, } 
                    recruit_pool "ME Cannon"  1   0.5   1  1  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Cannon"  1   0.5   1  1  requires factions { timurids, } 
                    recruit_pool "NE Serpentine"  1   0.5   1  1  requires factions { france, hre, } 
                    recruit_pool "NE Cannon"  1   0.5   1  1  requires factions { denmark, } 
                    recruit_pool "EE Cannon"  1   0.5   1  1  requires factions { poland, } 
                    recruit_pool "NE Mortar"  1   0.5   1  2  requires factions { england, scotland, venice, papal_states, sicily, } 
                    recruit_pool "NE Grand Bombard"  1   0.5   1  2  requires factions { france, hre, spain, portugal, milan, } 
                    recruit_pool "NE Ribault"  1   0.5   1  2  requires factions { denmark, } 
                    recruit_pool "EE Ribault"  1   0.5   1  2  requires factions { poland, hungary, } 
                    recruit_pool "EE Grand Bombard"  1   0.5   1  2  requires factions { russia, } 
                    recruit_pool "ME Grand Bombard"  1   0.5   1  2  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Grand Bombard"  1   0.5   1  2  requires factions { timurids, } 
                    recruit_pool "NE Ribault"  1   0.5   1  2  requires factions { england, scotland, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "NE Bombard"  1   0.5   1  3  requires factions { england, scotland, france, hre, denmark, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Bombard"  1   0.5   1  3  requires factions { poland, russia, hungary, } 
                    recruit_pool "GR Bombard"  1   0.5   1  3  requires factions { byzantium, } 
                    recruit_pool "ME Bombard"  1   0.5   1  3  requires factions { moors, egypt, turks, } 
                    recruit_pool "AS Rocket Launcher"  1   0.5   1  3  requires factions { mongols, } 
                    recruit_pool "AS Bombard"  1   0.5   1  3  requires factions { timurids, } 
                    weapon_naval_gunpowder 1
                }
                material wooden
                construction  4 
                cost  6400 
                settlement_min city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building urban_equestrian
    {
        levels racing_track sultans_racing_track 
        {
            racing_track city requires factions { middle_eastern, } 
            {
                capability
                {
                    recruit_pool "Turkomans"  1   0.4   1  0  requires factions { turks, timurids, }
                    recruit_pool "Desert Cavalry"  1   0.4   1  0  requires factions { moors, egypt, }
                    happiness_bonus bonus 1
                    stage_races 1
                }
                material wooden
                construction  4 
                cost  1200 
                settlement_min city
                upgrades
                {
                    sultans_racing_track
                }
            }
            sultans_racing_track city requires factions { middle_eastern, } 
            {
                capability
                {
                    recruit_pool "Turkomans"  1   0.4   1  0  requires factions { turks, timurids, }
                    recruit_pool "Desert Cavalry"  1   0.4   1  0  requires factions { moors, egypt, }
                    happiness_bonus bonus 2
                    stage_races 2
                }
                material wooden
                construction  5 
                cost  1200 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building port
    {
        convert_to castle_port
        levels port shipwright dockyard naval_drydock 
        {
            port city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "cog"  1   0.7   4   0  requires factions { hre, france, scotland, england, } 
                    recruit_pool "longboat"  1   0.7   4   0  requires factions { denmark, } 
                    recruit_pool "dhow"  1   0.7   4   0  requires factions { middle_eastern, } 
                    recruit_pool "cog"  1   0.7   4   0  requires factions { hungary, poland, } 
                    recruit_pool "ladya"  1   0.7   4   0  requires factions { russia, } 
                    recruit_pool "dromon"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "galley"  1   0.7   4   0  requires factions { sicily, papal_states, milan, venice, } 
                    recruit_pool "cog"  1   0.7   4   0  requires factions { portugal, spain, } 
                    trade_base_income_bonus bonus 2
                }
                material wooden
                construction  2 
                cost  800 
                settlement_min large_town
                upgrades
                {
                    shipwright
                }
            }
            shipwright city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "cog"  1   0.7   4   0  requires factions { hre, france, scotland, england, } 
                    recruit_pool "longboat"  1   0.7   4   0  requires factions { denmark, } 
                    recruit_pool "holk"  1   0.7   4   0  requires factions { hre, scotland, france, england, } 
                    recruit_pool "dragon boat"  1   0.7   4   0  requires factions { denmark, } 
                    recruit_pool "dhow"  1   0.7   4   0  requires factions { middle_eastern, } 
                    recruit_pool "war galley"  1   0.7   4   0  requires factions { egypt, moors, turks, } 
                    recruit_pool "cog"  1   0.7   4   0  requires factions { hungary, poland, } 
                    recruit_pool "ladya"  1   0.7   4   0  requires factions { russia, } 
                    recruit_pool "war galley"  1   0.7   4   0  requires factions { hungary, } 
                    recruit_pool "holk"  1   0.7   4   0  requires factions { russia, poland, } 
                    recruit_pool "dromon"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "fire ship"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "galley"  1   0.7   4   0  requires factions { sicily, papal_states, milan, venice, } 
                    recruit_pool "cog"  1   0.7   4   0  requires factions { portugal, spain, } 
                    recruit_pool "war galley"  1   0.7   4   0  requires factions { southern_european, } 
                    trade_base_income_bonus bonus 3
                }
                material wooden
                construction  3 
                cost  1600 
                settlement_min city
                upgrades
                {
                    dockyard
                }
            }
            dockyard city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 2
                capability
                {
                    recruit_pool "holk"  1   0.7   4   0  requires factions { hre, scotland, france, england, } 
                    recruit_pool "dragon boat"  1   0.7   4   0  requires factions { denmark, } 
                    recruit_pool "gun holk"  1   0.7   4   0  requires factions { northern_european, } 
                    recruit_pool "war galley"  1   0.7   4   0  requires factions { egypt, moors, turks, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { egypt, moors, turks, } 
                    recruit_pool "war galley"  1   0.7   4   0  requires factions { hungary, } 
                    recruit_pool "holk"  1   0.7   4   0  requires factions { russia, poland, } 
                    recruit_pool "gun holk"  1   0.7   4   0  requires factions { russia, poland, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { hungary, } 
                    recruit_pool "fire ship"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "war galley"  1   0.7   4   0  requires factions { southern_european, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { portugal, spain, papal_states, milan, sicily, } 
                    recruit_pool "caravel"  1   0.7   4   0  requires factions { portugal, spain, }  and event_counter world_is_round 1 
                    recruit_pool "galleass"  1   0.7   4   0  requires factions { venice, } 
                    trade_base_income_bonus bonus 4
                }
                material wooden
                construction  5 
                cost  3200 
                settlement_min large_city
                upgrades
                {
                    naval_drydock
                }
            }
            naval_drydock city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }  and event_counter world_is_round 1 
            {
                convert_to 3
                capability
                {
                    recruit_pool "gun holk"  1   0.7   4   0  requires factions { northern_european, } 
                    recruit_pool "carrack"  1   0.7   4   0  requires factions { northern_european, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { egypt, moors, turks, } 
                    recruit_pool "baghlah"  1   0.7   4   0  requires factions { egypt, moors, turks, } 
                    recruit_pool "gun holk"  1   0.7   4   0  requires factions { russia, poland, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { hungary, } 
                    recruit_pool "carrack"  1   0.7   4   0  requires factions { eastern_european, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "carrack"  1   0.7   4   0  requires factions { greek, } 
                    recruit_pool "lanternas"  1   0.7   4   0  requires factions { portugal, spain, papal_states, milan, sicily, } 
                    recruit_pool "caravel"  1   0.7   4   0  requires factions { portugal, spain, } 
                    recruit_pool "galleass"  1   0.7   4   0  requires factions { venice, } 
                    recruit_pool "carrack"  1   0.7   4   0  requires factions { papal_states, sicily, milan, venice, } 
                    recruit_pool "grande carrack"  1   0.7   4   0  requires factions { portugal, spain, } 
                    trade_base_income_bonus bonus 5
                }
                material wooden
                construction  6 
                cost  6400 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building castle_port
    {
        convert_to port
        levels c_port c_shipwright c_dockyard c_naval_drydock 
        {
            c_port castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "cog"  1  0.3  2  0  requires factions { hre, france, scotland, england, } 
                    recruit_pool "longboat"  1  0.3  2  0  requires factions { denmark, } 
                    recruit_pool "dhow"  1  0.3  2  0  requires factions { middle_eastern, } 
                    recruit_pool "cog"  1  0.3  2  0  requires factions { hungary, poland, } 
                    recruit_pool "ladya"  1  0.3  2  0  requires factions { russia, } 
                    recruit_pool "dromon"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "galley"  1  0.3  2  0  requires factions { sicily, papal_states, milan, venice, } 
                    recruit_pool "cog"  1  0.3  2  0  requires factions { portugal, spain, }
                    trade_base_income_bonus bonus 1 
                }
                material wooden
                construction  2 
                cost  800 
                settlement_min large_town
                upgrades
                {
                    c_shipwright
                }
            }
            c_shipwright castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "cog"  1  0.3  2  0  requires factions { hre, france, scotland, england, } 
                    recruit_pool "longboat"  1  0.3  2  0  requires factions { denmark, } 
                    recruit_pool "holk"  1  0.3  2  0  requires factions { hre, scotland, france, england, } 
                    recruit_pool "dragon boat"  1  0.3  2  0  requires factions { denmark, } 
                    recruit_pool "dhow"  1  0.3  2  0  requires factions { middle_eastern, } 
                    recruit_pool "war galley"  1  0.3  2  0  requires factions { egypt, moors, turks, } 
                    recruit_pool "cog"  1  0.3  2  0  requires factions { hungary, poland, } 
                    recruit_pool "ladya"  1  0.3  2  0  requires factions { russia, } 
                    recruit_pool "war galley"  1  0.3  2  0  requires factions { hungary, } 
                    recruit_pool "holk"  1  0.3  2  0  requires factions { russia, poland, } 
                    recruit_pool "dromon"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "fire ship"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "galley"  1  0.3  2  0  requires factions { sicily, papal_states, milan, venice, } 
                    recruit_pool "cog"  1  0.3  2  0  requires factions { portugal, spain, } 
                    recruit_pool "war galley"  1  0.3  2  0  requires factions { southern_european, }
                    trade_base_income_bonus bonus 1 
                }
                material wooden
                construction  3 
                cost  1600 
                settlement_min city
                upgrades
                {
                    c_dockyard
                }
            }
            c_dockyard castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }  and event_counter gunpowder_discovered 1 
            {
                convert_to 2
                capability
                {
                    recruit_pool "holk"  1  0.3  2  0  requires factions { hre, scotland, france, england, } 
                    recruit_pool "dragon boat"  1  0.3  2  0  requires factions { denmark, } 
                    recruit_pool "gun holk"  1  0.3  2  0  requires factions { northern_european, } 
                    recruit_pool "war galley"  1  0.3  2  0  requires factions { egypt, moors, turks, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { egypt, moors, turks, } 
                    recruit_pool "war galley"  1  0.3  2  0  requires factions { hungary, } 
                    recruit_pool "holk"  1  0.3  2  0  requires factions { russia, poland, } 
                    recruit_pool "gun holk"  1  0.3  2  0  requires factions { russia, poland, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { hungary, } 
                    recruit_pool "fire ship"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "war galley"  1  0.3  2  0  requires factions { southern_european, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { portugal, spain, papal_states, milan, sicily, } 
                    recruit_pool "caravel"  1  0.3  2  0  requires factions { portugal, spain, }  and event_counter world_is_round 1 
                    recruit_pool "galleass"  1  0.3  2  0  requires factions { venice, }
                    trade_base_income_bonus bonus 1 
                }
                material wooden
                construction  5 
                cost  3200 
                settlement_min large_city
                upgrades
                {
                    c_naval_drydock
                }
            }
            c_naval_drydock castle requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }  and event_counter world_is_round 1 
            {
                convert_to 3
                capability
                {
                    recruit_pool "gun holk"  1  0.3  2  0  requires factions { northern_european, } 
                    recruit_pool "carrack"  1  0.3  2  0  requires factions { northern_european, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { egypt, moors, turks, } 
                    recruit_pool "baghlah"  1  0.3  2  0  requires factions { egypt, moors, turks, } 
                    recruit_pool "gun holk"  1  0.3  2  0  requires factions { russia, poland, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { hungary, } 
                    recruit_pool "carrack"  1  0.3  2  0  requires factions { eastern_european, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "carrack"  1  0.3  2  0  requires factions { greek, } 
                    recruit_pool "lanternas"  1  0.3  2  0  requires factions { portugal, spain, papal_states, milan, sicily, } 
                    recruit_pool "caravel"  1  0.3  2  0  requires factions { portugal, spain, } 
                    recruit_pool "galleass"  1  0.3  2  0  requires factions { venice, } 
                    recruit_pool "carrack"  1  0.3  2  0  requires factions { papal_states, sicily, milan, venice, } 
                    recruit_pool "grande carrack"  1  0.3  2  0  requires factions { portugal, spain, }
                    trade_base_income_bonus bonus 1 
                }
                material wooden
                construction  6 
                cost  6400 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building market
    {
        levels corn_exchange market fairground great_market merchants_quarter 
        {
            corn_exchange city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent merchant  0  requires factions { northern_european, } 
                    agent merchant  0  requires factions { middle_eastern, } 
                    agent merchant  0  requires factions { eastern_european, } 
                    agent merchant  0  requires factions { greek, } 
                    agent merchant  0  requires factions { southern_european, } 
                    trade_base_income_bonus bonus 2
                    agent_limit merchant 1
                }
                material wooden
                construction  2 
                cost  600 
                settlement_min town
                upgrades
                {
                    market
                }
            }
            market city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent merchant  0  requires factions { northern_european, } 
                    agent merchant  0  requires factions { middle_eastern, } 
                    agent merchant  0  requires factions { eastern_european, } 
                    agent merchant  0  requires factions { greek, } 
                    agent merchant  0  requires factions { southern_european, } 
                    trade_base_income_bonus bonus 3
                    agent_limit merchant 1
                }
                material wooden
                construction  3 
                cost  1200 
                settlement_min large_town
                upgrades
                {
                    fairground
                }
            }
            fairground city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent merchant  0  requires factions { northern_european, } 
                    agent merchant  0  requires factions { middle_eastern, } 
                    agent merchant  0  requires factions { eastern_european, } 
                    agent merchant  0  requires factions { greek, } 
                    agent merchant  0  requires factions { southern_european, } 
                    trade_base_income_bonus bonus 4
                    agent_limit merchant 1
                }
                material wooden
                construction  4 
                cost  2400 
                settlement_min city
                upgrades
                {
                    great_market
                }
            }
            great_market city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent merchant  0  requires factions { northern_european, } 
                    agent merchant  0  requires factions { middle_eastern, } 
                    agent merchant  0  requires factions { eastern_european, } 
                    agent merchant  0  requires factions { greek, } 
                    agent merchant  0  requires factions { southern_european, } 
                    trade_base_income_bonus bonus 5
                    agent_limit merchant 1
                }
                material wooden
                construction  6 
                cost  4800 
                settlement_min large_city
                upgrades
                {
                    merchants_quarter
                }
            }
            merchants_quarter city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent merchant  0  requires factions { northern_european, } 
                    agent merchant  0  requires factions { middle_eastern, } 
                    agent merchant  0  requires factions { eastern_european, } 
                    agent merchant  0  requires factions { greek, } 
                    agent merchant  0  requires factions { southern_european, } 
                    trade_base_income_bonus bonus 6
                    agent_limit merchant 1
                }
                material wooden
                construction  7 
                cost  9600 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building temple_catholic
    {
        convert_to temple_catholic_castle
        religion catholic
        levels small_church church abbey cathedral huge_cathedral 
        {
            small_church city requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } 
            {
                convert_to 0
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    happiness_bonus bonus 1
                    religion_level bonus 1
                    pope_disapproval 1
                    agent_limit priest 1
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min town
                upgrades
                {
                    church
                }
            }
            church city requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } 
            {
                convert_to 1
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    happiness_bonus bonus 1
                    religion_level bonus 2
                    agent_limit priest 2
                    pope_disapproval 1
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                    abbey
                }
            }
            abbey city requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } 
            {
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    recruit_pool "Armored Clergy"  1   0.2   2  0  requires factions { denmark, } 
                    happiness_bonus bonus 2
                    religion_level bonus 3
                    agent_limit priest 3
                    pope_disapproval 1
                }
                material wooden
                construction  3 
                cost  3200 
                settlement_min city
                upgrades
                {
                    cathedral
                }
            }
            cathedral city requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, venice, } 
            {
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    recruit_pool "Armored Clergy"  1   0.4   3  0  requires factions { denmark, } 
                    happiness_bonus bonus 2
                    religion_level bonus 4
                    agent_limit priest 3
                    pope_disapproval 1
                    pope_approval 1
                    population_health_bonus bonus 1
                }
                material wooden
                construction  4 
                cost  6400 
                settlement_min large_city
                upgrades
                {
                    huge_cathedral
                }
            }
            huge_cathedral city requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } 
            {
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    recruit_pool "Armored Clergy"  1   0.4   3  1  requires factions { denmark, } 
                    happiness_bonus bonus 3
                    religion_level bonus 5
                    agent_limit priest 4
                    pope_disapproval 1
                    pope_approval 1
                    population_health_bonus bonus 3
                }
                material wooden
                construction  6 
                cost  10000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building temple_catholic_castle
    {
        convert_to temple_catholic
        religion catholic
        levels small_chapel chapel 
        {
            small_chapel castle requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } 
            {
                convert_to 0
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    happiness_bonus bonus 1
                    religion_level bonus 2
                    pope_disapproval 1
                    agent_limit priest 0
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min town
                upgrades
                {
                    chapel
                }
            }
            chapel castle requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } 
            {
                convert_to 1
                capability
                {
                    agent priest  0  requires factions { normans, denmark, scotland, hre, france, england, } 
                    agent priest  0  requires factions { hungary, poland, } 
                    agent priest  0  requires factions { papal_states, portugal, spain, sicily, milan, venice, } 
                    happiness_bonus bonus 1
                    religion_level bonus 3
                    agent_limit priest 0
                    pope_disapproval 1
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building temple_orthodox
    {
        convert_to temple_orthodox_castle
        religion orthodox
        levels small_church_o church_o abbey_o cathedral_o huge_cathedral_o 
        {
            small_church_o city requires factions { russia, byzantium, } 
            {
                convert_to 0
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, }
                    happiness_bonus bonus 1
                    religion_level bonus 2
                    agent_limit priest 1
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min town
                upgrades
                {
                    church_o
                }
            }
            church_o city requires factions { russia, byzantium, } 
            {
                convert_to 1
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, } 
                    happiness_bonus bonus 1
                    religion_level bonus 4
                    agent_limit priest 2
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                    abbey_o
                }
            }
            abbey_o city requires factions { russia, byzantium, } 
            {
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, } 
                    happiness_bonus bonus 2
                    religion_level bonus 6
                    agent_limit priest 3
                }
                material wooden
                construction  3 
                cost  3200 
                settlement_min city
                upgrades
                {
                    cathedral_o
                }
            }
            cathedral_o city requires factions { russia, byzantium, } 
            {
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, } 
                    happiness_bonus bonus 2
                    religion_level bonus 8
                    agent_limit priest 4
                    population_health_bonus bonus 1
                }
                material wooden
                construction  4 
                cost  6400 
                settlement_min large_city
                upgrades
                {
                    huge_cathedral_o
                }
            }
            huge_cathedral_o city requires factions { russia, byzantium, } 
            {
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, } 
                    happiness_bonus bonus 3
                    religion_level bonus 10
                    agent_limit priest 5
                    population_health_bonus bonus 2
                }
                material wooden
                construction  6 
                cost  10000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building temple_orthodox_castle
    {
        convert_to temple_orthodox
        religion orthodox
        levels small_chapel_o chapel_o 
        {
            small_chapel_o castle requires factions { russia, byzantium, } 
            {
                convert_to 0
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, } 
                    happiness_bonus bonus 1
                    religion_level bonus 4
                    agent_limit priest 0
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min town
                upgrades
                {
                    chapel_o
                }
            }
            chapel_o castle requires factions { russia, byzantium, } 
            {
                convert_to 1
                capability
                {
                    agent priest  0  requires factions { russia, } 
                    agent priest  0  requires factions { byzantium, } 
                    happiness_bonus bonus 1
                    religion_level bonus 6
                    agent_limit priest 0
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building temple_muslim
    {
        convert_to temple_muslim_castle
        religion islam
        levels small_masjid masjid minareted_masjid jama great_jama 
        {
            small_masjid city requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                convert_to 0
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 1
                    religion_level bonus 2
                    agent_limit priest 1
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min town
                upgrades
                {
                    masjid
                }
            }
            masjid city requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                convert_to 1
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 1
                    religion_level bonus 4
                    agent_limit priest 2
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                    minareted_masjid
                }
            }
            minareted_masjid city requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 2
                    religion_level bonus 6
                    agent_limit priest 3
                }
                material wooden
                construction  3 
                cost  3200 
                settlement_min city
                upgrades
                {
                    jama
                }
            }
            jama city requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 2
                    religion_level bonus 8
                    agent_limit priest 4
                    population_health_bonus bonus 1
                }
                material wooden
                construction  4 
                cost  6400 
                settlement_min large_city
                upgrades
                {
                    great_jama
                }
            }
            great_jama city requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 3
                    religion_level bonus 10
                    agent_limit priest 5
                    population_health_bonus bonus 2
                }
                material wooden
                construction  6 
                cost  10000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building temple_muslim_castle
    {
        convert_to temple_muslim
        religion islam
        levels c_small_masjid c_masjid 
        {
            c_small_masjid castle requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                convert_to 0
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 1
                    religion_level bonus 4
                    agent_limit priest 0
                }
                material wooden
                construction  1 
                cost  800 
                settlement_min town
                upgrades
                {
                    c_masjid
                }
            }
            c_masjid castle requires factions { timurids, mongols, egypt, moors, turks, } 
            {
                convert_to 1
                capability
                {
                    agent priest  0  requires factions { egypt, moors, turks, } 
                    happiness_bonus bonus 1
                    religion_level bonus 6
                    agent_limit priest 0
                }
                material wooden
                construction  2 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building taverns
    {
        levels brothel inn tavern coaching_house pleasure_palace 
        {
            brothel city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { middle_eastern, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent spy  0  requires factions { greek, } 
                    agent spy  0  requires factions { southern_european, } 
                    happiness_bonus bonus 1
                    agent_limit spy 1
                }
                material wooden
                construction  2 
                cost  800 
                settlement_min town
                upgrades
                {
                    inn
                }
            }
            inn city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent assassin  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { middle_eastern, } 
                    agent assassin  0  requires factions { middle_eastern, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent assassin  0  requires factions { eastern_european, } 
                    agent spy  0  requires factions { greek, } 
                    agent assassin  0  requires factions { greek, } 
                    agent spy  0  requires factions { southern_european, } 
                    agent assassin  0  requires factions { southern_european, } 
                    happiness_bonus bonus 2
                    agent_limit spy 2
                    agent_limit assassin 1
                }
                material wooden
                construction  3 
                cost  1600 
                settlement_min large_town
                upgrades
                {
                    tavern
                }
            }
            tavern city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent assassin  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { middle_eastern, } 
                    agent assassin  0  requires factions { middle_eastern, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent assassin  0  requires factions { eastern_european, } 
                    agent spy  0  requires factions { greek, } 
                    agent assassin  0  requires factions { greek, } 
                    agent spy  0  requires factions { southern_european, } 
                    agent assassin  0  requires factions { southern_european, } 
                    recruit_pool "Transilvanian Peasants"  1   0.4   3  0  requires factions { hungary, } 
                    happiness_bonus bonus 3
                    agent_limit spy 2
                    agent_limit assassin 2
                }
                material wooden
                construction  4 
                cost  3200 
                settlement_min city
                upgrades
                {
                    coaching_house
                }
            }
            coaching_house city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent assassin  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { middle_eastern, } 
                    agent assassin  0  requires factions { middle_eastern, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent assassin  0  requires factions { eastern_european, } 
                    agent spy  0  requires factions { greek, } 
                    agent assassin  0  requires factions { greek, } 
                    agent spy  0  requires factions { southern_european, } 
                    agent assassin  0  requires factions { southern_european, } 
                    recruit_pool "Transilvanian Peasants"  1   0.5   4  0  requires factions { hungary, } 
                    happiness_bonus bonus 4
                    agent_limit spy 2
                    agent_limit assassin 2
                }
                material wooden
                construction  5 
                cost  6400 
                settlement_min large_city
                upgrades
                {
                    pleasure_palace
                }
            }
            pleasure_palace city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent assassin  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { middle_eastern, } 
                    agent assassin  0  requires factions { middle_eastern, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent assassin  0  requires factions { eastern_european, } 
                    agent spy  0  requires factions { greek, } 
                    agent assassin  0  requires factions { greek, } 
                    agent spy  0  requires factions { southern_european, } 
                    agent assassin  0  requires factions { southern_european, } 
                    recruit_pool "Transilvanian Peasants"  1   0.5   4  0  requires factions { hungary, } 
                    happiness_bonus bonus 5
                    agent_limit spy 3
                    agent_limit assassin 2
                }
                material wooden
                construction  6 
                cost  10000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building city_hall
    {
        levels town_hall council_chambers city_hall mayors_palace 
        {
            town_hall city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent diplomat  0  requires factions { northern_european, } 
                    agent diplomat  0  requires factions { middle_eastern, } 
                    agent diplomat  0  requires factions { eastern_european, } 
                    agent diplomat  0  requires factions { greek, } 
                    agent diplomat  0  requires factions { southern_european, } 
                    law_bonus bonus 1
                    population_health_bonus bonus 1
                    trade_base_income_bonus bonus +1
                }
                material wooden
                construction  2 
                cost  600 
                settlement_min large_town
                upgrades
                {
                    council_chambers
                }
            }
            council_chambers city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent diplomat  0  requires factions { northern_european, } 
                    agent diplomat  0  requires factions { middle_eastern, } 
                    agent diplomat  0  requires factions { eastern_european, } 
                    agent diplomat  0  requires factions { greek, } 
                    agent diplomat  0  requires factions { southern_european, } 
                    recruit_pool "Carroccio Standard M"  1   0.2   2  0  requires factions { milan, } 
                    recruit_pool "Carroccio Standard V"  1   0.2   2  0  requires factions { venice, } 
                    law_bonus bonus 2
                    population_health_bonus bonus 2
                    trade_base_income_bonus bonus +2
                }
                material wooden
                construction  3 
                cost  1200 
                settlement_min city
                upgrades
                {
                    city_hall
                }
            }
            city_hall city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent diplomat  0  requires factions { northern_european, } 
                    agent diplomat  0  requires factions { middle_eastern, } 
                    agent diplomat  0  requires factions { eastern_european, } 
                    agent diplomat  0  requires factions { greek, } 
                    agent diplomat  0  requires factions { southern_european, } 
                    recruit_pool "Carroccio Standard M"  1   0.2   2  0  requires factions { milan, } 
                    recruit_pool "Carroccio Standard V"  1   0.2   2  0  requires factions { venice, } 
    
                    law_bonus bonus 3
                    population_health_bonus bonus 4
                    trade_base_income_bonus bonus +4
                }
                material wooden
                construction  4 
                cost  2400 
                settlement_min large_city
                upgrades
                {
                    mayors_palace
                }
            }
            mayors_palace city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    agent diplomat  0  requires factions { northern_european, } 
                    agent diplomat  0  requires factions { middle_eastern, } 
                    agent diplomat  0  requires factions { eastern_european, } 
                    agent diplomat  0  requires factions { greek, } 
                    agent diplomat  0  requires factions { southern_european, } 
                    recruit_pool "Carroccio Standard M"  1   0.4   3  0  requires factions { milan, } 
                    recruit_pool "Carroccio Standard V"  1   0.4   3  0  requires factions { venice, } 
                    recruit_pool "Famiglia Ducale"  1   0.5   4  0  requires factions { milan, } 
                    law_bonus bonus 4
                    population_health_bonus bonus 5
                    trade_base_income_bonus bonus +5
                }
                material wooden
                construction  5 
                cost  4800 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building bullring
    {
        levels plaza_del_toro 
        {
            plaza_del_toro city requires factions { portugal, spain, } 
            {
                capability
                {
                    recruit_pool "Merchant Cavalry Militia"  1   0.5   4  0  requires factions { spain, portugal, }
                    recruit_pool "Jinetes"  1   0.4   1  0  requires factions { portugal, } 
                    happiness_bonus bonus 2
                }
                material wooden
                construction  4 
                cost  4800 
                settlement_min city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building bank
    {
        levels merchant_bank merchant_vault 
        {
            merchant_bank city requires factions { hre, venice, milan, } 
            {
                capability
                {
                    trade_base_income_bonus bonus 4
                    agent_limit merchant 1
                }
                material wooden
                construction  4 
                cost  4800 
                settlement_min large_city
                upgrades
                {
                    merchant_vault
                }
            }
            merchant_vault city requires factions { hre, venice, milan, } 
            {
                capability
                {
                    trade_base_income_bonus bonus 6
                    agent_limit merchant 2
                }
                faction_capability
                {
                    trade_base_income_bonus bonus +1
                }
                material wooden
                construction  6 
                cost  9600 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building castle_academic
    {
        levels library academy 
        {
            library castle requires factions { denmark, scotland, hungary, poland, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent diplomat  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent diplomat  0  requires factions { eastern_european, }
    		infantry_bonus 1  requires factions { denmark, scotland, }
    		cavalry_bonus 1  requires factions { hungary, poland, }
                    agent_limit spy 1
                    agent_limit assassin 1 
                }
                material wooden
                construction  3 
                cost  1600 
                settlement_min large_city
                upgrades
                {
                    academy
                }
            }
            academy castle requires factions { denmark, scotland, hungary, poland, } 
            {
                capability
                {
                    agent spy  0  requires factions { northern_european, } 
                    agent diplomat  0  requires factions { northern_european, } 
                    agent assassin  0  requires factions { northern_european, } 
                    agent spy  0  requires factions { eastern_european, } 
                    agent diplomat  0  requires factions { eastern_european, } 
                    agent assassin  0  requires factions { eastern_european, }
    		infantry_bonus 2  requires factions { denmark, scotland, }
    		cavalry_bonus 2  requires factions { hungary, poland, }
                    agent_limit spy 2
                    agent_limit assassin 2 
                }
                material wooden
                construction  6 
                cost  3200 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_assassins_guild
    {
        levels assassins_guild m_assassins_guild gm_assassins_guild 
        {
            assassins_guild city requires factions { northern_european, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Battlefield Assassins"  1   0.4   3  0  requires factions { hungary, } 
                    law_bonus bonus 1
                }
                material wooden
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    m_assassins_guild
                }
            }
            m_assassins_guild city requires factions { northern_european, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Battlefield Assassins"  1   0.4   3  1  requires factions { hungary, } 
                    law_bonus bonus 1
                }
                material wooden
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    gm_assassins_guild
                }
            }
            gm_assassins_guild city requires factions { northern_european, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Battlefield Assassins"  1   0.4   3  2  requires factions { hungary, } 
                    law_bonus bonus 2
                }
                material wooden
                construction  1 
                cost  3000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_assassins_muslim_guild
    {
        levels eastern_assassins_guild m_eastern_assassins_guild gm_eastern_assassins_guild 
        {
            eastern_assassins_guild city requires factions { middle_eastern, } 
            {
                capability
                {
                    recruit_pool "Hashishim"  1   0.4   3  0  requires factions { moors, egypt, turks, } 
                }
                material wooden
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    m_eastern_assassins_guild
                }
            }
            m_eastern_assassins_guild city requires factions { middle_eastern, } 
            {
                capability
                {
                    recruit_pool "Hashishim"  1   0.4   3  1  requires factions { moors, egypt, turks, } 
                }
                material wooden
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    gm_eastern_assassins_guild
                }
            }
            gm_eastern_assassins_guild city requires factions { middle_eastern, } 
            {
                capability
                {
                    recruit_pool "Hashishim"  1   0.4   3  2  requires factions { moors, egypt, turks, } 
                }
                material wooden
                construction  1 
                cost  3000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_merchants_guild
    {
        levels merchants_guild m_merchants_guild gm_merchants_guild 
        {
            merchants_guild city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Merchant Cavalry Militia"  1   0.4   3  0  requires factions { england, france, hre, denmark, spain, portugal, poland, hungary, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.4   3  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Cavalry Militia"  1   0.4   3  0  requires factions { russia, } 
                    recruit_pool "Greek Militia Cavalry"  1   0.4   3  0  requires factions { byzantium, } 
                    trade_base_income_bonus bonus 1
                    trade_base_income_bonus bonus +2 requires factions { scotland, moors, egypt, turks, }
                }
                faction_capability
                {
                }
                material wooden
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    m_merchants_guild
                }
            }
            m_merchants_guild city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Merchant Cavalry Militia"  1   0.5   4  0  requires factions { england, france, hre, denmark, spain, portugal, poland, hungary, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.5   4  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Cavalry Militia"  1   0.5   4  0  requires factions { russia, } 
                    recruit_pool "Greek Militia Cavalry"  1   0.5   4  0  requires factions { byzantium, } 
                    trade_base_income_bonus bonus 2
                    trade_base_income_bonus bonus +1 requires factions { scotland, moors, egypt, turks, }
                }
                faction_capability
                {
                    trade_base_income_bonus bonus +1 requires factions { scotland, moors, egypt, turks, }
                }
                material wooden
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    gm_merchants_guild
                }
            }
            gm_merchants_guild city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } 
            {
                capability
                {
                    recruit_pool "Merchant Cavalry Militia"  1   0.5   4  0  requires factions { england, } 
                    recruit_pool "Merchant Cavalry Militia"  1   0.5   4  1  requires factions { france, hre, denmark, spain, portugal, poland, hungary, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.5   4  1  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Cavalry Militia"  1   0.5   4  1  requires factions { russia, } 
                    recruit_pool "Greek Militia Cavalry"  1   0.5   4  1  requires factions { byzantium, }
                    trade_base_income_bonus bonus 3
                    trade_base_income_bonus bonus +1 requires factions { scotland, moors, egypt, turks, } 
                }
                faction_capability
                {
                    trade_base_income_bonus bonus +2 requires factions { scotland, moors, egypt, turks, }
                }
                material wooden
                construction  1 
                cost  3000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_templars_chapter_house
    {
        convert_to guild_templars_chapter_house
        religion catholic
        levels templars_minor_ch templars_major_ch templars_hq 
        {
            templars_minor_ch  requires factions { england, france, scotland, denmark, hungary, poland, papal_states, milan, sicily, venice, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "Knights Templar"  1   0.4   3  0  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.4   3  0  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Crusader Sergeants"  1   0.4   3  0  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    templars_major_ch
                }
            }
            templars_major_ch  requires factions { england, france, scotland, denmark, hungary, poland, papal_states, milan, sicily, venice, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Knights Templar"  1   0.5   4  1  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.5   4  1  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Crusader Sergeants"  1   0.5   4  1  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    templars_hq
                }
            }
            templars_hq  requires factions { england, france, scotland, denmark, hungary, poland, papal_states, milan, sicily, venice, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Knights Templar"  1   0.7   6  2  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.7   6  2  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Crusader Sergeants"  1   0.7   6  2  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  3000 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_st_johns_chapter_house
    {
        convert_to guild_st_johns_chapter_house
        religion catholic
        levels st_johns_minor_ch st_johns_major_ch st_johns_hq 
        {
            st_johns_minor_ch  requires factions { england, france, scotland, denmark, hungary, poland, papal_states, milan, sicily, venice, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "Knights Hospitaller"  1   0.4   3  0  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.4   3  0  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, } 
                    recruit_pool "Crusader Sergeants"  1   0.4   3  0  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    population_health_bonus bonus 1
                    recruitment_slots bonus +1 
                }
                material stone
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    st_johns_major_ch
                }
            }
            st_johns_major_ch  requires factions { england, france, scotland, denmark, hungary, poland, papal_states, milan, sicily, venice, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Knights Hospitaller"  1   0.5   4  1  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.5   4  1  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, } 
                    recruit_pool "Crusader Sergeants"  1   0.5   4  1  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    population_health_bonus bonus 2
                    recruitment_slots bonus +1 
                }
                material stone
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    st_johns_hq
                }
            }
            st_johns_hq  requires factions { england, france, scotland, denmark, hungary, poland, papal_states, milan, sicily, venice, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Knights Hospitaller"  1   0.7   6  2  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.7   6  2  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, } 
                    recruit_pool "Crusader Sergeants"  1   0.7   6  2  requires factions { england, scotland, france, denmark, milan, venice, papal_states, sicily, poland, hungary, }
                    population_health_bonus bonus 3
                    recruitment_slots bonus +1 
                }
                material stone
                construction  1 
                cost  3000 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_teutonic_knights_chapter_house
    {
        convert_to guild_teutonic_knights_chapter_house
        religion catholic
        levels teutonic_knights_minor_ch teutonic_knights_major_ch teutonic_knights_hq 
        {
            teutonic_knights_minor_ch  requires factions { hre, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "Teutonic Knights"  1   0.4   3  0  requires factions { hre, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.4   3  0  requires factions { hre, }
                    recruit_pool "Crusader Sergeants"  1   0.4   3  0  requires factions { hre, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    teutonic_knights_major_ch
                }
            }
            teutonic_knights_major_ch  requires factions { hre, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Teutonic Knights"  1   0.5   4  1  requires factions { hre, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.5   4  1  requires factions { hre, }
                    recruit_pool "Crusader Sergeants"  1   0.5   4  1  requires factions { hre, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    teutonic_knights_hq
                }
            }
            teutonic_knights_hq  requires factions { hre, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Teutonic Knights"  1   0.7   6  2  requires factions { hre, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.7   6  2  requires factions { hre, }
                    recruit_pool "Crusader Sergeants"  1   0.7   6  2  requires factions { hre, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  3000 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_knights_of_santiago_chapter_house
    {
        convert_to guild_knights_of_santiago_chapter_house
        religion catholic
        levels knights_of_santiago_minor_ch knights_of_santiago_major_ch knights_of_santiago_hq 
        {
            knights_of_santiago_minor_ch  requires factions { portugal, spain, } 
            {
                convert_to 0
                capability
                {
                    recruit_pool "Knights of Santiago"  1   0.4   3  0  requires factions { spain, portugal, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.4   3  0  requires factions { spain, portugal, }
                    recruit_pool "Crusader Sergeants"  1   0.4   3  0  requires factions { spain, portugal, }
                    recruitment_slots bonus +1  
                } 
                material stone
                construction  1 
                cost  1000 
                settlement_min city
                upgrades
                {
                    knights_of_santiago_major_ch
                }
            }
            knights_of_santiago_major_ch  requires factions { portugal, spain, } 
            {
                convert_to 1
                capability
                {
                    recruit_pool "Knights of Santiago"  1   0.5   4  1  requires factions { spain, portugal, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.5   4  1  requires factions { spain, portugal, }
                    recruit_pool "Crusader Sergeants"  1   0.5   4  1  requires factions { spain, portugal, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  2000 
                settlement_min large_city
                upgrades
                {
                    knights_of_santiago_hq
                }
            }
            knights_of_santiago_hq  requires factions { portugal, spain, } 
            {
                convert_to 2
                capability
                {
                    recruit_pool "Knights of Santiago"  1   0.7   6  2  requires factions { spain, portugal, }
                    recruit_pool "Dismounted Crusader Knights"  1   0.7   6  2  requires factions { spain, portugal, }
                    recruit_pool "Crusader Sergeants"  1   0.7   6  2  requires factions { spain, portugal, }
                    recruitment_slots bonus +1  
                }
                material stone
                construction  1 
                cost  3000 
                settlement_min large_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    building guild_woodsmens_guild
    {
        levels woodsmens_guild m_woodsmens_guild gm_woodsmens_guild 
        {
            woodsmens_guild castle requires factions { england, } 
            {
                capability
                {
                    recruit_pool "Sherwood Archers"  1   0.2   2  0  requires factions { england, }
                    archer_bonus 1
                    recruitment_slots bonus +1 
                }
                material wooden
                construction  1 
                cost  1000 
                settlement_min large_town
                upgrades
                {
                    m_woodsmens_guild
                }
            }
            m_woodsmens_guild castle requires factions { england, } 
            {
                capability
                {
                    recruit_pool "Sherwood Archers"  1   0.5  4   0  requires factions { england, }
                    recruitment_slots bonus +1  
                    archer_bonus 1
                }
                faction_capability
                {
                    archer_bonus 1
                }
                material wooden
                construction  1 
                cost  2000 
                settlement_min large_town
                upgrades
                {
                    gm_woodsmens_guild
                }
            }
            gm_woodsmens_guild castle requires factions { england, } 
            {
                capability
                {
                    recruit_pool "Sherwood Archers"  1   0.5   4  1  requires factions { england, }
                    recruitment_slots bonus +1  
                    archer_bonus 1
                }
                faction_capability
                {
                    archer_bonus 2
                }
                material wooden
                construction  1 
                cost  3000 
                settlement_min city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    The above is the alterd coderealting to recruitment. The changes are EXTREMLY extensive, so it's hard to highlight whats changed. My advice would be to get the trial vershion of Beyond Compare 2 from here and use it to compare the uploaded file to the origional. I'll include a copy of the vanillia file for you in case you don't have a backup.


    Link to the full file here
    Find my ProblemFixer Purehere.

    This ProblemFixer fixes the following: 2-Hander bug, Pike Bug, Shield Bug, Chasing Routers, Cav not Charging, Formation Keeping Improved, Trait Bugs, and Ancillary Bugs.

    BETA Testers needed for the current version of RebuildProblemFixer. Thread here

  19. #19

    Default Re: How to improve the tactical AI

    A very good thread and i have to agree mostly with Cheetah on the battle AI if anyone have experienced the AI in STW or MTW which made this game famous.

    And i could safely say RTW is the downfall in battle AI [but the beginning of attractive graphic and interesting role play style]. If you think the AI in m2tw is bad, then RTW is the worst imo. [I dont even bother to buy its expansion, apart from buying all others TW series]

    I especially agree with the "height advantage" and "flank control" which are totally lacking in RTW/m2tw. The battle is so easy regardless of any quality/quantity of troops if you can always easily control the high ground and flank.

    I really miss out those tough battles in STW/MTW which i cant win even on my best, compare to i hardly lost a single battle in RTW/m2tw.

  20. #20

    Default Re: How to improve the tactical AI

    Just get into much detail on this thread and have to agree with Foz and Carls idea eliminated the low-tech AI troops.

    I just come up with an idea: how about we could upgrade an unit to their next level with half of the training cost?

    For example lets say mail knight cost 780 and feudal knight cost 860 (?) Then we could have the option to upgrade the mail knight to feudal knight with a training cost of 860/2 = 430 ? I think this also make real sense you can uplevel your army by providing time, equipment and funds? ( = forin in game)

    Meanwhile, it seems to be a very tough programming for height positioning and protecting flank after i read carl's explanation on that...I am a bit worry if i could see this be fixed [or come back from STW/MTW] in future TW series? As we are no doubt going to the tread of diversity in units choices in marketing reasons?

  21. #21

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Carl
    Thanks for that explanation, for some reason I assumed the situation between WM and YS, (Warrior Monks and Yari Spearmen Correct?), was duplicated elsewhere. I also previously wasn't aware that their where several units within the sword and spear classes, or as many in the Cav class. Your statement about just 11 different units meant I thought their where only 1 spear, 1 swords, 2 types of Cav, (one heavy one light), A general's unit and some missile units, plus the odd extra here and their. So STW has far more verity than I believed which also helped confuse me.
    There are 3 spear units:
    YA = yari ashigaru (cost 200)
    YS = yari samurai (cost 400)
    YC = yari cavalry (cost 1000)

    There are 3 sword units:
    ND = no-dachi (cost 500)
    NI = naginata infantry (cost 800)
    WM = warrior monk (cost 1000)

    There are 3 melee cavalry:
    NC = naginata cavalry (cost 900)
    YC = yari cavalry (cost 1000)
    HC = heavy cavalry (cost 1200)

    There are 4 ranged units:
    PT = Portuguese teppo (cost 200) arquebus doesn't fire in rain
    JT = Japanese teppo (cost 300) more accurate arquebus doesn't fire in rain
    SA = samurai archer (cost 400)
    CA = cavalry archer (cost 600)

    Two specialty units:
    Hatamoto (cost 400) 11 man unit useful as the general's unit.
    BN = battlefield ninja (cost 600) 12 man stealth unit useful for going after a hatamoto general

    With this small unit set, you can get a complex gameplay. The RPS system is basically: cav --> ranged --> sword --> spear --> cav. However, it's more complicated than that because of different capabilities within type. For instance, one sword is heavily armored and therefore not vulnerable to archers, but is vulnerable to teppo because guns penetrate armor easily. The yari cav is fast and can counter the other cav types, but the only sword it can defeat is the weak one, and it doesn't have high enough morale to frontally assault teppo. The samurai archer can outshoot the cav archer not because the bow characteristics are different but because because the horse is a larger target and therefore easier to hit. Both the samurai archer and the cav archer possess enough melee capability to make them moderately useful after they use their ammo. The AI handles all of this reasonably well.


    Quote Originally Posted by Carl
    1.9% is meant as % correct. Which makes it 0.019 in decimal terms.

    1.2** is 1.2 squared, so 1.44 after the squaring.

    The term "combat bonus" applies to any bonus to any specific bonuses against a particular target, for example the anti-Cav bonuses of spears.
    1.9% = 0.19
    1.2**(x) is raise 1.2 to the power of x.
    combat bonus is any situational bonus including anti-cav, armor pierce, charge bonus, terrain bonus, pushback, striking at a man's flank, striking at a router, specific target bonus, etc.

    Thus to use an example from M2TW, (ignoring the probably changed 1.2 value), of Spear Militia, (5 Attack, 7 defense, +8 attack vs. Cav), we would get:

    Quote Originally Posted by Carl
    0.019*1.44*(5-7+8)=0.16416. A bit low looking, (hence why i asked if the 1.9% was meant to be percent).
    In the old engine, each engaged man gets one strike within the 1 second combat cycle although he can parry many times if more than one man is attacking him. His chance to kill the man he strikes is:
    chance to kill = 0.019*1.2**(striker's attack value - defender's defense value + bonus)

    For example, a YS (0/2) (att/def) fighting a WM (5/2) in STW with no other bonus involved:
    YS strikes at WM:
    chance to kill = 0.019*1.2**(0 - 2) = 0.019*1.2**(-2) = 0.019*0.69 = 0.013 = 1.3%
    WM strikes at YS:
    chance to kill = 0.019*1.2**(5 - 2) = 0.019*1.2**(3) = 0.019*1.73 = .033 = 3.3%

    It's a bad example because both units have a defend value of 2, but that's the WM defend value in the first equation and the YS defend value in the second one. You can see there is about a 3 to 1 advantage for the WM in probability to kill the YS, but the empirical result will be closer to 4 to 1 because of pushbacks (+6 attack bonus on the next combat cycle) that the stronger unit can get, battlefield upgrades of individual men and the multiple attacks the WM can get once it has more men than the YS.





    Quote Originally Posted by Carl
    TBH the issue with animations, (as CA themselves have admitted), is down to a too low attack delay value. Since individualistic combats quickly end up with every individual in both units fighting out of sequence with both other members of their unit and the members of enemy units, the attack animation speed isn't necessarily important, (as an individual with a slower animation may well start his attack before someone with a faster animation), so long as the total attacks per minute from both sides is the same. Neither is getting more damage per minute in that way.
    If the number of strikes for each unit is the same, then that would drop out as a factor affecting balance. I was thinking the faster animation would get more strikes, but you are saying it's an alternating sequence which makes sense.


    Quote Originally Posted by Carl
    Likewise a large delay also gives models with short reach weapons the time to close into range without the long reach guy being able to make an attack and capitalize on his reach.
    This seems like a definite improvement to the combat as a simulation of different weapon types.


    Quote Originally Posted by Carl
    The big one that messes things up IMHO is the AP attribute as it gets more or less effective depending on the target, so it's nearly impossibbile to write a simple algorithm that takes account of it.
    That would still come in as a combat bonus, so if the AI is still, at least partially, using the relative combat strengths to make its decision the AP attribute would be affecting that decision.

    Quote Originally Posted by Carl
    Another matter that messes things up is the variation in missile units and how they work as a part of the RPS system, and likewise the way other new units have been added to the RPS system.

    I Believe that in STW the archers countered all infantry and where countered by all Cav correct?
    Well archers are not very effectve against high armored units. Those would be naginata infantry, naginata cavalry, heavy cavalry and hatamoto. They are not cost effective vs teppo or the yari samurai, but are moderately effective against them. They are effective vs yari ashigaru, but again there is the issue of cost effectiveness since they cost twice as much as yari ashigaru. It depends on the tactical situation whether or not you want to use archers against a low cost target. Their best targets are the two low armored sword units and yari cav and they are good for counter skirmishing cav archers.

    I have to break off here for now.

    _________Designed to match Original STW gameplay.


    Beta 8 + Beta 8.1 patch + New Maps + Sound add-on + Castles 2

  22. #22
    Senior Member Senior Member Carl's Avatar
    Join Date
    Dec 2006
    Posts
    1,461

    Default Re: How to improve the tactical AI

    First many thanks for all the info, I can't give a complete reply straight after reading this as i need a few minutes to digest things.

    Many thanks for so much info on STW, and for corrections, it's really helping me understand things a lot better.


    If the number of strikes for each unit is the same, then that would drop out as a factor affecting balance. I was thinking the faster animation would get more strikes, but you are saying it's an alternating sequence which makes sense.
    Sort of Puzz, what i said and what you said WOULD be true if the attack delay for all units was high enough that animation speed was not a limiting factor on attack rate.

    Unfortunately the attack delay in M2TW is often shorter than the Animation time, so instead of conducting an attack animation then pausing till the delay is through they immediately attack again which means animations and NOT attack delay are currently determining the number of attacks per minute. This info comes from CA.

    But as noted, if the attack delay WAS high enough, then animation speed wouldn't matter over much as the attack delay would ensure even the slowest animation had finished before the next attack could happen. Resulting in the same number of attacks per minute. CA have acknowledged the error and Will probably fix it in the expansion or a future patch.


    If that confusing anyone else, heres a quick example:

    Unit X: It's animation takes 0.1 seconds to play out.

    Unit Y: it's animation takes 0.2 seconds to complete.


    A unit can never start another attack animation till it's current one has completed, thus if the attack delay for both units X and Y was less than 0.1 seconds then unit X could attack more times per minute than unit Y.

    If however the attack delay was, (for example), 0.3 seconds, then both units would get exactly the same number of attacks as the delay is measured from the start of one attack animation to the start of the next attack animation. Thus the units would both attack once every 0.3 seconds in the above example.


    This seems like a definite improvement to the combat as a simulation of different weapon types.
    It would be if the delay was high enough, but right now it isn't, the delay needs to be about 1 second IMHO.


    That would still come in as a combat bonus, so if the AI is still, at least partially, using the relative combat strengths to make its decision the AP attribute would be affecting that decision.
    It's OK, I misunderstood and thought the attack and defense values in the formula you gave me had to be those of the same unit, (the unit under scrutiny), and not a specific comparison between 2 fighting units. i.e. they formula just produced a relative strength index vs. a given target unit class. Since the effects of AP are on the enemies defense and that varies with every unit and actually effects the enemies strength index it would have been a near impossibility to account for.

    But if the AI is just doing a straight unit vs. unit match up to determine the kill rates vs everyone and then picks the best possible target for the unit in question, it makes a lot more sense. AND, once the attack delay issue is fixed, should still work. Which implies a very simplistic AI code, (compared to STW), ATM, IMHO.


    Well archers are not very effective against high armored units. Those would be naginata infantry, naginata cavalry, heavy cavalry and hatamoto. They are not cost effective vs teppo or the yari samurai, but are moderately effective against them. They are effective vs yari ashigaru, but again there is the issue of cost effectiveness since they cost twice as much as yari ashigaru. It depends on the tactical situation whether or not you want to use archers against a low cost target. Their best targets are the two low armored sword units and yari Cav and they are good for counter skirmishing Cav archers.
    Thanks for that explanation, but in many ways it vindicates my point, in STW their was only one major infantry melee unit that they could be said to be ineffective. M2TW is like STW in that it is high defense units that archers are ineffective against, but unlike STW the high defense stuff is pretty common.

    ALL spear and sword units in M2TW come with a 6 point shield, and almost all can be upgraded to heavy mail Armour, (7 defense), making even the most basic anti-archer defense value from the front an impressive 13 points, 16 is about the max in game, their might be 1 unit higher, I can't remember off the top of my head.

    Max M2TW Missile attack values for reference, (approx):

    Non-AP Bows = 12
    AP Bows = 9
    Crossbows = 14, (but they shoot slower than bows so it cancels out)


    As you can tell even the most basic unit in the game, (spear militia), can vastly exceed the attack of the best non-AP archers. The equivalent level archer only has 5 attack.

    As a result it's my experience that missile units simply aren't cost effective against Armour upgraded units with Shields.

    Their are some lesser shield equipped infantry units, (mostly composite archers, but also the odd Axe/mace wielding infantry), but even these typically have 10 missile defense, which probably puts them in about the same situation as the STW archers vs. Yari Samurai, moderately effective, but not cost effective.

    They ARE cost effective vs. Pikes/Halberd/2-Handers due to the fact that they typically have a very high price and a missile defense of no more than 8 points, normally rather less as they don't always have lots of Armour upgrades. The Pikes/Halberds are also very slow which makes them very vulnerable as well.

    Add to that that archers with high attack values or AP are rare and crossbows fire too slowly to be of use in offensive battles, (unless you can make your opponent advance slowly, or sit their and be hit they can't match bows because of the slow fire rate), and you have archer issues.

    In effect what i'm driving at is that the list of targets against which missiles are even effective, (let along cost effective), is much narrower in M2TW in all probability and that HAS to be upsetting the RPS IMHO.
    Last edited by Carl; 04-13-2007 at 21:16.
    Find my ProblemFixer Purehere.

    This ProblemFixer fixes the following: 2-Hander bug, Pike Bug, Shield Bug, Chasing Routers, Cav not Charging, Formation Keeping Improved, Trait Bugs, and Ancillary Bugs.

    BETA Testers needed for the current version of RebuildProblemFixer. Thread here

  23. #23
    Masticator of Oreos Member Foz's Avatar
    Join Date
    Dec 2006
    Posts
    968

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Carl
    The above is the alterd coderealting to recruitment. The changes are EXTREMLY extensive, so it's hard to highlight whats changed. My advice would be to get the trial vershion of Beyond Compare 2 from here and use it to compare the uploaded file to the origional. I'll include a copy of the vanillia file for you in case you don't have a backup.


    Link to the full file here
    Thanks Carl. I understand it would be awful to try to delve into everything you've changed. If you get a free moment and feel like it, it would be nice to discuss your basic ideas in making revisions, though.

    As it stands I think I'll let the AI play a bunch of turns using your file and see how the armies come out.


    See my Sig+ below! (Don't see it? Get info here)

  24. #24
    Masticator of Oreos Member Foz's Avatar
    Join Date
    Dec 2006
    Posts
    968

    Default Re: How to improve the tactical AI

    Well I ran off a bunch of turns, and sure enough AI England had some better army composition than it normally would have. However, still a fairly large amount of bad militia. The more I play with things to try to influence army composition, the more I become convinced the only real factor affecting it is economics. I think that primarily my better results were due to Carl's increased free upkeep slots for cities, and the inclusion of free upkeep slots for castles. Playing with unit availability may help some, but in general I believe it is slim at best. At turn 100 I was seeing all units having 4+ members in the recruitment pool, which suggests the pools are not a limiting factor at all right now, for vanilla or modded. My theory on AI recruitment goes like this:

    Basically, the AI will spend all money possible every turn to recruit troops, at the very least in areas it has chosen to focus on (see the AI decision file that lays out all the buildup and attack decisions - many include a directive to build forces in preparation for attack or defense). The AI recruits good troops when the money is available, but if it is not then the AI will choose to recruit poor troops instead of waiting to buy the more expensive troops that it really should be using.

    If I'm right on that, then the ways to combat it include:

    1. Get more money available to the AI. With more cash, it can freely select the better more expensive troops for its armies. Upkeep slots seem to be doing this somewhat, but many other measures could be considered (king's purse, income factor boosts, recruitment cost cuts all come to mind).

    2. Cut off inferior troop types entirely. It seems obvious that the AI will recruit bad troops if money comes into play, so a simple way to counteract this is to remove its ability to do so. If an English fortress allows only knights, armored swordsmen, armored sergeants (note this is a change Carl made that I may keep), Billmen, and Yeoman to be recruited, the AI is sure going to have a hard time making Levy Spearmen, Peasant Archers, and Peasants even if money is tight.

    I have other thoughts and concerns of course, but I'm not really ready to dive into them yet: I really want to hammer out a solid way to make the AI recruit armies that are at the tech level its at before moving on: it seems like the most basic thing to achieve, a cornerstone from which to build. With that in mind, any ideas and feedback would be most useful.

    For the moment I'm going to try aggressively removing troop types entirely as they become outdated and see what happens. Hopefully it means the AI actually builds teched up armies efficiently...


    See my Sig+ below! (Don't see it? Get info here)

  25. #25

    Arrow Re: How to improve the tactical AI

    Quote Originally Posted by Foz
    The more I play with things to try to influence army composition, the more I become convinced the only real factor affecting it is economics.


    1. Get more money available to the AI. With more cash, it can freely select the better more expensive troops for its armies. Upkeep slots seem to be doing this somewhat, but many other measures could be considered (king's purse, income factor boosts, recruitment cost cuts all come to mind).

    2. Cut off inferior troop types entirely. It seems obvious that the AI will recruit bad troops if money comes into play, so a simple way to counteract this is to remove its ability to do so. If an English fortress allows only knights, armored swordsmen, armored sergeants (note this is a change Carl made that I may keep), Billmen, and Yeoman to be recruited, the AI is sure going to have a hard time making Levy Spearmen, Peasant Archers, and Peasants even if money is tight.
    What I said all along. Option 1, however, doesn't seem prudent to me. It's really no good solution just to throw more money at the problem, its fixing the Ai by giving it just an unfair per se advantage. If at all, I'd opt for the 2nd one as long no smart disbanding is implemented into the game code. However, inferior troop types could still be useful, there should be a way to tell the AI to not build above a certain percentage of them.
    Ignoranti, quem portum petat, nullus suus ventus est. -Seneca, Epistulae Morales, VIII, 71, 3

  26. #26

    Default Re: How to improve the tactical AI

    Basically, the AI will spend all money possible every turn to recruit troops
    It does. The whole game is designed round this fact--hence the very fast pop growth and city growth. All designed to keep a continuous flow of new money into the game to allow the AI to spam units.

    For the moment I'm going to try aggressively removing troop types entirely as they become outdated and see what happens. Hopefully it means the AI actually builds teched up armies efficiently
    That's what i've been doing--though so far i've only removed peasants from the 3rd level barracks and above as i got distracted into other modding.

    ~~~

    related side-issue is that the AI will often spam units to the point where it doesn't upgrade it's cities. so it can get stuck with low level units that way too. tis why revolts and lots of aggressive brigand activity can sometimes actually help the AI as clearing mechanisms
    Last edited by nikolai1962; 04-15-2007 at 09:06.
    It's not a map.

  27. #27
    Masticator of Oreos Member Foz's Avatar
    Join Date
    Dec 2006
    Posts
    968

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Brutal DLX
    What I said all along. Option 1, however, doesn't seem prudent to me. It's really no good solution just to throw more money at the problem, its fixing the Ai by giving it just an unfair per se advantage. If at all, I'd opt for the 2nd one as long no smart disbanding is implemented into the game code. However, inferior troop types could still be useful, there should be a way to tell the AI to not build above a certain percentage of them.
    Well, I'm really considering making an across-the-board change to raise income in general. It actually seems to help the AI to have more funds available, not just more than the player. So in essence I'm saying we may be able to close the gap between the two some by actually giving everyone more cash, since the extra cash may help the AI considerably more than the player - the player is already doing things well, generally, while the AI actually starts teching up its cities and troops better if it has more cash.

    For inferior troops, I mean in a pretty strict sense: troops that are the same type but obviously inferior to the newer ones with better stats. Examples would be bad spears in factions that have armored sergeants, peasants after pretty much any reasonable unit becomes available, and knights & archers which tend to be nearly identical except for newer ones having better stats. In general I think it's a bad idea to build those lower tier units when better ones are available, so it seems reasonable to try to make the AI conform to that.

    I removed peasants almost entirely already, but apparently have failed to cut back siege equipment enough, as it keeps showing up. The biggest trouble is the proliferation of town militia though. Haven't quite decided what to do about that just yet...

    Quote Originally Posted by nikolai1962
    related side-issue is that the AI will often spam units to the point where it doesn't upgrade it's cities. so it can get stuck with low level units that way too. tis why revolts and lots of aggressive brigand activity can sometimes actually help the AI as clearing mechanisms
    Yeah, it's a shame the AI can't disband troops, or at least take a stack of crappy ones and smash it against a settlement to weaken the settlement and be rid of the troops. Human players tend to do one or the other and thus keep their armies teched up, but not the AI... which is exactly what prompted me to try to get the AI armies to stay more at the current tech level.


    See my Sig+ below! (Don't see it? Get info here)

  28. #28

    Default Re: How to improve the tactical AI

    I was a bit wrong in what i posted before-- from rtw days really. Tested it out some more. Seems the AI spamming units is more of a VH thing. Giving AI more money on medium (via king's purse) didn't make it build more units.

    Also in my test (with france at balanced smith) the french AI didn't actually build many peasants. seemed to try and build the best available infantry, which meant peasant archers (as i'd pre-placed a bowyer). It's the militia swarm that is the most noticeable (as mentioned above). Easy to see why from the max numbers and high refresh rate. Same with siege weapons.

    Definitely possible to make the AI produce much scarier looking armies by tweaking the numbers. Once you have that then you might find the tactical AI in the battles works better as the player's army won't outclass the opposition so much.

    Another factor is the relative number of towns/castles in a faction. The western factions are better off with more castles maybe. factions with good town units like milan are ok but a faction like france with 3 towns and two castles is not playing to it's strength. I might change rheims to a castle.

    In general I think it's a bad idea to build those lower tier units when better ones are available, so it seems reasonable to try to make the AI conform to that.
    Especially when they have the same upkeep imo.

    I removed peasants almost entirely already, but apparently have failed to cut back siege equipment enough, as it keeps showing up. The biggest trouble is the proliferation of town militia though. Haven't quite decided what to do about that just yet...
    I think it needs to vary with faction. For france their militia units aren't in the same league as their castle infantry so it makes a lot fo sense to cut the max numbers and refresh rate right down imo. To the extent where it is mostly just garrisoning the cities. Let them build armoured sergeants instead :)
    It's not a map.

  29. #29
    Senior Member Senior Member Cheetah's Avatar
    Join Date
    Dec 2001
    Location
    Hungary
    Posts
    2,085

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Xdeathfire
    IMHO, the best way to solve the ai problem is to model the ai's behavior and tactics off of people of varying skills for different difficulty, but have different styles of player that will be modeled after. For example, there could be a blitzer or a turtler and the ai could randomly pick a tactic at the beginning of every campaign.
    IMO some styles fits the AI better than others. For example good blitz (rushing) is not that easy. For example, ATM the AI looks more like a noob rusher than an expert one (sending forth and wasting all of its cavalry well before its infantry could get there). I would say that if that is the AI "knows" about rushing then let it stick to a more conservative style.
    All in all considering the limitations of the AI some styles may not be suitable for the AI at all.
    Lional of Cornwall
    proud member of the Round Table Knights
    ___________________________________
    Death before dishonour.

    "If you wish to weaken the enemy's sword, move first, fly in and cut!" - Ueshiba Morihei O-Sensei

  30. #30
    Senior Member Senior Member Cheetah's Avatar
    Join Date
    Dec 2001
    Location
    Hungary
    Posts
    2,085

    Default Re: How to improve the tactical AI

    Quote Originally Posted by Foz
    I don't think getting the AI to field a lot of cavalry is a solution. As you pointed out, Cheetah, cavalry clearly gives the edge to the player since he is far more adept at maneuvering and using it. Much of this is down to the mobility of the unit, so clearly we want a less mobile unit favored. The only problem with heavy infantry like DFK is that they are somewhat disadvantaged to cavalry (note that working shields make them better than you'd expect - 21 armor goes a long way). The idea then shouldn't be to make the AI rely on heavy cav and try to match the player... but rather, I think it should be to severely limit heavy cavalry, so as to narrow the player's advantage from it, and make core infantry units like DFK viable as the basis for an army. In one move, you'll have put a leash on the human's ability to go nuts with all-heavy-cavalry armies, and allowed the AI to lean on a unit that really ought to be a viable mainstay of any army.
    I think we agree here. I just think that in general there are two ways to deny the cav superiority from the human player: (a) make the AI to build lots of cavs (like mongol style stacks), (b) or limit the human player. I agree that the later option perhaps preferable to the former.

    Quote Originally Posted by Foz
    ideas about recruitment pools ...
    I also agree that something have to be done about recruitment pools, though I have a bit more radical idea, namely to use castle recruitment pools as a max limit for that kind of unit, like we have max limit for priests, spies etc. More about this later.
    Lional of Cornwall
    proud member of the Round Table Knights
    ___________________________________
    Death before dishonour.

    "If you wish to weaken the enemy's sword, move first, fly in and cut!" - Ueshiba Morihei O-Sensei

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO