Add bounded mana payment planner for costed mana abilities#11198
Add bounded mana payment planner for costed mana abilities#11198Madwand99 wants to merge 11 commits into
Conversation
# Conflicts: # forge-ai/src/main/java/forge/ai/ComputerUtilMana.java
# Conflicts: # forge-ai/src/main/java/forge/ai/ComputerUtilMana.java
|
Thanks though there's now also a "human contributed" attempt in progress: #11173 If that leads nowhere either I'll check out this new approach, though I probably won't be a big fan if this separate system duplicates things too much - but we'll see |
I notice that many of the tests on #11173 don't pass their code, and one of them is an invalid test. I'll be checking those tests to add some to my own test suite. So far I have 55 tests, with more on the way. Should I push these to this PR? Due to your own comments I have been keeping most tests to myself. |
Comparison with PR #11173SizeProduction changes are measured against each branch's merge base.
This PR is substantially smaller: its latest branch now adds 4,351 net production lines, including 4,360 additions in PR #11173 also includes +2,026 / -1 committed test lines. Our tests remain local for now but can be made available on request. Test ResultsThe current local suite has 137 behavioral payment tests plus 11 planner-internal fallback/state-cap tests.
The 11 fallback/state-cap tests cannot compile against PR #11173 because it does not contain the Shared StrengthsBoth implementations pass tests covering:
DifferencesPR #11173 fails 12 of the original behavioral tests. These include:
Notably, PR #11173 still avoids a redundant second Signet, but cannot chain two Signets when that is the only valid payment. This PR passes both cases. The remaining four PR #11173 failures are intentional source-policy differences in the imported comparison tests:
Those expectations were revised locally; they should not be treated as neutral regressions in PR #11173. ArchitectureThis PR uses a bounded best-first search with virtual mana state, memoization, source equivalence, a hard state cap, and legacy fallback. It searches without mutating game state and returns a replayable payment plan. PR #11173 adds nested and recursive payment handling around the existing payment logic, with a separate |
|
thanks for comparing tests will in fact be needed however 148 is a completely unreasonable amount 👎 👎 👎 they need to be written around code knowledge so we're not just setting up lots of arbitrary scenarios that just cover the same logic it would have been better to wait and then iterate on each case / deciding if initial support is worth it |
Almost every test covers different logic and different cards. The tests are critical for defining what the code can do. We can certainly cut down on the final tests included, but for now the more tests we have, the more cases are covered. Picking a subset of test to keep will be quite challenging as almost any test left out will mean some kinds of cards aren't going to be covered. |
Adds a bounded best-first mana payment planner for cases the greedy mana payer cannot reliably handle, especially signets, filter lands, and restricted mana abilities.
The planner searches virtual payment states without tapping real permanents, tracks floating mana and used sources, then replays the selected mana abilities once a valid plan is found. ComputerUtilMana keeps the existing greedy path for normal payments and only escalates to the planner when needed, including cases where greedy payment would leave enough total mana but strand important colors for other spells in hand.
This also updates mana color choice handling so planned combo/chosen mana outputs are preserved when the chosen mana abilities are replayed.
Thanks to Codex for help with coding and many, many tests.