Page 1 of 1

Programming for Combat

PostPosted: 26 Jul 2011, 01:34
by slapshot5
Hi all,

The Combat code has changed a lot since the last time I dug around in there. (Probably when I first did Lure...) Anyways:

First question:
How does the compy decide if he's going to attack Human's Planeswalker? Is it really random as ComputerUtil_Attack2.chooseDefender() suggests?

Second:
If I set Combat.setCurrentDefender(int index), if that all the Combat code looks at for where to add attackers in Combat? I ask because I'm setting it to a planeswalker in chooseDefender, but the computer attacks Human and not the planeswalker.

That's a start. Thanks in advance.

-slapshot5

Re: Programming for Combat

PostPosted: 26 Jul 2011, 02:30
by friarsol
slapshot5 wrote:First question:
How does the compy decide if he's going to attack Human's Planeswalker? Is it really random as ComputerUtil_Attack2.chooseDefender() suggests?
Yes, but feel free to improve it. The way it worked before that wasn't much better. I think the AI would attack the Planeswalker if it could kill it, otherwise it wouldn't. The best way would involve prediction, spreading probably damage, and the like.

slapshot5 wrote:Second:
If I set Combat.setCurrentDefender(int index), if that all the Combat code looks at for where to add attackers in Combat? I ask because I'm setting it to a planeswalker in chooseDefender, but the computer attacks Human and not the planeswalker.
I think there might be a timing issue on when it gets set. Without looking at the code, I'm guessing AI probably overwrites the value that you set after you set it. These two changes is one of the few things I've touched in the Combat code, and it happened last November so I'm not that familiar with them.

Re: Programming for Combat

PostPosted: 26 Jul 2011, 03:29
by slapshot5
friarsol wrote:I think there might be a timing issue on when it gets set. Without looking at the code, I'm guessing AI probably overwrites the value that you set after you set it. These two changes is one of the few things I've touched in the Combat code, and it happened last November so I'm not that familiar with them.
It wasn't a timing issue at all. It was programmer error at the simplest level. Suffice it to say, the logic was all correct, except the logic *wasn't saved" at the very end. Boy do I feel dumb. Move along, nothing to see here. Except a working Gideon Jura coming soon! :D

-slapshot5