AI Improvement

All about getting the AI less baka...
Nazar-WTH-PCgamer
Posts: 60
Joined: Sat Feb 19, 2011 5:24 am

Re: AI Improvement

Post by Nazar-WTH-PCgamer »

On a slightly different note... from topic viewtopic.php?f=21&t=2525&start=10 where I didn't get any answers to my question.
Nazar-WTH-PCgamer wrote:My question to you guys is this: Is the AI player always thinking during the game or is it only responding when prompted to do so (triggered for instance) or is it only reacting/playing during certain phases (to defend during combat, or all along during its own turn)?
I'm totally unaware of the thinking process of AI during phases it isn't really playing but rather watching or waiting to react. Please enlight me on that subject to improve my understanding of the game and AI mechanic in WTH.

Thanks in advance!
Nazar is meant to rule the world... Someday! Once Nazar is in charge, goblins won't have to hide or shovel orcish poops no more. Vote for Nazar!!!
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: AI Improvement

Post by wololo »

Basically the engine asks the AI to react anytime it would ask a player to react. The AI is therefore given the opportunity to interrupt, etc... the same way a normal player would.

That being said, there are still many cases for which the AI just replies "I don't know what to do now, so I'm skipping". Although this has been dramatically improved recently by Zethfox who added the possibility to interrupt and play instants, I believe.
Nazar-WTH-PCgamer
Posts: 60
Joined: Sat Feb 19, 2011 5:24 am

Re: AI Improvement

Post by Nazar-WTH-PCgamer »

Thank you wololo for sharing that information with me and other users.
Nazar is meant to rule the world... Someday! Once Nazar is in charge, goblins won't have to hide or shovel orcish poops no more. Vote for Nazar!!!
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: AI Improvement

Post by Zethfox »

kinda, i disallowed it during interupting with instants of the move to phases or when the stack is empty...simply becuase it created a few infinate loops, i basically had no way of telling ai to "stop" trying to find a card to play...meaning something like a mass removal spell in hand, it sees that it would be "bad" to play it, then it tries looking for something else, since the function is run on update() calls, ai gets stuck constantly looping "play this----no---ok look for something else---nothing----ok contenue interupting becuase i see there is something i can play---same thing as before hmmm---no----ect ect ect" you get the point...

....however, the ai will respond to a card being played with instants, so things like "counterspell",mass removal, ect will be used...its nice seeing ai crush you with a instant...myself going against an ai deck with counterspells in it is so tragic...becuase i get so excited when im about to have enough mana to cast "the big spell that will win me the game", and as fast as lightining i see the interupt window pop up with "counterspell"....then i cry a little :(
timmermac
Posts: 99
Joined: Wed May 19, 2010 1:50 pm

Re: AI Improvement

Post by timmermac »

I downloaded the version 15 beta, and I've noticed while playing that the computer will cast Tranquility and other "Destroy all enchantment" type cards when there aren't any enchantments in play.
Mytherial
Posts: 16
Joined: Tue Sep 14, 2010 5:19 pm

Re: AI Improvement

Post by Mytherial »

I don't know how possible it would be to alter the way that the AI plays it's mana but if you could somehow have it delay playing mana cards during the first phase when certain cards are out (ex. Tectonic Instability - which causes all that players lands to be tapped when a land is played). it would allow the AI to continue playing even when they have mana in hand. as It is now, they simply play their mana if they have any, which taps all their mana and basically locks them out.
Mytherial
Posts: 16
Joined: Tue Sep 14, 2010 5:19 pm

Re: AI Improvement

Post by Mytherial »

Zethfox wrote:kinda, i disallowed it during interupting with instants of the move to phases or when the stack is empty...simply becuase it created a few infinate loops, i basically had no way of telling ai to "stop" trying to find a card to play...meaning something like a mass removal spell in hand, it sees that it would be "bad" to play it, then it tries looking for something else, since the function is run on update() calls, ai gets stuck constantly looping "play this----no---ok look for something else---nothing----ok contenue interupting becuase i see there is something i can play---same thing as before hmmm---no----ect ect ect" you get the point.(
Not sure this is possible or not Zeth, but is it possible to code a boolean variable array that the AI could check against when an update() call occurs?

Example:

The update() function triggers, and the AI scans it's cards for a playable card. If it finds one, it checks the boolean array for that card #. If it's true, it skips the rest of the function.
if it's false then it sets that boolean array with the number being the card # in his hand to true.
If that card can't be played then it does nothing.

if the card can be played, it sets the variable back to false since the card is used and triggers the interrupt.
alternately, if there is a function for when a card is played or drawn, it could set that variable back to false then as well to make sure it will check that slot in his hand again later.

something along those lines might prevent the AI from looping permanently?
Not sure though, since my programming experience is limited to trigger editing for maps in games like Starcraft and Warcraft III
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: AI Improvement

Post by Zethfox »

well, as for ai looping, i found the cause of a rare loop that was happening where ai gets stuck in a targetchooser, and have solved it, as far as the update call you suggest, this is how it currently already works, however what would happen when i let it run wild is that ai would try interupting and when it couldnt find a card it would try again....over and over...if we restrict ai in the function it uses to determine the ai then the restriction we add would apply if or if no cards were found, so ai gets dumbed down way too much...meaning it would cast only one card or 2, when it was able to cast its whole hand.

alot of the ai logic needs a serious rewrite. something i might do myself here in the weeks to come.
Mytherial
Posts: 16
Joined: Tue Sep 14, 2010 5:19 pm

Re: AI Improvement

Post by Mytherial »

that makes sense i spose, plus now that i think about it, if the game situation changed that card would still be ignored even if it did become useful so my idea wouldn't really be feasible anyway.
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: AI Improvement

Post by Zethfox »

i actually reworked this today, thought of a more clever way to do it :)
say hello to counterspell battles between you and ai...
Locked