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
933 stars 543 forks source link

AI chooses a single target with a higher cmc for two different Pithing Needles #5896

Open MorihiroS opened 1 month ago

MorihiroS commented 1 month ago

Describe the bug AI casts the first Pithing Needle and chooses one target with a larger cmc. Then AI casts the second Pithing Needle and chooses the same target.

To Reproduce Steps to reproduce the behavior:

  1. Player has Spellskite, Agatha's Soul Cauldron and Shalai, Voice of Plenty
  2. I casts its first Pithing Needle and chooses Shalai, Voice of Plenty
  3. I casts its second Pithing Needle and chooses Shalai, Voice of Plenty again

Expected behavior

  1. AI should choose different targets for different Pithing Needle
  2. AI should targets cards with more dangerous abilities at first

Additional context Similar with #4282

Desktop OS: Windows 10 Java Version: 1.8.0_202-b08 Forge Version: 1.6.64-SNAPSHOT-08.04

Screenshots

needle1 needle2

MorihiroS commented 1 month ago

@Hanmac, need AI label, keep label and assign someone, please

Hanmac commented 1 month ago

For stuff like Pithing Needle, and similar, AI needs two Logics (when playing and Choosing Cards)

There is the Part for Choosing the CardName, imo it might need more "Generic" implementation https://github.com/Card-Forge/forge/blob/024bf680407498fd5eff8f7ef930a367769f85dc/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java#L1463-L1465

This Part should check if the affected Card's Activated Abilities can be activated https://github.com/Card-Forge/forge/blob/024bf680407498fd5eff8f7ef930a367769f85dc/forge-ai/src/main/java/forge/ai/SpecialCardAi.java#L298-L301