-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels