public Vector GetPossibleStartPlace(IsGroundedChecker groundedChecker, Func <Vector, bool> isForbidden, Vector botCoordinate) { return(figure.OrderByDescending(f => (f - botCoordinate).Mlen) .Where(f => f != botCoordinate) .Where(f => groundedChecker.CanPlace(f)) .FirstOrDefault(f => f.GetAdjacents() .Any(adj => !figure.Contains(adj) && matrix.Contains(adj) && !isForbidden(botCoordinate)))); }
private bool BreakesGrounding(State state) { if (state.Fill) { return(!curGroundChecker.CanPlace(state.Region.AllPoints().ToList())); } else { return(!curGroundChecker.CanRemove(state.Region.AllPoints().ToHashSet())); } }
public Vector SetWorkerAndGetInput(IsGroundedChecker groundedChecker, Func <Vector, bool> isForbidden, Vector botCoordinate, int botId) { if (start != null) { throw new Exception("too many workers"); } BotId = botId; return(start = figure.OrderBy(f => (f - botCoordinate).Mlen) .Where(f => f != botCoordinate) .Where(f => groundedChecker.CanPlace(f)) .FirstOrDefault(f => f.GetAdjacents() .Any(adj => !figure.Contains(adj) && matrix.Contains(adj) && !isForbidden(botCoordinate)))); }