magefree / magefree/mage

AI can't use additional cost like buyback, replicate, etc

Open
#6,143 0 comments 0 reactions 0 assignees View on GitHub
AI bug
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

With current additional cost logic users must choose extra cost before cast. Human player can calc it itself and predict future cost, but AI don't known all available mana and can't calc needed mana for it to use.

Moreover there are hidden mana added by TAPPED_FOR_MANA events. It's can't be calced before real mana use -- see TODO from f5ef16c8cf4d9ef51b9b2981c93946e18453d9f4. There are conditional mana, etc.

That's why it's impossible to know all available mana before real pay (in current version).

Problems example:
* `Replicate` ability cause AI to infinite choices (AI try to add more replicates as possible);
* `Buyback` ability always activated by AI (e.g. it can't cast card for normal cost at all -- buyback activated and spell cancelled on not enough mana);
* Search all problem abilities by `implements OptionalAdditionalSourceCosts`.
* Conspire ability works fine with AI;

Use `Outcome.AIDontUseIt` for that abilities (AI will ignore it) until mana available will be improved (see bcb37992cc63fba2ed17082ad69fce4a93e5bf4b and 1ae9fc883eeef2910df4716db64de677af8ea434). No needs to find all available mana -- it can be only basic mana/pool without any conditions/restrictions for use.

Contributor guide

No contributing guide indexed for this repository

Research direction

Search for abilities implementing OptionalAdditionalSourceCosts and inspect the referenced commits and the TAPPED_FOR_MANA TODO. Trace how additional costs are presented to the AI, including Replicate and Buyback, and identify the affected abilities. Done means those abilities use Outcome.AIDontUseIt so the AI does not select them until mana availability can be handled reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
ai, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.