PTPump Code Change
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
6 posts
• Page 1 of 1
PTPump Code Change
by Rob Cashwalker » 25 May 2009, 12:51
As discussed in the card request thread, this code should support a "macro" of sorts for pumping in increments of the cards current power or current toughness. Like Chameleon Colossus.
It starts at around Line 361 for PTPump. The same code can be applied to the PTKPump.
It starts at around Line 361 for PTPump. The same code can be applied to the PTKPump.
- Code: Select all
final String manaCost = k[0].substring(7);
Integer na = card.getNetAttack();
Integer nd = card.getNetDefense();
pt[0].replace("p", na.toString());
pt[0].replace("t", nd.toString());
pt[1].replace("p", na.toString());
pt[1].replace("t", nd.toString());
attack[0] = Integer.parseInt(pt[0].replace("+", ""));
defense[0] = Integer.parseInt(pt[1].replace("+", ""));
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: PTPump Code Change
by Rob Cashwalker » 25 May 2009, 13:09
Other cards supported by this:
Feral Animist
Auriok Bladewarden
Wow.. unless I'm missing something.. it's a pretty short list.
Feral Animist
Auriok Bladewarden
Wow.. unless I'm missing something.. it's a pretty short list.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: PTPump Code Change
by Rob Cashwalker » 26 May 2009, 02:00
Here's some logic change for the pump abilities to help prevent the computer from wasting all available mana.
I wrote it based on the KPump code, but it can pretty much be adapted to the others.
I wrote it based on the KPump code, but it can pretty much be adapted to the others.
- Code: Select all
public boolean canPlayAI()
{
//in case if a lifelink pump, allow multiple pumps
if (CardFactoryUtil.AI_doesCreatureAttack(card) &&
!card.getKeyword().contains(keyword))
{
Random r = new Random();
if (r.nextFloat() <= Math.pow(.6667, card.getAbilityUsed()))
return true;
else
return false;
}
else
return false;
}
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: PTPump Code Change
by DennisBergkamp » 26 May 2009, 07:02
Yes, I like this way of doing it. Actually, maybe we could even make the number (0.667) a little bit smaller.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: PTPump Code Change
by Chris H. » 26 May 2009, 11:23
I assume that we have a variable with the number of cards in the computers hand.
I wonder if we could use this to modify the chance that the computer will use it's mana to pump a creature.
I wonder if we could use this to modify the chance that the computer will use it's mana to pump a creature.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: PTPump Code Change
by Rob Cashwalker » 26 May 2009, 11:44
The AI code for RegenerateMe uses the cards in hand as a modifier.
After sleeping on it, I realize that KPump doesn't need the limiting code like the PTPump. Once the creature has the keyword, it fails the first test (does it already have the keyword). The TargetedKPump will need it.
I was thinking about it more, and .5 could work.
It still won't pump to maximum effect if the creature is going to attack without any possible blockers.
Oh, and the code change to support "+p" or "+t" has one flaw. The ability description won't work right. WE could modify the code that builds the description, if p or t is used, that it instead generates "+X/+X where X is the creature's" (power or toughness based on the usage of p or t in the keyword).
After sleeping on it, I realize that KPump doesn't need the limiting code like the PTPump. Once the creature has the keyword, it fails the first test (does it already have the keyword). The TargetedKPump will need it.
I was thinking about it more, and .5 could work.
It still won't pump to maximum effect if the creature is going to attack without any possible blockers.
Oh, and the code change to support "+p" or "+t" has one flaw. The ability description won't work right. WE could modify the code that builds the description, if p or t is used, that it instead generates "+X/+X where X is the creature's" (power or toughness based on the usage of p or t in the keyword).
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 38 guests