* Support export/import states with arbitrary players.
Previously, the dump/setup game state dev options were only able to handle a 2-player human vs. AI game. This PR expands the functionality to support any number of players and ignores the type of player (naming them p0,p1,...,pN). The previous names of ai and human are supported for backwards compatibility.
This change improves Simulated AI logic by eliminating many unnecessary simulations, particularly due to:
- Invalid targets involving counterspells countering themselves (including modal spells).
- Pruning identical land drop decisions.
Tests are added to cover these cases.
Some core logic is changed, in particular, SpellAbility.canTarget() was not rejecting self-targeting for counterspells. This was likely being done at a higher level somewhere (e.g. in UI code for choosing targets for the human player or AI-specific code for non-simulated AI).
Additionally, a convenience SpellAbility.hasLegalTargets() method is added, from the logic that was previously in AIController.java, so that it can be re-used by the simulation AI code.
A few small style clean ups are included in the code being changed.
Uses a seeded deterministic random generator when simulating choices, which ensures the same number of sub-choices are always used, which the code requires. Adds a test.
* Improve AI logic for cavern of souls.
Improve AI logic for cavern of souls.
- Don't count token creature types when looking for most prominent creature type, since cavern of souls doesn't help with them.
- Weigh cards in hand and commanders double, as they are more likely to be cast.
I tested with a Tiny Leaders deck running Geist of Saint Traft that didn't have any creature type synergy and confirmed that the changes make the AI choose Spirit for Geist, rather than Human as before.
* Apply this to a few more cards.
* Remove a print statement.
* Address review comments.
This got broken by the following refactor:
79c9c914e2
The result was that simulation AI was ignoring certain decision trees that involved
playing lands, leading to not considering certain lines of play and some log
messages printed to standard error. I've added a test that covers this logic to prevent
it breaking again in the future.
Also, a couple small clean ups to related tests.