-
Notifications
You must be signed in to change notification settings - Fork 1k
Let the AI count converge before it decides whether to cast #11486
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
Draft
liamiak
wants to merge
13
commits into
Card-Forge:master
Choose a base branch
from
liamiak:ai-converge-prediction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
78cf177
AI: announce X on a converge card so it buys the colours
liamiak1 5c11ade
AI: predict converge when deciding whether to cast
liamiak1 0dfd8e8
AI: tutoring from your own library should take the best card
liamiak1 01aac00
Test for the AI changes above
liamiak1 3571151
AI: predict the colours rather than fabricating the payment
liamiak1 8353ed2
AI: reuse the converge colours the X search already found
liamiak1 52d2e12
AI: offer the converge prediction through PlayerController instead
liamiak1 6c929fd
Drop getConvergeCount now that the prediction answers for it
liamiak1 324d467
Cover the draw path the override used to handle
liamiak1 edbcd46
Cover the token path the converge loop never reached
liamiak1 ee59488
Search the converge X once per decision, not once per caller
liamiak1 d736d02
AI: work out the converge payment on first read, not up front
liamiak1 c870505
AI: announce X for a converge token count that reads it through anoth…
liamiak1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't mind a more generic solution but then you need to replace the specific variant above
otherwise we end up with duplicated logic that also wastes runtime
though the ones with X will probably make things tricky 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and that's done as of the push after your review —
getConvergeCountis now justColorSet.fromMask(getConvergeColors(sa, ai)).countColors(), so there's one payment simulation rather than two. Same result either way:getSunburst()was alreadyColorSet.fromMask(sunburstMap).countColors()andgetColorsPaid()returns that same mask.The X ones are in that push too — X gets announced before the colours are measured, since on those cards X is what buys them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well the code duplication is gone but the method is still used and calculates again for no reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, and it goes further than that — the method can go entirely.
All four callers had the same shape: work out the amount with
calculateAmount, then override it forCount$Converge. That override exists becausecalculateAmountreturned zero before anything had been paid, which is the problem this branch set out to fix. With the prediction in place the engine's own expression gives the right number, so the override was running a full payment simulation to reach a value the line above it already held.I checked rather than assumed, since it would be easy to see the right number coming from resolution instead of evaluation. Instrumenting the
Count$Convergebranch inAbilityUtilsand tagging each call with its caller: 21 of them arrive viaChangeZoneAi.hiddenOriginCanPlayAI— the AI deciding whether to cast — withcastSAset and the count correct.PermanentAi's converge loop was already replaced bysetXForBestConvergeearlier on this branch, so removing these four leavesgetConvergeCountwith no callers and it goes too. That commit is +1/-20.Verified on the paths I could reach.
Painful Truthson theDrawAipath andUnified FrontonTokenAiboth get cast and sized correctly with the override gone — three cards and three life, four tokens. I added the first as a regression test.DamageAllAiI could not exercise: itscheckApiLogicis never reached for Radiant Flames, the onlyDamageAllconverge card in the pool. It is the same one-line pattern as the other two so I would not expect it to differ, but it is untested here rather than verified.339 tests, 0 failures.