This keeps the index and list size of the available decisions as part of the plan, to be compared with when following through with the plan. Among other things, this ensures that the correct SA is chosen from the list when there are multiple similar SAs (e.g. correctly crewing the 2nd Smuggler's Copter).
The problem was that during copying of SAs, the spabCache was not updated correctly due to the code being in the wrong order. A further problem was that activatingPlayer was not being correctly set on the new abilities, so you would end up referencing a Player from a different Game object from an SA that was in a spabCache, resulting in many previously-simulated Game objects being leaked through this reference chain.
This change fixes both of those problems and also adds a validation function that checks the contents of the spabCache at every game copy.
Note: There's still a limitation in the simulated AI where it doesn't know what to do when multiple effects from an ability require targets. This can be addressed in the future to support things like Cryptic Command to both counter a spell and bounce a permanent.
Since marked damage affects attack/block decisions and this is used for scoring, it resulted in a different score being computed in the sub game, triggering a copy error.
Adds a test.
Also fixes creature power evaluation copy paste error.
Also fixes a bug in the main game code where if you have Clone try to copy a token with abilities, like an Eldrazi Scion, it would previously not get those abilities.
Adds a test for the game simulation/copy case.
This fixes all the simulated AI logic to correctly look at all the sub-abilities for target choices. However, it still doesn't support multiple sub-abilities with targets.
Also fixes an issue - still with Wild Slash - where the AI would only look at top-level SA restrictions when determining whether a card is playable. For Wild slash, the top-level SA is the ferocious clause - while the 2 damage clause is a sub-ability and doesn't have the same restrictions.
Marks some functions as private.
Renames a function to avoid confusion because of a different function with same name. Some other whitespace changes and moves attack/blocker decisions away from all the functions dealing with choosing SAs.
This allows coming up with a multi-step planning and caching it, so it doesn't need to be re-computed at subsequent steps if nothing meaningful changed.