public CPos ChooseClosestMatchingEdgeCell(CPos cell, Func<CPos, bool> match) { return AllEdgeCells.OrderBy(c => (cell - c).Length).FirstOrDefault(c => match(c)); }