US Coast Guard Navigation Rules

# https://www.navcen.uscg.gov/pdf/navrules/navrules.pdf
# https://www.navcen.uscg.gov/?pageName=navRulesFAQ#0.3_13

def which_vessel_is_stand_on
  if (one vessel is being overtaken)
    return (vessel being overtaken)   # Rule 13(a)
  if (one vessel is not under command)
    return (vessel not under command) # Rule 18
  if (one vessel has restricted maneuverability)
    return (restricted vessel)        # Rule 18
  if (one vessel is engaged in fishing)
    return (fishing vessel)           # Rule 18
  if (one vessel is being rowed)
    exception (undefined)             # FAQ 13
  if (vessel under sail meets vessel under power)
    return (vessel under sail)        # Rule 18
  if (vessel under power meets vessel under power)
    if (meeting head-on)              # Rule 14(a)
      exception (pass port to port)
    else                              # Rule 15
      return (vessel on starboard side of the other)
  if (vessel under sail meets vessel under sail)
    if (wind on different sides)      # Rule 12(a)(i)
      return (vessel with wind from starboard)
    else                              # Rule 12(a)(ii)
      return (vessel to leeward)