Class FormationSide
A formation's centre is the mean position of the force. When a river runs between the two halves of that force, the mean lands in the water - a hex no unit can stand in, measured on a river crossing as 18% of the distinct centre positions in a run. Every unit is then held to a point in the middle of the river, which is the one place the formation cannot be.
The rule here is deliberately narrow: a friend counts toward the formation only if the straight line to it does not cross deep water. Units form up with their own bank, the far bank forms up with itself, and as units cross, the near group shrinks and the far group grows until the force is whole again on the far side. That is how a force actually crosses a river - it assembles on the far bank - rather than trying to hold one shape across an obstacle it can only pass a few units at a time.
Depth matters. Only water deep enough to force a unit to wade separates a formation
(SEPARATING_DEPTH). A shallow ford costs movement but does not break a force in two, and treating
every puddle as a barrier would fragment formations on wet maps for no reason.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisForceSplit(Board board, Coords from, List<Coords> positions) Whether any separating water lies between the mover and the given friends at all.static booleanWhether two positions are on the same side of any water obstacle deep enough to split a formation.static booleanWhether two positions are on the same side of any water of at least the given depth.
-
Method Details
-
sameSide
Whether two positions are on the same side of any water obstacle deep enough to split a formation.- Parameters:
board- the board both positions are onfrom- the mover's positionto- the friend's position- Returns:
truewhen the straight line between them crosses no separating water, and so the two can form up together
-
sameSide
public static boolean sameSide(@Nullable Board board, @Nullable Coords from, @Nullable Coords to, int minimumDepth) Whether two positions are on the same side of any water of at least the given depth.- Parameters:
board- the board both positions are onfrom- the mover's positionto- the other positionminimumDepth- the shallowest water that counts as a divide, in levels- Returns:
truewhen the straight line between them crosses no such water
-
isForceSplit
public static boolean isForceSplit(@Nullable Board board, @Nullable Coords from, List<Coords> positions) Whether any separating water lies between the mover and the given friends at all.Lets a caller skip the per-friend filtering entirely on the overwhelmingly common case of a dry map, where the answer is always the whole force.
- Parameters:
board- the board the force is onfrom- the mover's positionpositions- the friends' positions- Returns:
truewhen at least one friend is cut off from the mover by water
-