Played a few more games in CivIV. Terrain defensive bonuses are very powerful and should definitely play a prominent role in strategy for defensive play. I've talked briefly about the basics before, but I can now expound on that a bit more with additional play under my belt.

Assuming that the attacker/defender have no specific unit type bonuses against the opponent... (some units gain +25% against archery units for example). Also ignoring the terrain defense bonuses that some units get (+25% if they're on a hill, or +25% if they're in a city). Here's how it stacks up for defender bonuses. These bonuses only apply if you are the defender in a particular attack.

The basic components are (and these all add together):

1) Whether the defending unit has entrenched themselves into their current square. Most units get this ability (but not all). Every turn, you gain an additional 5% towards your defender strength, with a maximum of 25%.

2) Whether the attacker is crossing a river. The defender gets +25% in that case.

3) The terrain bonus. Flat tiles get no bonus. Coastal tiles provide a +10% bonus and hills give +25%.

4) The "cover" bonus. Any tiles that are covered in jungle or forest add a 50% bonus.

5) Manmade fortifications. These are obsolete against gunpowder units but are useful before then. A fort (built by a worker on an unworked tile) gives +25%. Cities can also have walls built around them which grant 25% as well. There are also other city-specific defense bonuses that come into play and vary a lot (archers get +25% or +50% for sitting on a city tile, a high-culture city gives a bonus).

Obviously, some of the above are mutually exclusive. You can't get the forest bonus if you've built any improvement on the tile (such as a farm, cottage, fort or city). You can't build a fort on a city tile or a mine.

So what does this mean on a practical level? To calculate the combat strength of the unit in a particular situation:

1) Add up all of the defender bonuses from terrain, etc. Add in any bonuses for defending against the attacker's unit type (such as spearmen who get +100% against mounted units). Subtract any negatives that the attacker gets for a particular situation (some attackers get +25% against archers for instance, or +10% for attacking a city tile). The end result is your modifier value (which can be negative).

2) Multiple the result of step 1 against the defender's current strength. This value is typically called "D".

3) Compare against the current strength of the attacker (this value is typically called "A").

Obviously, if you are the attacker, you want a ratio of A/D that is greater then 1.0. Ideally, you want a ratio that is more like 2.0:1 or even 3.0:1. That requires making tactical decisions about which unit to attack with first, because if there are multiple defenders on the target tile the computer will pick the best one to counter with.

Examples (disregarding "vs unit type" bonuses):

A) Attacking units on a neighboring flat tile. No defender bonus for terrain, cover, or situation. So the only modifiers will be any "vs unit type" bonuses. This is the ideal situation for an attacker, because the defender is basically out in the open with nowhere to hide (and no bonuses to bolster their strength).

B) Across a river. Defender gets +25%. Bad move, cross the river, then attack the target from the same side of the river on the next round.

C) Defender on a hill gets +25%. Try to lure the defender off of their tile down onto flat tiles.

D) Defender in a covered tile (forest/jungle) gets +50%. Try to lure the defender off of the covered tile and out into the open.

E) Defender in a fort gets +25%.

F) Defender in a city gets a varying bonus (this is displayed above the city name in the main view, IIRC). Bombardment by seige weapons (catapult, cannon, artillery, tank) should be used first to lower the defense bonus prior to attacking.

G) Defender that has dug in gets +5% to +25%. Make him attack and thereby lose his entrench bonus.

Combinations of the above situations (or why you should never attack a defender on their chosen ground):

A) Forested Hill = +75%

B) Forested Hill, Across a River, Entrenched Defender = +100% (this can go even higher if the defender has hilltop defense bonuses).

C) Forest Hill, Fortified = +50%.

D) Forest Hill, Foritified and Entrenched = +75%.

E) Entrenched defender on a flat tile inside a fort = +50%.

F) City, Across a River, Entrenched Defender = +75% (or even much higher)

Thoughts on how this will play out in CivIV:

A) Barbarians - Barbarian AI is somewhat simplistic. They will make a beeline for the nearest target for the most part. So entrenching archers on a forested hill on the outskirts of your empire will draw many attackers. (A bit like using a bug zapper to keep the insect population down.) Sometimes they will bypass your pickets and go on a pillaging run, so you will need to have backup plans for when they play smarter.

B) AI Opponents - A bit craftier and more likely to calculate odds of winning rather then suicide on your defenses. In this case, static hard points are merely staging areas for raids on the enemies avenue of attack. Your goal is to herd the enemy to a place of your choosing where you can slaughter them without them having any defensive bonus from terrain.

C) Human Opponents - All bets are off. They may choose to wear you down, or use feints to draw your forces off to one side, etc.. The goal is to out-maneuver your opponent so that you can bring more forces to a particular battle them they can.

Obviously, the ideal situation is a series of pickets in a desert or grassland environment where there are conveniently spaced forested hills with only 2 flat tiles between hills. If you position pickets on every hill, the enemy cannot slip past your pickets without taking 1-3 turns worth of attacks.

The terrain generator in CivIV, however, is never that accomodating. So instead you have to make do with what it gives you and formulate a new plan for just about every situation. What will you do if an attacker attempts to bypass point X and drive directly against target Y? Will you be able to wither his flanks, or can he stay on forest/jungle/hill tiles to lower your chances of success?