Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong SynchroMaterialSelection #206

Open
TheSwerik opened this issue Nov 10, 2024 · 0 comments
Open

Wrong SynchroMaterialSelection #206

TheSwerik opened this issue Nov 10, 2024 · 0 comments

Comments

@TheSwerik
Copy link
Contributor

TheSwerik commented Nov 10, 2024

I noticed that OnSelectSum has a bug:

If a mandatory card has an effect that allows it to optionally change its level, this effect does not get used in OnSelectSum.
Example Card: Yamatako Orochi

LuckyBot tried to Synchro summon a Level 9 Monster with Yamatoko Orochi and two Level 1 non-tuners on the Field and could not do it, because the code (in general, not only for LuckyBot) never considers Yamatoko Orochi to be Level 8:

for (int k = 0; k < mandatoryCards.Count; ++k)
{
        sumval -= mandatoryCards[k].OpParam1;
}

IList<ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max, _select_hint, mode);

(Yamatoko Orochi has OpParam1 = 1 and OpParam2 = 8)

I cannot quickly think of a good way to check for all combinations of mandatory cards and OpParams.
Something like this but there is probably a non-recursive way:

// ...
IList<ClientCard> selected = SelectSumRecursive(0, sumval);

IList<ClientCard> SelectSumRecursive(int cardIndex, int sumVal)
{
    if (cardIndex >= mandatoryCards.Count) return _ai.OnSelectSum(cards, sumVal, min, max, _select_hint, mode);

    ClientCard card = mandatoryCards[cardIndex];
    for (int opParam = 0; opParam < 2; opParam++)
    {
        int opParamValue = opParam == 0 ? card.OpParam1 : card.OpParam2;
        int tempSumVal = sumVal - opParamValue;

        IList<ClientCard> tempResult = SelectSumRecursive(cardIndex + 1, tempSumVal);
        if (tempResult.Count >= min) return tempResult;
    }

    return new List<ClientCard>();
}
// ...

I opened a PR with this code to better understand what that code is supposed to do: #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant