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

Interaction of blocking requirements and restrictions prevents game from proceeding #11661

Open
xenohedron opened this issue Jan 16, 2024 · 6 comments
Labels
bug Bugs and errors Developers Discussion Discussion about redesign or changes refactoring Developers topics about code and programming

Comments

@xenohedron
Copy link
Contributor

One example from an XDHS game today: [[Grand Melee]] and [[Loyal Pegasus]]

image

This is a deep bug in the combat engine. It's a major problem because it's not just incorrect rules enforcement, but prevents the game from continuing. Does anyone have ideas on how to go about fixing it? Failing that, any ideas on workarounds to alleviate it?

Related issues (presumably same root cause but variations on the general theme):

@xenohedron xenohedron added bug Bugs and errors refactoring Developers topics about code and programming Developers Discussion Discussion about redesign or changes labels Jan 16, 2024
Copy link

Grand Melee - (Gatherer) (Scryfall) (EDHREC)

{3}{R}
Enchantment
All creatures attack each combat if able.
All creatures block each combat if able.

Loyal Pegasus - (Gatherer) (Scryfall) (EDHREC)

{W}
Creature — Pegasus
2/1
Flying
Loyal Pegasus can't attack or block alone.

@ssk97
Copy link
Contributor

ssk97 commented Jan 18, 2024

The main issue is that solving this correctly is computationally infeasible. Right now we're trying to do it in a single pass, which means that sometimes the rules system assumes you can do something impossible and then doesn't let you continue the game.

I've looked into this some a few months ago, but it was getting messy enough that I would definitely want to rewrite the whole thing before doing a PR of it and I decided to focus on easier issues instead. My idea was that rather than doing a single pass, we have a few different "blocking strategy" engines which create possible blocks that follow the requirements but not necessarily all restrictions. We then see which of those satisfies the most restrictions, and then only allow blocks if the number of restrictions satisfied is at least as many as the best of those strategies.

This would always allow play to proceed, the failure case would be allowing some illegal blocks when none of the engines are able to find any of the legal blocks. If the engines are reasonably comprehensive, this would only happen in extremely rare cases.

@JayDi85
Copy link
Member

JayDi85 commented Feb 3, 2025

Human related blocking problems must be fixed by #13182. Some AI related blocking problems must be fixed by 92b7ed8 (e.g. menace problem).

@ssk97
Copy link
Contributor

ssk97 commented Feb 4, 2025

Human related blocking problems must be fixed by #13182.

That fixed the most common cause of the problem ("can't be blocked except by X or more"+must block) but there are a wide range of more complex situations that could cause the same basic issue.

@JayDi85
Copy link
Member

JayDi85 commented Feb 4, 2025

If you find bad use cases then report it here (if human players can't continue game due bad blocking restrictions).

@Grath
Copy link
Contributor

Grath commented Feb 4, 2025

Another bad use case we ran into in my Commander games: There were only flying attackers and a blocker that must block but didn't have reach or flying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs and errors Developers Discussion Discussion about redesign or changes refactoring Developers topics about code and programming
Projects
None yet
Development

No branches or pull requests

4 participants