It is currently 11 Sep 2025, 17:42
   
Text Size

Programming for Combat

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Programming for Combat

Postby 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
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

Postby friarsol » 26 Jul 2011, 02:30

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Programming for Combat

Postby slapshot5 » 26 Jul 2011, 03:29

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
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times


Return to Developer's Corner

Who is online

Users browsing this forum: Google Adsense [Bot] and 35 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 36 users online :: 1 registered, 0 hidden and 35 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: Google Adsense [Bot] and 35 guests

Login Form