Heaven’s Design Pages

Getting the CP to Build Walls and Towers in Scenarios

By Bruce Denyes


Download the scenario and other documentation that goes with this article - A Must!

1. The Perimeter Defence Zone (PDZ)
2. Wall Building in the "Perimeter Defence Zone"
3. Controlling the Number of Gates, Their Width and Placement
4. Estimating the Number of Towers Required
5. Tower Building in the "Perimeter Defence Zone"
6. Estimating the Number of Towers Required
7. Wall and Tower Strategies
8. Play Test the Scenario
9. Illustrative Wall Building Scenario

One of the common problems experienced by many scenario developers is programming the Computer Player (CP) via the .ai and .per files to build walls in neat lines and towers in desirable places. This article contains methods and tips to control the building and placement of walls and towers by CP's in Age of Empires Scenarios.


The Perimeter Defence Zone (PDZ)

In .per files, there are two strategic numbers (SN's) which can be set to control the minimum and maximum town size - these are:

SN73 - SNMinimumTownSize and
SN74 - SNMaximumTownSize.

SN74 controls the location of the outer boundaries (or perimeter) of your town. SN74 specifies the number of tiles that each of the four town borders will be located - the tiles are measured outward from the Town Centre. For example, SN74 set to 20 would locate the outer borders of the town at a distance of 20 tiles from the Town Centre. The outer perimeter of the town takes the shape of a SQUARE (not a circle) with each edge of the square being 20 tiles from the Town Centre. The perimeter of the square is equal to the value set for SN74 multiplied by eight (8) - in our example, 20 tiles multiplied by 8 equals a 160 tile perimeter. ALL buildings will be located within this 160 tile town boundary.

SN73 sets the minimum town size - also measured in tiles outward from the Town Centre. The term "minimum town size" is somewhat misleading. What the "minimum town size" SN really does is define the inner boundary of what the author has termed the "Perimeter Defence Zone" (PDZ). The width of the PDZ is the difference between the values set for SN74 and SN73 (i.e. the maximum town size minus the minimum town size). The PDZ can be thought of as a "narrow" strip of land bordering the outer perimeter of the town. Continuing with our example, if SN73 is set to 17, then the width of the Perimeter Defence Zone would be SN74 - SN73 = 20 - 17 = 3 tiles. The PDZ is now established as a zone 3 tiles wide located all the way around the outer portion of the town area. Another way to visualize the PDZ would be as a narrow band 3 tiles wide around the outer boundaries of the town - the outer part of the band being located at a distance of 20 tiles and the inner part of the band at a distance of 17 tiles from the Town Centre.

What is the real significance of the PDZ? All defensive structures, which include walls and towers, are built within this zone and ONLY in this zone. By controlling the width of the zone, the scenario designer can control the placement of walls and towers built by the CP. Other non-defensive type buildings (such as Archery Ranges, Stables, Academies, etc.) may still be constructed in the PDZ area.

CAUTION: When setting values for SN73 and SN74 in .per files, be sure to specify a value for each SN to avoid conflicts with the default values.

CAUTION: If SN73 and SN74 are both set to the same value, then the width of your PDZ is effectively zero, and NO WALLS OR TOWERS WILL BE CONSTRUCTED even though they are specified in the .ai file.


Wall Building in the "Perimeter Defence Zone"

The "randomness" of CP wall building can be controlled by setting the width of the PDZ zone. Many scenarios do not set values for SN73 and SN74 in the .per files, or if they do, the resulting PDZ is often very wide (from 5 to 10 tiles). If SN73 and SN74 are not set in the .per files, then the software uses the default
values. Although the default values are not known for certain, it is suspected that for a "large" size map SN74 = 20 and SN73 = 15 which results in a PDZ width of 5 tiles. Other map sizes may adjust these SN's for compatibility with the overall map area. The wider the PDZ - the more "random" and "erratic" wall building will become - the "randomness" will decrease as the PDZ narrows. If accurate wall building is a priority in a scenario, then the PDZ should be restricted to 3 or less.

Precise wall building can be accomplished by setting the width of the PDZ to one (1) (this means setting SN74 and SN73 in the .per file so that SN74 - SN73 = 1) and by using the .ai file to instruct the CP on the total quantity of wall units and the build lot sizes. With a PDZ width of one, the CP will build a wall one tile wide around the entire perimeter of the town (the CP cannot build wall outside of the PDZ). The wall will be formed in an exact straight line; the wall will span obstacles (such as resource units and obstructions like bodies of water); the wall will build over elevation changes and over cosmetic type units such as rocks, ground cracks, etc.. By building the wall in a series of small sized lots (5 to 10 units is recommended) spaced
throughout the .ai file, areas on the perimeter that are at first blocked to wall building by removable resource units will later be filled with wall as the resource units are removed. For example, a berry bush or a stone mine may be located on the perimeter where the wall is to be built; after the resource is removed by "gathering" villagers, the building of small quantities of wall in the .ai file will result in wall "gaps" being filled in.

When the width of the PDZ is set to 2, the "randomness" of wall building will increase - but perhaps not objectionably so. A PDZ of 2 or higher does, however, give the CP the opportunity to build around obstacles it encounters. With the PDZ set to 2, the CP may build double thick walls in some areas - this could at times be a benefit - especially if the civilization is Babylonian!!!

If the width of the PDZ is set to 3 or higher (which is the case with many scenarios and certain for random mode game play), the "randomness" of wall building will increase dramatically. In some cases, walls will "double-back" on themselves and may even create triple thicknesses. This can create awesome fortifications but has several disadvantages (watch the expert Babylonian masonry builders of CP 6 in the Walls.scn - also described in the "Illustrative Wall Building Scenario" section below).


Controlling the Number of Gates, Their Width and Placement

One of the major problems associated with building walls using .per and .ai files is controlling the number of gates and their width and placement. The AOE software and Scenario Builder do not provide many effective tools to help the scenario designer with gate building. The gate problem in turn makes estimating the quantity of wall units needed a very tricky task - too many wall units coupled with a PDZ of 1 and the CP may end up actually walling itself in!! - this would be disastrous at any stage of the game.

Calculating the quantity of wall units needed would be much simpler if two other SN's in the .per file could be made to function correctly - namely SN84 SNNumberWallGates and SN85 SNSizeWallGates. All attempts by the author in setting these two SN's under controlled test conditions failed to produce any type of gate opening in perimeter walls. The author would appreciate hearing from fellow designers who have successfully used SN's 84 and 85. The author has been able to produce only one gate (of varying width) in a wall by carefully setting the wall build quantities in the .ai file (see CP2 in the Walls.scn). Also, the placement of the gate cannot be controlled using the .ai or .per files.

The author has also had no luck with using .cty files to control the placement of walls and gates by means of specifying building x/y co-ordinates. In fact, .cty files are a veritable nightmare to work with - the AOE game could certainly do with some type of city plan editor. Also, it is recommended that, in the Scenario Builder - Player Section, the "City Plan" be set to "None". DO NOT select the "Default.cty" file as this default file will prevent Wonders from being built.

The most effective way of controlling the number, width and location of gates is to place "shallows" terrain on the map using the Scenario Builder. Once the PDZ has been set, place "shallows" to cover the area on the PDZ where the gate is to be located. The CP will not be able to build wall on the "shallows" terrain but the "shallows" will not restrict the movement of villagers or military units. The "shallows" doesn't look great graphically (or blend in with a nicely landscaped city) but it does solve the gate location problem. Refer to CP's 5 and 6 in the Walls.scn for examples of how to use "shallows" terrain to control gate placement. The use of the "shallows" method is practically mandatory to prevent the CP from walling itself in when the PDZ is set to 2 or 3. AOE really needs to be patched/updated to provide a graphical GATE unit which could be placed on the map to restrict wall building but still allow villagers to pass through (similar to the function of the "shallows" terrain).


Estimating the Quantity of Wall Units Required

An initial estimate of the number of wall units needed can be made by multiplying the maximum town size (SN74) by a factor of 8. For example, if the PDZ is set to 1 tile wide and the maximum town size has been set to 15 tiles, then the number of wall units required to completely enclose the perimeter of the town would be 15 x 8 = 120 wall units. Building this number of units would, however, completely enclose the town.

From the estimated number of wall units must be subtracted the desired width of the gate (in tiles). Also to be subtracted are the number of tiles on the town perimeter occupied by permanent obstructions (such as cliffs or bodies of water). The number of tiles occupied by resource units should also be subtracted. The resulting number of wall units can then be safely built as early in the game as the Tool Age without danger of walling in the CP.

The tile spaces initially occupied by resource units can be walled in later once they have been removed by "gatherers" by specifying the building of the necessary number of wall units in small quantities towards the end of the .ai file.

Three instances require special care in calculating the quantity of units required to effectively wall a CP's town. In all cases, several play-testing runs will likely be required to finalize the quantity of wall needed.

1) When the Town Centre is situated such that part of the PDZ is cut-off by one or more of the map boundaries, the number of perimeter wall units may have to be reduced considerably. When in the Scenario Builder, press < Ctrl+B > to display an on-screen tile grid overlaying your scenario landscape. Each full (unbroken) town border will require SN74 (maximum town size) times two(2) number of wall tiles. For the remaining broken borders, simply count the number of tiles required. Using a Gaia object such as "ROCK2" to mark the corners of your town perimeter (or other reference points) may help when counting tiles - they can always be removed later. After totalling the number of perimeter tiles needed, make reduction adjustments for the gate opening, permanent obstacles, and resource units as described above.

2) When building walls around towns located on "small island" maps, care must be taken not to wall in the CP early in the game - this would have the effect of cutting the CP off from needed resources located elsewhere on its home island and impeding its advancement through the various age levels. For CP's operating on "small island" maps, it is definitely safer to build walls toward the end of the .ai file. Play-testing of wall building in "small island" scenarios is mandatory.

3) When the PDZ is set to a width of 2 or more tiles, the accurate estimation of wall quantities becomes more difficult - increasing as the width of the PDZ increases. Play-testing is a must. As a general rule-of-thumb, an initial estimate can be made by calculating the number of wall units needed to build on the perimeter (as described above for a PDZ of 1) and then increase the quantity by 50% for a PDZ of 2 and by 100% for a PDZ of 3. For example, if the PDZ is 2, multiply the normal wall quantity by a factor of 1.5 - if the PDZ is 3, multiply by a factor of 2 - and if the PDZ is 4, multiply by 2.5 - and so on. Play-test the scenario and increase or decrease the quantities as required to achieve the desired effect. A great deal of multiple wall building is likely to occur with PDZ's of 2 and higher.


Tower Building in the "Perimeter Defence Zone"

ALL towers will be built within the PDZ.

For towers to be built, the PDZ need only be one (1) tile wide. However, if the perimeter is entirely occupied with wall units, the result will be no room left for towers, and no towers will be built. For the purposes of tower building, a PDZ two (2) tiles wide will function pretty much the same as if the PDZ was one (1) tile wide - towers will simply be placed around the town perimeter in a fairly straight line.

To build BOTH towers and walls on a 1 or 2 tile wide PDZ, it is best to place the towers ahead of wall units in the .ai file to ensure that the towers will be able to find a suitable building location along the PDZ. Place the building of walls later in the .ai file (or interspersed in small quantities among other building units). By placing towers first, subsequent wall units will be able to fill in the spaces between the towers. The result will be a defensive zone (1 or 2 tiles wide) around the entire perimeter of the town - the perimeter being protected by either a tower or a wall unit.

If the PDZ is set to 3, then the CP will be able to build both walls and towers at any point on the PDZ. If a wall is built first, then the tower will usually be placed behind the wall (i.e. on the inside of the wall - within the town compound). If the tower is built first, it will usually be placed on the outer edge of the PDZ and the wall will either be built behind or adjacent to the tower.

If the PDZ is set at 4 or higher, then the building of walls and towers will be much more variable being spread throughout the PDZ area. It will also be possible to build more units of each type. Wide PDZ's will play havoc with wall placement, but if walls are not required, a wide PDZ can be a very effective way of spreading towers throughout the town area (see CP 8 in the Walls scenario). Narrowing the PDZ width will restrict and move tower placement toward the outer edges of the town.


Estimating the Number of Towers Required

The number and sequencing of towers to be built by a CP should be specified by the designer in the .ai file (as opposed to relying on the tower autobuild feature). In the .per file, SN207 SnAutoBuildTowers should be set to zero (off) and SN222 SNMaxTowers should be set to the maximum number of towers to be built.

If equally spaced towers are desired around the perimeter of the town, the number of towers needed can be estimated using the following formula:

Number of Perimeter Towers = (SN74 x 8)/(Desired Tower Spacing)

For example, if SN74 is set to 15 tiles and it is desired to have the CP build towers around the town perimeter spaced on average 6 tiles apart, then the number of towers required would be (15 x 8)/6 = 20 towers.


Wall and Tower Strategies

The scenario designer must carefully choose the width of the PDZ to accommodate the location of the town, surrounding terrain and town space limitations. The strategy to be employed by the CP must also be taken into account (i.e. are walls needed at all?? - after all, they do take time and resources to build). The designer should understand how wall/tower building and placement is done in the PDZ and have a feel for the advantages and limitations associated with various PDZ widths.

For example, a town with a perimeter defence built on a PDZ one tile wide, may be susceptible to breakthrough of the perimeter defence by a concentrated attacking force. Depending on the size of the town, the remainder of the perimeter defences could then be rendered ineffectual in protecting the town buildings.

If the designer does not wish to build walls, then it may be best to set a wide PDZ. In this way, many towers can be built and the towers will be distributed evenly throughout the town area thereby providing better defensive coverage. It should be noted that setting a wide PDZ does not restrict the location of other building types - they can still be constructed in the PDZ up to the outer limits of the town (SN74 - SNMaximumTownSize). The PDZ width restricts the building of walls and towers only.

If the designer wants to construct only walls (no towers), then a PDZ width of 1 would probably be the most appropriate - this will result in neater, straighter looking walls. A PDZ of 2 will result in double fortifications in some areas and but will provide more flexibility for the CP to build walls around obstacles. PDZ's of 2 or higher require that more wall units be specified in the .ai file than would be required for building a perimeter wall only one PDZ wide.


Play Test the Scenario

As all good scenario designers know, the creation of a successful scenario requires that it be play-tested many times. The same holds true with respect to the evaluating the effectiveness of wall and tower building in scenarios.

Play Testing Tips:

1) The process of fine-tuning .ai and .per files can be accelerated by using the < Alt+Tab > key combination to switch between the AOE Data directory where the .per and .ai files are located and the AOE Scenario Builder. Use Notepad to open and modify the .per and .ai files - just be sure to save and close the files in Notepad before switching back to the Scenario Builder. Selecting "Test" from the Scenario builder menu will automatically read and incorporate your modified .per and .ai files into the scenario test run.

2) Use the "//" line prefix in both .per and .ai files to "remark" out various lines without having to actually delete them - this will render the line inoperable. In this way, the line can be restored very simply by deleting the "//" and the line does not need to be retyped.


Illustrative Wall Building Scenario

An illustrative Wall Building Scenario is included with this .ZIP file package. The scenario shows how .per and .ai files can be written to build walls and towers using the methods described in this article.

The WALLS.zip file contains a WALLS.scn file along with WALLS2.ai to WALLS8.ai and WALLS2.per to WALLS8.per files for each of the seven computer players in the Wall Building scenario. Copy the .SCN file to the AOE "Scenario" directory and the .ai and .per files to the AOE "Data" directory. Start the scenario either from the AOE Main Menu or from within the AOE Scenario Builder. Type in the cheat commands "reveal map" and "no fog". Your computer player (blue) is located in the upper left corner of the map - but you need do nothing with your villagers. Simply move around the map and observe each of the computer players (2 to 8) building various types of wall and tower defences as described below. All players have been set to "Ally" and no military units are produced. The scenario takes about 10-15 minutes to run.

Gaia ROCK2 units have been placed as reference markers outward from each Town Centre to show the x/y axes; rocks are spaced at 2 tile intervals.

Included in the WALLS.ZIP file are 3 additional files: this instructional file WALLS.txt (DOS ASCII text format), WALLS.doc (contains the same material as WALLS.txt but is in a format that can be read by WIN95's Wordpad), and a short introductory README.txt file.

Notes on the wall/tower building activities of each computer player are given below.


CP2 - Location: Center of Map - Assyrian (Red CP)
PDZ = 1 Walls2.per and Walls2.ai Files

This is an example of wall building at its simplest. The Walls2.per file sets the maximum town size (SN74) at 12 tiles and the minimum town size (SN73) at 11 tiles. This results in a Perimeter Defence Zone (PDZ) one (1) tile wide. A wall one tile wide is built around the entire town perimeter with one 3 tile wide gate providing access to the town.

The number of wall units required = 12 x 8 = 96 - 3 (gate opening) = 93. Wall building in the Walls2.ai file is interspersed with construction of other buildings.


CP3 - Location: North Center of Map - Sumerian (Yellow CP)
PDZ = 1 Walls3.per and Walls3.ai Files

This CP shows how to build a combination of single width walls and towers around the town perimeter. The Walls3.per file sets the maximum town size (SN74) to 12 tiles and the minimum town size (SN73) to 11 tiles. This results in a Perimeter Defence Zone one (1) tile wide. Be sure that SN222 MaxTowers is set equal to or greater than the number of towers the .ai must build - in this case 16.

The desired average tower spacing is 6 tiles; therefore, the number of towers required is (12 x 8)/6 = 16. Spaces 2 or more tiles wide between towers will be walled in; spaces only 1 tile wide between towers will be left open as a gate; the CP does this automatically.

Each tower is 2 units wide which means that a total of 32 tiles (16 x 2) must be reserved on the perimeter to accommodate the towers. The number of wall units required = (12 x 8) - 3 (gate opening) - 32 (for towers) = 61 tiles. The towers are built in the first part of the .ai file - before most of the walls.


CP4 - Location: North-East Corner of Map - Minoan (Brown CP)
PDZ = 1 Walls4.per and Walls4.ai Files

This wall building example has the CP building over various types of terrain, and around both permanent and removable resource "obstacles".

The Walls4.per sets the maximum town size (SN74) at 12 tiles and the minimum town size (SN73) at 11 tiles. This results in a Perimeter Defence Zone one (1) tile wide. SN222 has been set equal to the number of towers to be built - in this case 4.

A single width wall and 4 towers are built around the town perimeter. The CP builds the wall around "obstacles" encountered. Walls are not built through permanent obstacles such as bodies of water and cliffs. Walls are not built through resource objects such as berry bushes, stone and gold mines until they have been removed by gatherers. Walls are built through forest areas (if the villager can access the designated build square) and over changes in terrain elevation.

An estimate of the number of wall units required = (12 x 8) - 4 (for gate openings) - 8 (for 4 towers x 2) - 6 (for permanent obstacles i.e. 1 for cliffs and 5 for water) = 78 wall units. Subtract a further 3 units for berry bushes and stone mines that lie on the perimeter. For the first test-run of the .ai, the CP should place 75 wall units. The quantity of wall units to be built can be adjusted on the basis of play-testing runs.

If desired, several small wall build quantities can be placed near the end of the .ai file to fill in wall sections that were initially "blocked" by removable resources (in this example, 3 units).

Be sure to build the 4 towers near the top of the .ai file.


CP5 - Location: East Side of Map - Babylonian (Orange)
PDZ = 2 Walls5.per and Walls5.ai Files

CP5 demonstrates wall and tower building in a PDZ 2 tiles wide. The Walls5.per file sets the maximum town size (SN74) at 12 tiles and the minimum town size (SN73) at 10 tiles. This results in a Perimeter Defence Zone (PDZ) two (2) tiles wide. With a PDZ of 2 tiles, wall building will be more random and double wall thickness will be built in some areas. Wall building can be controlled somewhat by the careful placement of removable resources and fixed obstacles.

This .ai also shows how "shallows" terrain can be used to control the location and width of gates. Be sure to make the shallows as wide as the PDZ - in this case two wall tiles wide. The width of the shallows area along the perimeter controls the width of the gate.

An estimate of wall units needed = (12 x 8) = 96 - 12 (for 6 towers x 2)- 6 (for gate openings) = 78.

Guideline: when the PDZ is 2, increase the number of wall units needed by 50% to account for areas where double thick walls will be constructed. On this basis, the number of wall units needed in the .ai will be 78 x 1.50 = 117. Subsequent play-testing indicated that an additional 15 wall tiles should be added bringing the total to 132.


CP6 - Location: South Center of Map - Babylonian (Light Green CP)
PDZ = 3 Walls6.per and Walls6.ai Files

This CP does a fantastic job of wall building!!! Walls of triple thickness are built in some areas which can create an awesome fortification - especially when the civilization is Babylonian (with their extra wall and tower hit points).

The Walls6.per file sets the maximum town size (SN74) at 12 tiles and the minimum town size (SN73) at 9 tiles. This results in a Perimeter Defence Zone three (3) tiles wide. Be sure that SN222 is set equal to or greater than the number of towers that are to be built in the .ai - in this case 8.

This .ai shows that wall building becomes much more random as the PDZ increases. When the PDZ is set to 3, many wall sections of triple thickness will be constructed. Building walls in a PDZ 3 tiles wide has several disadvantages: 1) greatly increased quantities of wall must be built; 2) occasionally, the CP will actually entomb (wall-in) one of its own builders - this generally results in the .ai building plan "hanging-up" or drastically slowing down; and 3) gates MUST be controlled by means of using "shallows" terrain or the CP is in very real danger of walling itself in.

In this .ai, the location and width of gates is controlled by placing "shallows" terrain where the gates are needed. Walls and towers will not be built on "shallows" terrain but villagers and military units can still pass through the "gate" area. Make sure that the "shallows" terrain is placed to cover the full tile width of the PDZ - use the grid (Ctrl+B) and play-testing to fine-tune the exact location(s) for gates. There are 4 gates placed in this .ai - all have a depth of 3 tiles with 2 gates being 2 tiles wide and the other 2 gates being 1 tile wide.

When using PDZ values of 3, ample play-testing will be required to establish the right number of wall units to build. Too many units and the CP may wall itself in. An initial estimate of the number of wall units required can be made by multiplying the value set for SN74 by 8 (in this .ai file 12 x 8 = 96 wall units), subtracting for tower and gate openings, and then increasing this quantity by 100% (double it). On this basis, the initial number of wall units needed in this .ai file was estimated as = 96 - 6 (for 2 gate openings 2 tiles wide and 2 openings 1 unit wide) - 16 for towers (8 towers x 2) = 74 which was multiplied by 2 = 148. After play-testing, it was found that 20 more wall tiles were required for a total of 168.

When the PDZ is 3 or higher, the CP may actually wall-in one or more of its villagers/builders. If the .ai appears to "hang" in it's building process, then a builder may be either walled-in or unable to access a square on which he has been assigned to build. In such cases, it may be necessary to adjust terrain elevations and "obstacles".

The 8 towers are built near the top of the .ai file.


CP7 - Location: South-West Corner of the Map Phoenician (Grey CP)
PDZ = broken Walls7.per and Walls7.ai Files

The purpose of this example is to illustrate wall building when the perimeter of the town is "broken" or reduced by the map edges.

The Walls7.per file sets the maximum town size (SN74) at 18 tiles and the minimum town size (SN73) at 17 tiles. This results in a Perimeter Defence Zone one (1) tile wide. When the Town Center is located near a corner or edge of the map, the town radius must be set much higher than normal to allow the CP ample area in which to construct town buildings.

This .ai builds 6 towers and a single width wall around the town perimeter. To estimate the number of wall units required, begin by determining the number of perimeter sections that are not cut by a map edge and then use <Ctrl+B> in the AOE Scenario Builder to turn on the grid and count the remaining perimeter tiles. In this .ai, there are 2 unbroken perimeter sections which require (18 x 2) = 36 wall units. The wall tiles needed for the rest of the perimeter were counted at 14 tiles. The total wall units needed was then determined as being 36 + 14 = 50 - 4 (for gate openings) and - 12 (for 6 towers) = 34 wall units.


CP8 - Location: West Side of Map - Yamato (Turquoise CP)
PDZ = 13 Walls8.per and Walls8.ai Files

The Walls8.per sets the maximum town size (SN74) at 14 tiles and the minimum town size (SN73) at 1 tile. This results in a Perimeter Defence Zone 13 tiles wide - pretty much the entire town area. A wide PDZ will most certainly play havoc with wall building, but will allow the CP to place towers throughout the town area for wide defensive coverage.

This .ai builds 16 towers throughout the town area. 20 wall units are also constructed by the .ai to demonstrate the random location of wall building when a wide PDZ is used. The .ai also includes the construction of 8 town buildings.

Congratulations!! You've now completed the AOE Wall and Tower Building Tutorial 101 - with a little practice you'll soon have your Master's Degree in Stone Masonry !!!

Back to Top