The ship combat starts when the attacker ship tries to move into the space taken by the defender ship. The combat is played in rounds. Each round the attacker ship shoots and deals damage to the defender, then the defender ship - even when destroyed completely (DL 1.2 and all later versions) - shoots and deals damage to the attacker. Below is my best understanding of how the combat is calculated, it has not been confirmed by StarDock yet.

The attacker shoots each of its weapons' type in turn (beam weapon, missile and mass driver weapons) on the opponent's ship. Each weapon type has a maximum attack value Amax (or simply attack value) associated with it (which can be checked in the ship info window), that represents the sum of all attack values of all weapons of that particular type. The shooting is performed by rolling a random number A between 0 and Amax.

Then, for each shot, a maximum defense value Dmax is calculated. For each weapon type there is optimum defense. For laser the optimum defense is shield, for missile it is point defense and for mass driver it is armor. All defense values are added together, but for non-optimal defense the square root is taken first and the value is rounded down (minimum of 1) before it is added to the other defenses. For example, if the attacker shoots with the laser and the defender has 1 in shields and 2 in armor then the maximum defense value is ${\displaystyle D_{\textrm{max}} = 1 + \lfloor \sqrt{2} \rfloor = 1 + 1 = 2}$.

After that the defense roll D is calculated by rolling a number between 0 and Dmax. The damage is calculated as the difference between the attack roll A and the defense roll D. If the damage value is zero or negative, then the damage is deflected. If the damage value is positive, it is subtracted from the hit points of the defender ship.

This procedure repeats for other two weapon types (if any). The firing stops, if hit points of the target ship become equal or less than zero. In that case the target ship is marked as destroyed. When attacker ends, the attacker and defender change roles, and the defender ship starts firing its weapons. At the end of the combat round the destroyed ships are removed, and the next round starts.

How the combat is performed if at least one side is a fleet, see fleet combat.

Note
• It appears that the manual's description placing the minimum attack and defense rolls as 1 is incorrect. According to Lead Developer Cari Begle, all rolls have a minimum of 0, and deflections (0-damage hits) are possible, but apparently not shown in the battle viewer.
• Regardless of its firepower one ship can destroy only one opponent's ship per combat round. This makes using hordes of small expendable ships still useful for fighting large ships.
• Rule-of-the-thumb amount of defenses: 1.5 the attack of the most common opponent's warship. Use fleets of those ships.
• When firepower of ships increases significantly over their hitpoints (usually late game), defenses lose somewhat on their efficiency. A bad defense roll in early game causes a loss of some hitpoits. A bad defense roll in late game causes a loss of a whole ship.
• The attack and defense values can be modified by the presence of military starbases.
The Math

Based on the assumptions that attack follows from a uniform discrete distribution from 0 to attack value and defense follows from a uniform discrete distribution from 0 to defense value, the following can be ascertained:

(Note: It appears like, despite what the Lead Developer Cari Begle claims, the actual functionality is like written in the book; the attacker can't roll less than 1. See the Discussion page for discussion and versions of these equations for that case. Feel free to move into the main page if others agree.)

For the function f mapping attack a and defense d to mean damage per round, there are 2 distinct cases, mainly arising from the fact that attack and defense are not symmetric with one another:

${\displaystyle f(a,d) = \begin{cases} \frac{a(a+2)}{6(d+1)} & \text{if } a \leq d \\ \frac{a-d}{2} + \frac{d(d+2)}{6(a+1)} & \text{if } a > d \end{cases}}$
${\displaystyle f(a+1,d) - f(a,d) = \begin{cases} \frac{2a+3}{6(d+1)} & \text{if } a < d \\ \frac{1}{2} - \frac{d(d+2)}{6(a+1)(a+2)} & \text{if } a \geq d \end{cases}}$

Interpreted, this means that if attack and defense both increases lockstep on a 1 to 1 basis, mean damage per round still increases by about ${\displaystyle \frac{1}{6}}$ per point. 59 attack versus 59 defense will cause about 1 more mean damage per round than 53 attack versus 53 defense. When defense is greater than attack, defense in the denominator is a linear function running against a quadratic attack function on the numerator. When attack grows larger in comparison to defense the formula slowly morphs from ${\displaystyle \frac{2y-x}{6}}$ to ${\displaystyle \frac{y-x}{2}}$. Early defense looks good because of the huge constant (6, compared to 2 with no defense) attached to it, but the effect diminishes once your defense reaches parity with the enemy offense. (To understand defense in more detail, you should look at the reciprocal or logarithm of expected damage dealt.)

If you want an even more watered down interpretation, here it goes: The first few points of attack are very weak against high defenses, but subsequent points provide increasing returns, reaching roughly ${\displaystyle \frac{1}{3}}$ point of damage per round with attack equal to defense, and converging to ${\displaystyle \frac{1}{2}}$ point of damage per round when attack vastly exceeds defense. Each point of defense takes away roughly ${\displaystyle \frac{1}{3}}$ point of damage per round until defense matches attack, then it tapers off.

## Dark Avatar combat changes

The best info on this you can find on GalCiv forums: DA (Beta) Combat System.

• each weapon now attacks separately, rolling from Luck ability (0%, 25% or 50% of max weapon's power) to max weapon's power;
• in each round of combat all ships in a fleet attack single target;
• when that target is destroyed, the remaining unfired weapons fire at another ship;
• attack bonuses from weapons are handled as a supershot. They are all added to the first shot from the first weapon on a ship. This is the reason of "unexplainably" high damage a well-defended ship sometimes gets in combat;
• defenses on attacked ship are summed up for each defense type. For off-type defense this sum is square-rooted. For each attack the defense with the highest value is chosen and rolls from 0 to its value + defense bonus rounded down. If it rolls higher or equal than the attack value, its value is decreased by the value of the attack (it is depleted). If it rolls less than the attack value, it is depleted for its roll, the difference is subtracted from ship's hitpoints. The next weapon fires on depleted defenses. This procedure repeats until all weapons are fired;
• off-type defenses first deplete, then get sqrt decrease for damage calculation;
Corollary: Low-attack weapons (firepower 1 and 2) don't work well against comparable amount of WRONG defenses, eg. ship with 3 plasma weapons (FP 3 * 2) attacking a ship with 6 armors will do less damage than expected, because attacking ship will roll 3 times from 0 to 2 (1 on average), and armors will also roll from 0 to sqrt(max_value=6)=2 for each firing weapon. If defenses are hit for 1 point with first weapon, their max value is decreased by 1, and they roll from 0 to sqrt(5) or still 0-2 for the second weapon. Rule-of-the-thumb: each single weapon on your ship should have either more FP than the ship you attack has sqrt(defenses), or you put low-attack ships in a fleet to get significantly more attack than defending ship has defenses.
• all defenses fully replenish between combat rounds (each round starts with full defenses);
• in each combat round ALL (also destroyed) ships fire (no more first strike);
• only Arceans (Super Warrior) have first strike (destroyed ships don't fire back) in the first combat round, if they are the attacker. In later rounds all ships fire;
• tie rule #1: if in last round of combat surviving ship(s) destroy each other, the strongest ship still survives (the strongest seems to be the ship with highest attack).
• tie rule #2: if in 50 combat rounds (300 for fleets) the battle is not resolved, the game determines which side is 'tougher' by the formula sqrt( ( 2 * Attack ) + Defense + ( Current HP / 2 ) ). The side with the highest number automatically destroys all opposition.

The end result is:

• While you can match your defenses on a single ship with about 75% firepower of the AIs fleet, is that ship nearly indestructible. That's usually until the late game.
• Game experience: ships from races with Luck do more damage than they should.
• When the firepower of the fleet becomes too great for the defenses, the rule of the day becomes all-attack single suicidal ship (firepower several hundred points), that destroys many of the opponent's ships in the first round of the combat, and by the "tie rule" maybe even survives.
• In middle and late game, using fleets become counterproductive. Because AI's destroyed ships fire back and destroy your ships, and your destroyed ships never fire back.
• Game experience: AIs don't cope well with those changes. Probably because they can't read this ;-)