Skip to content

Single item satisfying multiple trade input requirements #48

@cubefury

Description

@cubefury

This bug is introduced with the addition of oredict support into existing code, but does not affect the pack currently as we do not have trades that fit this condition.

Bug Description:

If a trade requires multiple inputs which can be satisfied with a single item. eg. if a trade wanted 1 oredict:logWood + 1 Oak log. Since the required items are checked separately, having 1 oak log in the input slots would satisfy both these conditions. However, when the trade is actually performed, it would void the oak log and fail the trade.

The current idea to solve this is to copy the available items cache and actually remove from this cache to avoid double counting items. There are two issues with this approach:

  1. I'm not sure how to do this for AE2 as the cache would include items that are view-only but not removable. Copying the item cache for each trade every second also seems quite computationally expensive.
  2. This solution would greedily remove the first available items that satisfies each input requirement, but I get the feeling the generalization of this problem (general function mapping n items to m conditions) is np-complete and cannot be solved in this way. In other words, a trade could have been satisfied if the items were mapped to input conditions differently instead of being greedily mapped.

Alternatively, we can just track what items were taken mid-trade execution, and if the trade fails before completion, we dump the already-consumed items to the output buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions