destroy all

All about getting the AI less baka...
rawsugar
Posts: 228
Joined: Wed Aug 11, 2010 11:05 am

destroy all

Post by rawsugar »

Here's the current algorithm:
myNbCards = count the number of cards in my play that will be impacted by the "destroy all"
opponentNbCards = count the number of cards in my opponent's play that will be impacted
myCardsPower = count the total power of the creatures in my play that will be impacted by the card
opponentCardsPower= count the total power of the creatures in opponent's play that will be impacted by the card
if (myNbCards < opponentNbCards OR myCardsPower < opponentCardsPower) then high percentage of chance to cast the spell, otherwise low percentage

could a life vs power requirement be added to this?
like
life/10 < [myNbCards - opponentNbCards] OR life/4 < [myCardsPower - opponentCardsPower]

or simply a number higher than 0, like
2 < [myNbCards - opponentNbCards] OR 3 < [myCardsPower - opponentCardsPower]

so that the destroy all should affect either 2 cards of opponents more than yours or destroy 3 more power than you lose
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: destroy all

Post by Zethfox »

huh?
rawsugar
Posts: 228
Joined: Wed Aug 11, 2010 11:05 am

Re: destroy all

Post by rawsugar »

for spells like judgment day etc. the current algorithm is a quote from wololo in this thread viewtopic.php?f=32&t=416

year and a half old tho, might have moved on.

making it not simply a matter of power inferiority but actually requiring it to be of a certain size would make it less likely that AI burns through it destroyall spells while there no creatures in play or while playing a creature would actually give it power superiority.
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: destroy all

Post by Zethfox »

whatever that is, it is certainly not the case anymore...
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: destroy all

Post by wololo »

Zethfox wrote:whatever that is, it is certainly not the case anymore...
Why, did you change it? It used to work fairly well, for the AI to know if it should cast such a spell or not.
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: destroy all

Post by Zethfox »

i didnt change it, it was changed long before me...if you try to break point in those old "all" function in the svn, they say "no executable code is associated with this line, this breakpoint will not be hit" i imagine these became obsolete when "all(" was introduced...but thats just guessing....this also explains why ai waste cards like wraith of gods....even tho you have no creatures it will cast it killing his own....
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: destroy all

Post by wololo »

The code is still here, but changed a bit:
in function int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, TargetChooser * tc)

Code: Select all

    if (ALord * abi = dynamic_cast<ALord *>(a))
    {
        int myCards = countCards(abi->tc, p);
        int theirCards = countCards(abi->tc, p->opponent());
        int efficiency = abilityEfficiency(abi->ability, p, mode, tc);
        if (myCards > theirCards)
            return efficiency;
        return -efficiency;
    }
http://code.google.com/p/wagic/source/b ... y.cpp#2785
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: destroy all

Post by Zethfox »

ah...well, havent messed with that piece of code myself...did the logic behind it change...becuase currently its as if its completely ignored.
after debugging a bit i find the where it states return eff..thats the suggestion...bad naming considering everywhere else it calls this int suggestion....

this function is not coded correctly , using the logic of returning -(-number) is bad....and can lead to alot of confusion...like why did this ai just return a bad ability as a good one and kill off its 4 creatures with day of judgement....
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: destroy all

Post by wololo »

Zethfox wrote: this function is not coded correctly , using the logic of returning -(-number) is bad....and can lead to alot of confusion...like why did this ai just return a bad ability as a good one and kill off its 4 creatures with day of judgement....
I think I coded it correctly, but I'm not perfect ;)

Here's the logic, in english:
I have a lord, that impacts some of my cards, and some of my opponent's card.
The lord core effect (such as "+1/+1"), independently of the targets, is either negative, or positive (for example, "-1/-1" is negative)

If I have more creatures impacted than my opponent, return the same impact as the effect (i.e if the effect is negative and more creatures from me are impacted than from my opponent, return negative. if the effect is positive and more creatures from me are impacted than from my opponent, return positive.)

If I have less creatures impacted than my opponent, return the opposite of the effect. (i.e if the effect is negative and less creatures from me are impacted than from my opponent, return positive) <- makes sense?

But if you find a flaw in the logic, please enlighten me. I'm not perfect, but right now I just think you didn't actually understand the (fairly simple) logic :)
This is not to say that it is bug free, but at least this part I believe is correct...
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: destroy all

Post by Zethfox »

not so much the logic of the code itself...but something you touched on with me the other day..using code logic that forces the human brain to think in negitive negitive...like i dont like not going without having a car...did i mean i DO like it when i dont have a car...or did i mean i DONT like it when i do have a car....
Locked