Preconditions: If two minefields overlap, i.e. Radius_1 + Radius_2 > Sqrt((X_1-X_2)^2 + (Y_1-Y_2)^2), they interact unless any of the following holds:

  • minefields are of different type (web vs. normal) and AllowMinesDestroyWebs is disabled (default)
  • minefields are owned by same player
  • minefield owners are allies, and have a mutual mine-level alliance

In the 1:1 case, i.e. two hostile minefields overlapping, the following formula is used:

Mines_exploding =
   Min(Units_1, Units_2)
                     ...if Dist = 0
   Units_1           ...if A < 0
   Units_2           ...if A > D
   Units_1 - A^2     ...otherwise
   ...with
      D = Distance between minefield centers
      A = (Units_1 - Units_2 + D^2) / (2*D)
      Units_1, Units_2 =
          Number of mine units contained in both fields

This formula is used with AlternativeMinesDestroyMines enabled when a minefield is laid or enlarged to overlap an old one. In this case, PHost iterates through all other minefields in Id order, checks whether there is a hostile overlap, and applies the above formula.

During the Mines destroy Mines stage of host processing, PHost uses more complicated formulas. The basic ideas are the following: a minefield that overlaps N hostile minefields shrinks at a speed of N minefield units per time unit. For each minefield pair, we can therefore compute the time until the overlap is gone. PHost now computes the minimum such time, and removes N * Time units from all minefields. At least one overlap is gone now. All the speeds are now recomputed, and the algorithm restarts if overlaps remain.

Time_until_overlap_gone =
   Min(U1 / S1, U2 / S2)
                     ...if D=0
                        (i.e. concentric minefields)
   U1 / S1           ...if U2*S1 - U1*S2 ≥ D^2 * S1
                        (i.e. field 2 eliminates field 1 completely)
   U2 / S2           ...if U1*S2 - U2*S1 ≥ D^2 * S2
                        (i.e. field 1 eliminates field 2 completely)
   (U1 - A^2) / S1   ...if S1 = S2
   ((U1-U2-D^2)*S1 - (U1-U2+D^2)*S2 + 2*Sqrt(D^2 * (U2*S1^2 - (U1+U2-D^2)*S1*S2 + U1*S2^2)))
     / (S1 - S2)^2   ...otherwise
   ...with
      D = Distance between minefield centers
      A = (U1 - U2 + D^2) / (2*D)
      U1,U2 = Mine units in both fields (Units_1, Units_2)
      S1,S2 = Shrink speeds, i.e. overlap counts for both fields

The frightening last formula is the solution to Sqrt(U1 - S1*x) + Sqrt(U2 - S2*x) = D obtained using Mathematica.

PHost's actual implementation is heavily optimized for speed. It does not consider all minefields at once; instead it groups them into possibly interacting partitions first (i.e. start by picking an arbitrary minefield, and add all that may interact with it considering owner, type and location, add all that may interact with the fields just added, and so on). In addition, to guarantee reasonable progress, it always advances time by a minimum amount Epsilon, which can make a minefield lose a handful more units than required to remove all overlaps. Epsilon currently is 1.0 divided by the maximum overlap occuring in the current partition, but at least 1/16, empirically chosen by testing as a compromise between precision and speed.

To predict mines-destroy-mines at client-side, it probably suffices to use an Epsilon of 1/16 all the time.

After computing all losses, PHost attempts to sort them in a way that they can be reasonably incorporated into the game data, and reported to players. The above formulas may yield results such as "minefield pair #17/#233 loses 0.12 units", but since the unit count must be an integer, PHost has to round again. Let Loss(A,B) be the loss of minefield pair A/B as computed according to the above algorithm. The amount ultimately reported using util.dat record 29 and the message will be

Rounded_loss(A,B) =
   Min(Ceil(Loss(A,B)), Units_A, Units_B)

(4.1a) In case this formula causes a minefield to lose less mines than needed to resolve all overlaps, PHost will finally remove the excess using util.dat record 53. This generally happens only when many overlaps exist with a single field.