It is currently 27 Jun 2025, 01:22
   
Text Size

PTPump Code Change

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

PTPump Code Change

Postby 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.
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.
User avatar
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

Postby 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.
The Force will be with you, Always.
User avatar
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

Postby 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.
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 first time it plays the ability, .6667^0 is 1.0; the second time, .6667^1 is .6667, and the third time, .6667^2 is .4448. So it becomes less and less likely that it plays the ability. Meh... not terribly intelligent, but definitely should be an improvement.
The Force will be with you, Always.
User avatar
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

Postby 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.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: PTPump Code Change

Postby 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.
User avatar
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

Postby 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).
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times


Return to Forge

Who is online

Users browsing this forum: No registered users and 38 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 38 users online :: 0 registered, 0 hidden and 38 guests (based on users active over the past 10 minutes)
Most users ever online was 5050 on 26 Jun 2025, 06:02

Users browsing this forum: No registered users and 38 guests

Login Form