Commit Graph

1413 Commits

Author SHA1 Message Date
Agetian
a8b48da7c3 - For now, limit Nykthos, Shrine to Nyx activations to abilities coming from cards in hand, on the battlefield or in command zone (fixes some more wasted activations). 2017-01-03 17:25:43 +00:00
Agetian
e59ed8a34a - Removed unused imports. 2017-01-03 13:39:29 +00:00
Agetian
103c62cab7 - Improved AI logic for Nykthos, Shrine to Nyx. Should prevent wasted activations in many (but not all) cases. 2017-01-03 13:39:01 +00:00
Agetian
2687b9a6a3 - Clarification. 2017-01-03 10:50:15 +00:00
Agetian
d6f084e6e3 - Play Combustible Gearhulk even if the opponent can't be targeted (e.g. through Sigarda, Heron's Grace), a 6/6 first strike creature is decent. 2017-01-03 10:49:21 +00:00
Agetian
faa2634ec4 - Don't forget to set target opponent for Combustible Gearhulk 2017-01-03 10:45:30 +00:00
Agetian
50760a396c - A more targeted solution for Combustible Gearhulk (in ChooseGenericEffectAi), since that card has a special hard-coded AI logic for it anyway. 2017-01-03 09:18:17 +00:00
Agetian
0290413128 - The AI should not immediately disregard triggered abilities in doTriggerAINoCost that have AI logic specified for them (fixes e.g. the AI never playing Combustible Gearhulk at all). 2017-01-03 08:54:21 +00:00
Agetian
c6b8c2cf4e - Some tidying up in ChooseColorAi 2017-01-02 15:25:20 +00:00
Agetian
9f2158c762 - Code formatting. 2017-01-02 15:17:50 +00:00
Agetian
0c18195558 - Added some basic hardcoded logic for Nykthos, Shrine to Nyx to make the AI not to waste it completely and to try to use it to get a mana advantage in main phase 2 instead, when possible.
- Marked Nykthos, Shrine to Nyx as AI playable.
2017-01-02 15:15:13 +00:00
Myrd
d45da5f3db [Simulated AI] Move out anon class to make the code more readable. 2017-01-02 00:53:21 +00:00
Myrd
7f068eb87a [Simulated AI] Refactor SpellAbilityChoicesIterator to its own class. 2017-01-02 00:46:37 +00:00
Myrd
0c6a7bbd18 [Simulated AI] Support modal spells where allowRepeat is true. (e.g. C15 confluence cycle) 2017-01-02 00:29:56 +00:00
Myrd
51af35db2e [Simulated AI] Remove SIMULATE_LAND_PLAYS constant since it's enabled by default now. 2016-12-31 18:38:52 +00:00
Myrd
52711b7b33 [Simulated AI] Make game copier copy player mana pools along with a test. 2016-12-31 18:07:36 +00:00
Myrd
6f0eda7509 [Simulated AI] Fix inverted logic I accidentally landed earlier. 2016-12-30 18:10:19 +00:00
Myrd
a2e2753429 [Simulated AI] Fix energy counters propagation with a test. 2016-12-30 18:03:58 +00:00
Myrd
ce4ef7a4d7 [Simulated AI] More safety guards around executing a planned decision.
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).
2016-12-30 17:50:47 +00:00
Myrd
6ac9182701 [Simulated AI] Fix a NPE in target caching code. 2016-12-30 17:21:51 +00:00
Myrd
503ee37c8a [Simulated AI] Make a SpellAbilityRef helper class.
I plan to expand it in the future, but for now this doesn't introduce any functional changes.
2016-12-30 17:08:34 +00:00
Myrd
4ffa41f624 [Simulated AI] Stop recursing when we've found a winning move already. 2016-12-29 22:56:19 +00:00
Myrd
1c1de9a195 [Simulated AI] Fix transformed state with a test and commit part of my fix from my previous change.
I forgot to actually commit the validation and activatedPlayer setting part of my last change, so this change contains that too.
2016-12-29 22:42:37 +00:00
Myrd
0e9b327fd9 [Simulated AI] Fix memory leak caused by SAs making it into the wrong game's spabCache.
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.
2016-12-29 22:31:18 +00:00
Myrd
c3f30c6871 [Simulated AI] Make printing of the decision tree a bit better.
Also removes a print line from a test.
2016-12-29 18:22:31 +00:00
Myrd
c67a809367 [Simulated AI] Get target candidates from the SA that requires targets, rather than the root one.
This makes sense correct target restrictions are used.
2016-12-29 06:44:14 +00:00
Myrd
1d1b94e757 [Simulated AI] Teach simulated AI how to choose card modes (e.g. on Charms and Commands).
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.
2016-12-29 06:36:08 +00:00
Myrd
485623b631 Fix dev mode restoring game state with counters (e.g. planeswalker loyalty). 2016-12-28 21:32:29 +00:00
Myrd
4b13094945 Remove debug print lines. 2016-12-27 20:24:47 +00:00
Myrd
0cd378b442 [Simulated AI] Fix a bug in my previous changes.
resetTargets() needs to be called before tgt.getAllCandidates() so that the currently-set target is also considered.
2016-12-27 20:24:18 +00:00
Myrd
2a6ab7ec26 [Simulated AI] Introduce an optimization that skips evaluating a target for a spell/ability if it's the same as a different target that was already evaluated (e.g. when there's lots of tokens on the field and AI is evaluating removal). 2016-12-27 20:10:59 +00:00
Myrd
8f64ad3638 [Simulated AI] Fix game copy error caused by marked damage not being copied.
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.
2016-12-27 19:11:18 +00:00
Myrd
7521c33c30 [Simulated AI] Fix issue with empty card names when pretty-printing SpellAbilities. 2016-12-27 04:28:02 +00:00
Myrd
77a526b6d9 [Simulated AI] Fix copying tokens with abilities, like Eldrazi Scions.
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.
2016-12-27 04:09:18 +00:00
Myrd
5f634730ff [Simulated AI] Some cards, like Wild Slash, have targeting as part of their sub-ability.
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.
2016-12-27 02:14:40 +00:00
Myrd
eafaaf5088 [Simulated AI] Copy combat when copying game state. This fixes an NPE in AI code that expects the Combat object to exist if we're in the corresponding phase. 2016-12-26 17:28:50 +00:00
Hanmac
e2eb916d72 make TokenDoubler use new Replacement Effect 2016-12-26 16:57:28 +00:00
Myrd
d3723daa6d [Simulated AI] Fix game copy error with dashed creatures and add a test. 2016-12-26 16:29:21 +00:00
Myrd
0b7c70230a [Simulation AI] Fix broken tests. 2016-12-26 16:12:46 +00:00
Hanmac
a67da177ff add new Replacement Effect its for manipulating the original request
Card#addCounter does show how it is done
2016-12-26 13:31:20 +00:00
Myrd
4f61ca9f3b [Simulated AI] Remove limitation of playing spells only in MAIN2 which I added a few commits ago. 2016-12-26 05:42:19 +00:00
Myrd
a78455051d [Simulated AI] Now that we're pruning the search tree a bit, enable land-play simulation and increase search depth. 2016-12-26 05:34:21 +00:00
Myrd
496f63c814 [Simulated AI] Add logic to prune some targeting decisions that have been evaluated previously in the decision tree and found lacking. 2016-12-26 05:11:36 +00:00
Myrd
6831c990a6 [Simulated AI] Add capability to simulate land plays, allowing the AI to prioritize which lands to play.
Currently, this is disabled because enabling this requires increasing the search depth and that slows things down too much currently.
2016-12-25 19:42:15 +00:00
Myrd
c3b9332e59 A few more cleanups to AIController. 2016-12-25 17:10:02 +00:00
Myrd
da9694c515 Some cleanups to AIController.
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.
2016-12-25 17:04:00 +00:00
Myrd
5def006bcd Remove some extra printing. 2016-12-25 15:53:56 +00:00
Myrd
b74b952584 [Simulated AI] Remove a wasteful GameSimulator instantiation. 2016-12-25 06:39:10 +00:00
Myrd
328922029a [Simulated AI] Refactor code to create a Plan object.
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.
2016-12-25 05:05:18 +00:00
Hanmac
e2cbbd7575 ComputerUtil & HumanPlay: fixed Splice onto Arcane only for Spells 2016-12-24 11:01:48 +00:00