# choke point mini mod

#### dreiche2

##### Prince
I expanded a little bit on the choke point algorithm I used once in my flavor scripts. This little module searches for choke points on the current map, evaluates their 'chokiness' using a custom algorithm, and then places forts on the better choke points.

Choke value:

The idea is that a choke point between two areas is the better the "longer you have to walk" around the blocking tiles until you get from on to the other side. Starting towards an free tile from the choke point, the algorithm counts the number of steps necessary to get back to the choke point while clinging to the blocking tiles at its right hand side. If the choke point hasn't been reached after CHOKE_FORT_MAX_WALK steps, it aborts and the latter value is taken as result.
Then it does the same with starting in the opposite direction. The choke point value is then the minimum of the two step counts.

Note: When the choke points sits on a land bridge that separates two areas of land, the step count obtained from the above algorithm will be an approximate measure for the size of the separated areas. Hence, also here it can be seen as an appropriate measure for the qualitiy of the choke point.

For further details, see selected comments from the script in the spoiler:

Spoiler :
FILE: ChokeFortModule.py
VERSION: 1.00
AUTHOR: David Reichert (dreiche2)
PURPOSE: Find good choke points and place forts on them.

DESCRIPTION:
This module provides a function placeForts(), which will place forts on choke points, i.e. land bridges, mountain passes, etc. It could for example be called from within a map script or from within inititialization procedures of a mod. The script searches for the choke points and examines them for their 'choke value', see below. It will start with the best choke points, and the minimal valid choke value and the minimal distance between forts can be set via global parameters.

A plot is defined as choke point in 6 different situations:
(the central plot is the choke point, x is blocking, o is land, in u there must be at least one land per area)

1 2
uuu uxu
xox uou
uuu uxu

3 4 5 6
oxx xxo xuu uux
xou uox xou uox
xuu uux oxx xxo

Details of the algorithm:

When talking about "right" and "left", this is always meant relative to the direction the 'walker' is currently facing:

nortwest north northeast
west 0 east
southwest south southeast

left front left front

back left / front right

back back right right

Run I:
start:
-face east
-if not blocked:
*while front right is free, turn front right
-else:
*turn front left until front is free
(#front right is blocked now#)
-go front, save this initial direction
walk:
-while current position != starting point and steps <= max steps
*if last step was diagonal:
+face right
*else:
+face front right (#asymmetry comes from quadratic map grid#)
(#front right is blocked now#)
*while front is blocked, turn front left
*go front, steps=steps+1

Run II:
as Run I, but in beginning face in opposite direction from Run I initial direction

Proof that this algorithm works: Proven by example

screens:

The icy spots mark the tiles the algorithm "walked". They are shown for debugging reasons only, of course, and will not be placed normally.

Installation:

To try it out, you'll have to replace one of the default FfH files with one provided.

View attachment ChokeFortModule.zip

There are two files in the archive, ChokeFortModule.py and a modified CvEventManager.py, the latter for FfH 0.21

1. Go to Mods/<current FFH dir>/Assets/python/
2. Backup the file CvEventManager.py so that you can do undo the changes!
3. Extract the archive here. In the end, you should have the module file and the modified event manager file in this directory. Note that the modified file just has two additional lines: one imports the module, the other one calls the placeForts() function.

Note 1: For new FfH versions, the event manager file possibly has to be updated.

Note 2: I think sometimes forts still get placed at not so great spots, although not often. I'm currently out of time to search for the reason, but it's not that bad, anyway.

#### dreiche2

##### Prince
general thoughts:

I've chosen the forts for the choke points because they seem to be underused, and they somehow fit (they could be ancient forts just like there are ancient towers). Still, with 25% defensive bonus, they're not that great.

1. Increase fort defense bonus.
2. Maybe place a resource at the choke points so that the AI guards them. Maybe a new one, related to trade/tolls or something, maybe one that actually needs forts as improvement to be harvested...
3. Something else for the choke points, some sort of natural defenses, whatever...

#### seZereth

##### FfH´s art monk(ey)
That sounds and looks great, i also appreciate your ideas!

#### eerr

##### Emperor
maybe.. a rescource that gives trade routes? lol

#### Go Boks

##### Prince
Maybe a goodie hut inside?

It would be cool if Doviello style barbarian units, as opposed to Orcs, occupied them. Sort of an ice age hold over that never got big enough to start a civ. Maybe a warrior or two to guard the fort, and a horseman or two to send out raiding parties? If you had the map place these units, you might not need a resource at all as you would have to take them out to move through the choke point.

Another thought on forts in general to make them more useful. Make them buildable anywhere. If it is connected to your trade network, any units inside don't have a unit supply cost. Maybe also give it zone of control from previous Civ games?

Otherwise, you could make them work like colonies from Civ 3.

#### Thennorin

##### Chieftain
Great idea! But given the sheer number of threads and suggestions on how to improve forts and the distinct lack of trialling any of them, I don't think they're going to be useful any time soon Still, if ever they are I'll grab this script immediately. Thanks!

#### Chandrasekhar

##### Determined
Wow, that's a nifty feature.

#### dreiche2

##### Prince
The thing with the choke points is to 50% a proof of concept, something I wanted to try out for quite some time... we'll have to see if something really useful comes out of it. Maybe the code could also be used for strategical considerations of the AI, without necessarily placing anything on the plots...

#### onedreamer

##### Dragon
completely off topic, but where did you get that retreating-ice terrain I see in the screenshots ?

#### dreiche2

##### Prince
That's simply what it looks like when you place the ice 'feature' on those terrains... I think usually it's only on oceans? That's also why it looks 'retreating', it intersects with land tiles, which apparently have the same height.

#### Go Boks

##### Prince
Might be worth remembering that if the team ever decides to implement a retreating ice caps as the Age of Ice ends concept to preserve unexplored wilderness for the mid to late game. You would also have to make ice an impassable terrain.

##### Deity
It would make sense from a flavour perspective to have a much higher defensive bonus in a fort if your unit is fortified there. Perhaps forts could give +25&#37; defence normally but a fortified unit in a fort gets 2x bonus on their total defensive strength.

#### eerr

##### Emperor
now we just need randomly generated deathnights to guard randomly generated fortresses
: O

#### Go Boks

##### Prince
How about the Knights of Nee?

#### eerr

##### Emperor
How about the Knights of Nee?

give them a sword that goes snicker-snack!

#### JDexter

##### Prince
Has anyone tried this with 0.25 already?

#### Kael

##### Deity
It wouldn't work, it will need to be converted (the particular way this is implemented means that it would need to be converted for each patch).

#### [NWO]_Valis

If someone picks up the torch here is a nice thread in the new SDK/python subforum about forts having zone of control and expanding curtular borders [source code included].

I bet there are some ppl who would love to have it implemented.

#### Kael

##### Deity
Personally I think it would be better to implement this as a custom map script, not as a mini-mod or python replacement (as it was done the first time).

Done correctly a custom map script won't be obsoleted by new versions (as long as the fort improvement is maintained and we have no plans to remove it).

Replies
14
Views
907
Replies
1
Views
393
Replies
5
Views
749
Replies
6
Views
773
Replies
42
Views
6K