Programming for Combat
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
3 posts
• Page 1 of 1
Programming for Combat
by slapshot5 » 26 Jul 2011, 01:34
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
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
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Programming for Combat
by friarsol » 26 Jul 2011, 02:30
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: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?
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.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.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Programming for Combat
by slapshot5 » 26 Jul 2011, 03:29
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!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.

-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: Bing [Bot] and 40 guests