Card-Forge / forge

An unofficial rules engine for the world's greatest card game.
https://card-forge.github.io/forge/
GNU General Public License v3.0
935 stars 546 forks source link

AI ignores "for each". #4242

Open stormcat664 opened 9 months ago

stormcat664 commented 9 months ago

Describe the bug When the AI plays a card with text like "for each opponent" it may target a single player's object multiple times. ex. Grasp of Fate

To Reproduce Steps to reproduce the behavior:

  1. Play against AI with multiplayer game.

Expected behavior Select one object per opponent.

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

MeinName216 commented 9 months ago

I'd like to second this issue. As you can see in my screenshot, I've just had it happen for me with Grasp of Fate, too, but I have experienced the same issue with the effect of Bronzebeak Foragers as well.

Seems like the targeting restrinction Target OneEach doesn't work correctly.

Screenshot_2023-12-20_121039

EDIT: Looking into Target OneEach it makes total sense that the AI wouldn't know to restrict itself to only target one thing for each player, because OneEach is just a variable defined as the total amount of players. No restriction there at all.

github-actions[bot] commented 8 months ago

This issue has not been updated in a while and has now been marked as stale. Stale messages will be auto closed.

MeinName216 commented 8 months ago

I'd like to bump this issue again with the additional information that it works fine when a player uses these cards.

github-actions[bot] commented 6 months ago

This issue has not been updated in a while and has now been marked as stale. Stale messages will be auto closed.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 5 days with no activity.

blerg-rush commented 4 months ago

I've been digging through the AI code to understand where this problem is, because I've bumped into this bug a lot playing 3-player commander goldfish against AI players.

I'm still learning where this sort of logic should go to keep the AI targeting logic orderly and easy to understand as possible, but it looks like we might be concerned with DestroyAI and a missing SpellAbility.canTarget() check. There's some similar-ish logic in forge.ai.simulation, but from what I gather that's specifically for automating games entirely through CLI?

I'll have to set up a Java IDE to play around with it and that takes more spoons than I've got this evening, but I thought I'd throw that out there in case it inspires someone to confirm my assumption before I get to it.