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

AI stuck trying to block creature with menace #13290

Open
alexander-novo opened this issue Feb 3, 2025 · 11 comments
Open

AI stuck trying to block creature with menace #13290

alexander-novo opened this issue Feb 3, 2025 · 11 comments
Assignees
Labels
AI bug Bugs and errors

Comments

@alexander-novo
Copy link
Contributor

Tried attacking an AI player with [[Obeka, Splitter of Seconds]] and it got stuck trying to block it with only a single creature. Log instantly filled up with messages as soon as attackers were declared:

Image

I suspect this is due to the AI changes around blockers in the recent update.

Copy link

github-actions bot commented Feb 3, 2025

Obeka, Splitter of Seconds - (Gatherer) (Scryfall) (EDHREC)

{1}{U}{B}{R}
Legendary Creature — Ogre Warlock
2/5
Menace
Whenever Obeka, Splitter of Seconds deals combat damage to a player, you get that many additional upkeep steps after this phase.

@JayDi85
Copy link
Member

JayDi85 commented Feb 3, 2025

Related to #13182, added AI reproduceable test in 356d677

@JayDi85 JayDi85 added bug Bugs and errors AI labels Feb 3, 2025
@JayDi85 JayDi85 self-assigned this Feb 3, 2025
JayDi85 added a commit that referenced this issue Feb 3, 2025
* fixed game freezes for no-possible block configurations like Menace (#13290);
* fixed computer cheating to ignore block requirements like Menace (now AI will choose all required blockers instead 1);
* improved computer logic for blockers selection (try to sacrifice a creature instead game loose, simple use cases only);
* added freeze protection for bad or unsupported attacker-block configuration;
* refactor: deleted outdated AI code;
@JayDi85
Copy link
Member

JayDi85 commented Feb 3, 2025

AI's blocker logic reworked in 92b7ed8, it must be more stable and compatible. There are still possible no-valid block configurations from AI but it will be visible by game log warning only (without game freeze).

@JayDi85
Copy link
Member

JayDi85 commented Feb 4, 2025

Looks like blocking problems was one of the main reason of AI game freezes for long time. Now I can run hundreds of random games (ai vs ai) without stuck. ~20 seconds per 1 game.

@JayDi85
Copy link
Member

JayDi85 commented Feb 4, 2025

Some funny staff related to AI:

  • Average AI game finish at ~21 turn on combat damage. But sometime it can ends on main or upkeep steps too.
  • Average battlefield size at the end -- 5 vs 5 creatures, but sometime one AI player can collect 15+ creatures;

Raw data:
Image

JayDi85 added a commit that referenced this issue Feb 6, 2025
* now computer will use simplified 1 vs 1 combat damage simulations to choose better blockers (due better game score after combat);
* it's not a full combat simulation, but support many things like non-stack abilities, damage replacement effects and SBA -- much better than older PT compare (related to #13290);
* now AI correctly use a blockers with deathtouth, indestructible, first/double strike and other abilities;
* chump blocks also supported (chump logic implemented before in 92b7ed8, related to #4485);
@alexander-novo
Copy link
Contributor Author

It looks like there's still an issue with menace handling on the latest beta release.

@JayDi85
Copy link
Member

JayDi85 commented Feb 10, 2025

@alexander-novo need battlefield screenshot or description for bad use cases (impossible block message from AI or wrong blocks declare -- it's different problems)

@alexander-novo
Copy link
Contributor Author

Image

Here's another example. It seems to get hung up much less frequently before, but I am still noticing a problem with menace (in this screenshot [[Professional Face-Breaker]]). No messages in either console, and it always seems to be the last AI in turn rotation that gets stuck, rather than the one blocking the menace creature.

Copy link

Professional Face-Breaker - (Gatherer) (Scryfall) (EDHREC)

{2}{R}
Creature — Human Warrior
2/3
Menace
Whenever one or more creatures you control deal combat damage to a player, create a Treasure token.
Sacrifice a Treasure: Exile the top card of your library. You may play that card this turn.

@alexander-novo
Copy link
Contributor Author

Image

Another example - although this time without a creature with menace.

@JayDi85
Copy link
Member

JayDi85 commented Feb 16, 2025

Maybe related to multiplayer games (multiple opponents). Hmm.

@JayDi85 JayDi85 reopened this Feb 16, 2025
4825764518 pushed a commit to 4825764518/mage that referenced this issue Feb 17, 2025
4825764518 pushed a commit to 4825764518/mage that referenced this issue Feb 17, 2025
* fixed game freezes for no-possible block configurations like Menace (magefree#13290);
* fixed computer cheating to ignore block requirements like Menace (now AI will choose all required blockers instead 1);
* improved computer logic for blockers selection (try to sacrifice a creature instead game loose, simple use cases only);
* added freeze protection for bad or unsupported attacker-block configuration;
* refactor: deleted outdated AI code;
4825764518 pushed a commit to 4825764518/mage that referenced this issue Feb 17, 2025
* now computer will use simplified 1 vs 1 combat damage simulations to choose better blockers (due better game score after combat);
* it's not a full combat simulation, but support many things like non-stack abilities, damage replacement effects and SBA -- much better than older PT compare (related to magefree#13290);
* now AI correctly use a blockers with deathtouth, indestructible, first/double strike and other abilities;
* chump blocks also supported (chump logic implemented before in 92b7ed8, related to magefree#4485);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI bug Bugs and errors
Projects
None yet
Development

No branches or pull requests

2 participants