Class PartialSearch.PartialShapelessResult

  • All Implemented Interfaces:
    io.github.sakaki_aruka.customcrafter.search.PartialSearch.PartialSearchResult

    
    public final class PartialSearch.PartialShapelessResult
     implements PartialSearch.PartialSearchResult
                        

    Partial-search result for a CRecipe.Type.SHAPELESS recipe.

    Because shapeless recipes have no positional constraint, a recipe slot may be satisfiable by more than one input slot. relations captures these weak (non-exclusive) candidate associations; the true MatchState is determined by computing a maximum bipartite matching over relations in state.

    Since:

    5.0.21

    • Constructor Detail

      • PartialSearch.PartialShapelessResult

        PartialSearch.PartialShapelessResult(CRecipe recipe, Map<CoordinateComponent, Set<CoordinateComponent>> relations)
        Parameters:
        recipe - The shapeless recipe that was evaluated.
        relations - A map from each matchable recipe slot coordinate to the set of input slot coordinates that are individually compatible with that slot.
    • Method Detail

      • state

         PartialSearch.MatchState state()

        Returns the MatchState by computing a maximum bipartite matching over relations.

        Unlike the default implementation, this override accounts for the case where a single input slot appears as a candidate for multiple recipe slots — a naive notEnough().isEmpty() check would produce a false MatchState.ALL in that situation. An augmenting-path algorithm (Kuhn's algorithm) is used to find the true maximum matching size and compare it against CRecipe.items.

        Since:

        5.0.21

      • weakRelations

         final Map<CMatter, Set<CoordinateComponent>> weakRelations()

        Returns the weak candidate associations keyed by CMatter instead of by coordinate.

        Each entry maps a recipe-slot matter to the set of input slot coordinates that are individually compatible with it. The set may be empty when no input matched that matter, mirroring the information in relations with a matter-oriented key.

        Returns:

        A map from each recipe matter to the set of compatible input slot coordinates.

        Since:

        5.0.21