Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] [thomas@xxxxxxxxxxxxxx: All the facts of the Civ2 combat s
Home

[Freeciv-Dev] [thomas@xxxxxxxxxxxxxx: All the facts of the Civ2 combat s

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] [thomas@xxxxxxxxxxxxxx: All the facts of the Civ2 combat system]
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 6 Oct 2001 09:50:31 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

This may be of general interest.

        Raimar

----- Forwarded message from "T.J.T van Kooten" <thomas@xxxxxxxxxxxxxx> -----

From: "T.J.T van Kooten" <thomas@xxxxxxxxxxxxxx>
To: <rf13@xxxxxxxxxxxxxxxxx>
Subject: All the facts of the Civ2 combat system
Date: Sat, 6 Oct 2001 00:37:52 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200


Hi there,


I don't know if you check out the Civ2 forums at Apolyton so you might have
heard of this: everytging you wanted to know about Civ2 combat but were
afraid to ask. It's a long article that can be found in the Great Libary
thread in the Civ2 strategy forum. I think it might interest freeciv
developers as well.


Cheers,

CapTVK






Combat



Table Of Contents


Basics
Unit Combat Factors
Adjustment Factors
The Combat Formula
Additional Considerations
Healing
Hints and Tips
False Statements



----------------------------------------------------------------------------
----


Basics


1.1 Combat occurs when a unit with an attack value greater than 0 attempts
to enter a square occupied by a unit of another, non-allied, civilization.

1.2 A battle results in the destruction of one unit or the other. If the
primary defender is destroyed, all other defenders (stacked) in the same
square are also destroyed unless:

they occupy a city square, or
the square has the fortress improvement built on it.

The primary defender is the unit with the greatest modified defense value at
the moment of the attack.

1.3 Units involved in combat usually sustain damage. Damage is shown in the
unit's strength bar by color and percentage.

Green: 2/3 to full strength
Yellow: 1/3 to 2/3 strength
Red: less than 1/3 strength

1.4 Except for air units, damaged units have reduced movement points
approximately proportional to the damage. However, land units will never
have less than 1 movement, and sea units will never have less than 2. The
proportion of damage is rounded to the nearest integer, but never less than
the minimum for that unit.

CMP = CHP/HP * MP + 0.2

CMP...current movement points
CHP...current hit points
HP...maximum hit points (from rules.txt)
MP...maximum movement points (from rules.txt)

1.5 Ground units can only attack other ground units. Exceptions: Helicopters
can be attacked by ground units if they occupy a land square. A sea or air
unit may be attacked if it is the primary defender in a city or airbase.

1.6 Air units can attack only ground or sea units. Air units with the "Can
attack air units" flag (fighters) can also attack other air units. Air units
attacking ground units ignore city walls.

1.7 Sea units can attack other sea units or any unit occupying a sea square
or land square adjacent to a sea square, including cities. This includes
helicopters, land units, or any air units caught on the ground in a city or
airbase. Exceptions: Airborne bombers cannot be attacked by sea units. Units
with the "Submarine advantages/disadvantages" (submarines, thus) cannot
attack land units. When a sea unit attacks a land unit, it is called shore
bombardment.

1.8 Special domain 3 units can be attacked by any other unit, regardless of
flags. Domain 3 units can attack any other unit, and they ignore city walls,
SAMs, and coastal fortresses.




----------------------------------------------------------------------------
----


Unit Combat Factors


Units have four basic factors figured into the calculation of a combat
result: attack strength, defense strength, hit points, and firepower.

2.1 Attack strength is the likelihood of inflicting damage when attacking an
opponent. Units with 0 attack strength cannot initiate combat.

2.2 Defense strength represents the ability of a unit to defend itself when
attacked; It is the likelihood that damage will be inflicted on an attacking
unit.

2.3 Hit points indicate how much damage a unit can withstand before it is
destroyed. The true number of hit points is the hp value x10. A 2hp unit
thus has 20 hit points.

2.4 Firepower indicates how much damage a unit can inflict in a round of
combat. A successful round reduces the opponent's total hit points by the
value of the unit's firepower.




----------------------------------------------------------------------------
----


Adjustment Factors


Many factors affect the four basic Unit Combat Factors, depending upon the
circumstance of the battle. All factors that apply as percentages are
multiplied together.

3.1 Veteran units receive a +50% bonus for both attack and defense strengths

3.2a Fortified land units receive a +50% bonus for defense strength. This
bonus is superceded by fortress improvement (3.2b) and city walls (3.4). It
can be used in combination with a SAM battery (3.5) or a coastal fortress
(3.6).

Notes:
This bonus applies only on the next turn, after the unit appears with the
dirt entrenchment, not while in the process of fortifying.
It has been suggested, but not tested, that city defenders in multiplayer
games do gain the bonus immediately if given the order to fortify with the
'f' key, but not the menu. (MdS suspects this is false in single player.)
Air units caught fortified in an air base do not enjoy this bonus. Fighters
in unwalled cities may, however, gain the scrambling defense bonus, as if
being attacked by a bomber - even if the attacker is a land or sea unit.
(This point is still in contention, see posts 15 thru 17 and post 19,
below.)

3.2b The fortified bonus increases to +100% for a land unit occupying a
fortress improvement, whether given the order to fortify or not.

3.3 Terrain increases defense strength of all units by:

x150% if on forest, jungle, or swamp
x200% if on hills
x300% if on mountains
+50% if on a river, additively enhancing any other terrain bonus. For
example, a rivered hill gives a x250% bonus, a (200 + 50)% multiplier.

3.4 City walls triple the defense value of city defenders against attacks by
land units only. This bonus can apply only to land units.

3.5 SAM batteries double the defense value of city defenders against attacks
by air units. This bonus applies to any unit defending a city except a
scrambling fighter, which receives a separate defense bonus.

3.6 Coastal fortresses double the defense value of city defenders against
attacks by naval units. This bonus applies to any unit defending a city.

3.7 Some flags (in rules.txt) can alter combat calculations as follows:

Negates city walls (howitzer): Self explanatory.
x2 on defense versus horse (pikemen):: This is actually a limited bonus,
+50% if the attacker is a land unit with move=2, hp=1, and fp=1.
Can attack air units (fighter):: Self explanatory. A fighter stationed in a
city that is attacked by a bomber or helicopter scrambles, gaining a +300%
defense bonus. A fighter gains a +100% defense bonus when attacked by
another fighter. However, a fighter cannot benefit from a SAM adjustment.
Any helicopter attacked by a fighter suffers a -50% defense adjustment and
has its firepower reduced to 1.
x2 on defense versus air (AEGIS):: An AEGIS cruiser gains a +200% bonus when
attacked by an air unit, +400% if the attacker is a missile (destroyed after
attacking).

3.8 Partisans gain an attack advantage against non-combat units (any with
attack value = 0). Their attack value is increased eightfold (8x).

3.9 Shore bombardment: When a naval unit attacks a land unit, both units
have their firepower reduced to 1. A sea unit's firepower is also reduced to
1 when it is caught in port (or on a land square) by a land or air unit; The
attacking unit's firepower is doubled in this case.

3.10 SDI defenses thwart any nuclear attack (except those set by spies)
within 3 squares of the city in which it is built.

3.11 Nuclear missiles have a special attack value of 99. Unless thwarted by
an SDI, this sidesteps any combat result calculations. If a missile attacks
a target, a strike results. This kills all units within one square of the
strike, causes pollution, and reduces the population of any city within the
radius by half.

3.12 Barbarians do not always attack and defend at normal unit strengths.
Barbarian archers defend with a base value of 1, not the normal archer
defensive value of 2. Other barbarian units have normal defense values. All
barbarian attack factors are affected by the difficulty level of game being
played:

Chieftan - 25% of normal
Warlord - 50%
Prince - 75%
King - 100%
Emperor - 125%
Deity - 150%

3.13 Sneak attack! A sneak attack gives an advantage to the attacker. The
value of this bonus is currently unresolved (see the thread Does it pay to
be sneaky?).




----------------------------------------------------------------------------
----


The Combat Formula


First, some background. The manual provides a simplified combat formula to
approximate the likely outcome of a combat. This formula states that the
total modified attack and defense factors are combined; The probability of
victory is approximately the ratio of the unit's factor to the total. In
other words,

U / (a + d)

where
U = the unit's modified factor,
a = the attacker's modified attack factor, and
d = the defender's modified defense factor.

This approximation has proven insufficient for many Apolytoners. Much debate
has resulted in a more detailed formula. First, an explanation of what it
entails. For explanatory purposes, a combat is a single round, a battle the
cumulative result of all combats.

The attacker and defender each own a portion of the total modified attack
and defense values proportional to their value, as the simplified formula,
above, expresses. For each combat, a winner is determined by this ratio. In
simple terms, the higher modified value is more likely to win a combat. For
each combat won, the opponent reduces its hit points by the winner's
firepower. This continues until one unit is reduced to zero hit points and
is thus destroyed.

Heated discussion of a simplified combat formula led to several ideas being
put forth. The one that most closely gives the results of the complex
formula is:

Odds = (S + (S - W)) * Shp * Sfp / (W * Whp * Wfp)

where:
S = Stronger unit's modified attack or defense value
W = Weaker unit's modified attack or defense value
Shp = Stronger unit's hit points
Sfp = Stronger unit's firepower
Whp = Weaker unit's hit points
Wfp = Weaker unit's firepower.

No playtesting results to test the accuracy of this formula have surfaced.

On to the real calculation...
Each unit gets a randomly generated number from 0 to its modified value
minus one, multiplied by a constant. This constant has been best-guessed
(based on play testing) to be 8. The unit with the higher random number wins
the combat, ties going to the defender.

If the defense value is equal to or greater than the attack value, the
probability (p) of the attacker winning the combat round is

p = (A - 1) / 2D

If the attack value is greater than the defense value,

p = 1 - ((D + 1) / 2A)

Where A = (a * 8) and D = (d * 8). The resulting p is the odds of the
attacker winning the combat. To calculate the odds of the attacker winning
the battle, p is plugged into the equation

P = SUMn(COMB(n-1,dh-1) * (p^dh) * (1-p)^(n-dh))

Where "n" is summed from dh to dh+ah-1.

ah = Attacker's modified hit points
dh = Defender's modified hit points
p = probability for attacker to win combat round
P = probability for attacker to win battle

Note: Modified hit points: An opponent's total hit points are divided by the
unit's firepower. Thus an attacker with 2fp halves the defender's total hit
points.

Comments:
This formula accounts for damaged units, as the input is the unit's current
hit point total.

In layman's terms, P is the sum of the probabilities of the all possible
outcomes of the attacker winning; For example, the odds of the attacker
winning ten straight combats, plus that of winning ten out of eleven, plus
that of winning ten out of twelve, and so on, added together to produce a
grand total. The maximum number of rounds is the attacker's and defender's
total hit points minus one. Basically, until the winner is left with a
single hit point after destroying the loser. The defender's chance is (1 -
winner's probability).

For those unable to decipher the above mathematics,
An advantage in hit points is slightly more beneficial that an advantage in
firepower, other factors being equal. An increase in HP produces a greater
range of values of n to be summed. Because FP is in the denominator of the
fraction, its effect is less; Greater HP is all accounted for in the range,
half of a greater FP is. The greater range of values means more COMBinations
are calculated. COMB values increase at a greater rate than the final
exponent ^(n-dh) reduces the total value in our equation.
The more total hit points involved in the battle, the more likely the unit
with the greater modified value, the stronger unit, in other words, will
win.
With an even attack to defense ratio, the higher the values, the better the
odds for the attacker.


An Example
Units with 0 defense can occasionally win because it generates a number
between 0 and 0 (0, thus), and the attacker can also end up with a 0. The
tie goes to the defender, meaning he wins that combat round. A damaged unit,
or one attacking at partial strength (after using part of its movement
allowance), can on rare occasions end up on the short end of this
possibility.

Artillery (10a, 1d, 20hp, 2fp) vs. Rifleman (5a, 4d, 20hp, 1fp): The formula
predicts 82.5% victories, Marko Polo tests resulted in 79%.

Armor (10a, 5d, 30hp, 1fp) vs. Rifleman (5a, 4d, 20hp, 1fp): The formula
predicts 45.8% victories, Marko Polo tests resulted in 44%.

Other tests of Cavalry vs. Armor, Fanatics vs. Musketeer, Fanatics vs.
Alpine Troops, Warrior vs. Warrior, Catapult vs. Musketeer, and others all
matched the formula closely.




----------------------------------------------------------------------------
----


Additional Considerations


5.1 A city's population is not reduced if the city has city walls and a
defender loses a combat.

5.2 A sacked city will have its population reduced by one. A size one city
will usually be destroyed if sacked. There is unresolved discussion about
when size one cities are captured instead of destroyed. See the thread City
Razing Problem for more.

5.3 Naval bombardment ignores city walls.

5.4 Units that 'Can make amphibious assaults' (Marines) can attack from the
sea (a ship), but do not ignore city walls. This does not count as shore
bombardment.




----------------------------------------------------------------------------
----


Healing


After the battle, the victor is usually damaged. Units can heal as long as
they do not move, not even along railroad. They heal at varying rates,
depending on their proximity to a friendly city or barracks. Settlers and
Engineers, the only units incapable of fortifying, heal while working.

6.1 Land Units:

100% of total hit points healed every turn in a city with barracks.
40% of total hit points healed every turn in a non-barrack city
30% of total hit points healed every turn near a city with barracks (i.e. a
square 7x7 squares)
20% of total hit points healed every turn near a non-barrack city
10% of total hit points healed every turn on normal square
Fortress (3.2b) always adds an extra 10% to the rate (i.e. on a normal
square, near a city, or near a city with barracks).

6.2 Naval/Aerial Units:

20%/20% of total hit points healed every turn in a fortress or a city
10%/0% of total hit points healed every turn on normal square
100%/100% of total hit points healed every turn in a city with port
facility/airport, respectively.
Airbase and barracks have no effect.
port facility/airport affects only the city square.

6.3 Healing away from a city or fortress (by skipping that unit's turn)
occurs immediately, before the next unit is available for an order. Barracks
healing occurs at the end of the player's turn.




----------------------------------------------------------------------------
----


Hints and Tips


As a general rule, the unit with the higher modified attack or defense
strength will likely win the combat.

Against 1hp defenders:

Even strengths or a defensive advantage strongly favor the defender.
Even a slight attack advantage means a much greater possibility of winning
the battle.

Against 2hp and 3hp defenders:
Even strengths slightly favor the defender.
Defensive advantages again heavily favor the defender.
Attack strength advantage strongly favors the attacker.
A 2hp attacker needs at least a fourth again as much strength as the 3hp
defender to have even slightly favorable odds.
A 1hp attacker needs better than half again as much strength as the 2hp
defender, and more than double the 3hp defender to gain slightly favorable
odds.

Defenders in a city have the advantage of maximum defense and healing. Also,
only a diplomat or spy can see what units reside in an enemy city.

Stacked defenders are immune to bribery unless adjacent to a city that is
bribed.




----------------------------------------------------------------------------
----


False Statements


Much discussion has surrounded figuring out how combat works. In the
process, some misinformation has been spread. This section addresses these
incorrect ideas.

The following statements about CivII combat are all FALSE. Where applicable,
a reference number before the statement directs you to the section where the
correct information can be found:



The attack strength of the defender is figured into combat resolution.
The defense strength of the attacker is figured into combat resolution.
The terrain on which the attacking unit begins is figured into combat
resolution.
(1.4) Damaged units have movement points proportional to their damage.
(3.2a) The defensive bonus of fortifying a unit enhances the city wall or
fortress bonus.
(3.2a) The defensive bonus of fortifying is immediate.
(3.2b) A unit must be fortified in a fortress to gain the defensive bonus.
(3.3) The defensive bonus of rivered terrain is multiplied along with other
adjustment factors.
(3.4) City walls increase the defense strength of any unit.
(3.5) A SAM Battery and an SDI combine for a greater defensive bonus against
missiles.
(3.7) The pikeman bonus works against all land units with more than one
movement point.
(3.9) A ship caught in port has its defense strength reduced to 1.
The combat formula in the manual is correct.
(5.4) Marines attacking from a ship ignore city walls.
Defenders attacked by marines on a ship gain the coastal fortress bonus.
(6.2d) Air units gain a healing bonus in an air base.




----- End forwarded message -----


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] [thomas@xxxxxxxxxxxxxx: All the facts of the Civ2 combat system], Raimar Falke <=