I’ve talked a lot about the AI, but I have still a little more on my mind. Hopefully I can get the computer to play Instants and abilities during combat and at end of turn. I say “hopefully” because I am not quite to that point yet and although it sounds simple to theory, in reality it is always more complicated.
Anyways, as you might remember the AI calls SpellAbility canPlayAI method if it should play that card or ability. If that method returns true, then chooseTargetAI is called and it sets any necessary targets. This is a simple way that I have found to give each card some intelligence.
The problem came about when I think Shock should kill a 2/2 flyer, in order to maximize its effect. The computer will first try to kill you with Shock if your life points are that low. The problem is that in constructed (all the available cards) killing a 2/2 flyer is fairly common, but in sealed or draft it is more unusual. I could split the AI put into limited and non-limited games, but generally the same AI does fine for both. In general I want the AI to be more flexible, so that Shock should usually target a 2/2 flyer, but sometimes if the computer is desperate, it will kill a non-flyer.
I could split canPlayAI and chooseTargetAI into two sets of methods. The first set of methods could check if the best targets are available. And the second set of methods could check for just good targets. If the computer is over 10 life only the “best” functions would be called, so a card would always get the maximum effect. Otherwise, the “good” methods would be checked, so a card would have a lesser effect. Using this division would ensure that only good cards are played at the beginning of the game and that lesser cards are used out of necessity in order keep from dying.
The main drawback with this type of AI is that the computer will not double Shock a 4/4 creature, because each individual Shock only looks for a X/2 creature to kill. This worries me when I am programming but I don’t notice when I’m playing a game. I guess it is just a case of “over thinking” the situation.
Saturday, July 7, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment