Jump to content
Sign in to follow this  
silverlime

Problem with Parting Shot (and Sturdy) with AI

Recommended Posts

I've found another thing that should probably be addressed in the AI, this time for Parting Shot. Here's the code for reference:

      when 0x13D # Parting Shot
        if (!opponent.pbCanReduceStatStage?(PBStats::ATTACK) && !opponent.pbCanReduceStatStage?(PBStats::SPATK)) || (opponent.stages[PBStats::ATTACK]==-6 && opponent.stages[PBStats::SPATK]==-6) || (opponent.stages[PBStats::ATTACK]>0 && opponent.stages[PBStats::SPATK]>0)
          score*=0
        else
          if attacker.pbNonActivePokemonCount==0
            if attacker.pbOwnSide.effects[PBEffects::StealthRock]
              score*=0.7
            end
            if attacker.pbOwnSide.effects[PBEffects::StickyWeb]
              score*=0.6
            end
            if attacker.pbOwnSide.effects[PBEffects::Spikes]>0
              score*=0.9**attacker.pbOwnSide.effects[PBEffects::Spikes]
            end
            if attacker.pbOwnSide.effects[PBEffects::ToxicSpikes]>0
              score*=0.9**attacker.pbOwnSide.effects[PBEffects::ToxicSpikes]
            end 
            if (attacker.pbSpeed>pbRoughStat(opponent,PBStats::SPEED,skill)) ^ (@trickroom!=0)
              score*=1.1
            end
            sweepvar = false
            for i in pbParty(attacker.index)
              next if i.nil?
              temprole = pbGetMonRole(i,opponent,skill,count,pbParty(attacker.index))
              if temprole.include?("Sweeper")
                sweepvar = true
              end
            end  
            if sweepvar 
              score*=1.5
            end
            if roles.include?("Lead")
              score*=1.1
            end
            if roles.include?("Pivot")
              score*=1.2
            end
            loweredstats=0
            loweredstats+=attacker.stages[PBStats::ATTACK] if attacker.stages[PBStats::ATTACK]<0
            loweredstats+=attacker.stages[PBStats::DEFENSE] if attacker.stages[PBStats::DEFENSE]<0
            loweredstats+=attacker.stages[PBStats::SPEED] if attacker.stages[PBStats::SPEED]<0
            loweredstats+=attacker.stages[PBStats::SPATK] if attacker.stages[PBStats::SPATK]<0
            loweredstats+=attacker.stages[PBStats::SPDEF] if attacker.stages[PBStats::SPDEF]<0
            loweredstats+=attacker.stages[PBStats::EVASION] if attacker.stages[PBStats::EVASION]<0
            miniscore= (5)*loweredstats    
            miniscore+=100
            miniscore/=100.0
            score*=miniscore      
            raisedstats=0
            raisedstats+=attacker.stages[PBStats::ATTACK] if attacker.stages[PBStats::ATTACK]>0
            raisedstats+=attacker.stages[PBStats::DEFENSE] if attacker.stages[PBStats::DEFENSE]>0
            raisedstats+=attacker.stages[PBStats::SPEED] if attacker.stages[PBStats::SPEED]>0
            raisedstats+=attacker.stages[PBStats::SPATK] if attacker.stages[PBStats::SPATK]>0
            raisedstats+=attacker.stages[PBStats::SPDEF] if attacker.stages[PBStats::SPDEF]>0
            raisedstats+=attacker.stages[PBStats::EVASION] if attacker.stages[PBStats::EVASION]>0
            miniscore= (-5)*raisedstats
            miniscore+=100
            miniscore/=100.0
            score*=miniscore    
            if attacker.effects[PBEffects::Toxic]>0 || attacker.effects[PBEffects::Attract]>-1 || attacker.effects[PBEffects::Confusion]>0
              score*=1.3
            end
            if attacker.effects[PBEffects::LeechSeed]>-1
              score*=1.5
            end   
            miniscore=130
            if attacker.hasWorkingAbility(:SHADOWTAG) || attacker.hasWorkingAbility(:ARENATRAP) || opponent.effects[PBEffects::MeanLook]>=0 ||  opponent.pbNonActivePokemonCount==0
              miniscore*=1.4
            end
            ministat=0          
            ministat+=opponent.stages[PBStats::ATTACK] if opponent.stages[PBStats::ATTACK]<0
            ministat+=opponent.stages[PBStats::DEFENSE] if opponent.stages[PBStats::DEFENSE]<0
            ministat+=opponent.stages[PBStats::SPEED] if opponent.stages[PBStats::SPEED]<0
            ministat+=opponent.stages[PBStats::SPATK] if opponent.stages[PBStats::SPATK]<0
            ministat+=opponent.stages[PBStats::SPDEF] if opponent.stages[PBStats::SPDEF]<0
            ministat+=opponent.stages[PBStats::EVASION] if opponent.stages[PBStats::EVASION]<0
            ministat*=(5)
            ministat+=100
            ministat/=100.0
            miniscore*=ministat  
            if opponent.hasWorkingAbility(:UNAWARE) || opponent.hasWorkingAbility(:DEFIANT) || opponent.hasWorkingAbility(:COMPETITIVE) || opponent.hasWorkingAbility(:CONTRARY)
              miniscore*=0.1
            end
            miniscore/=100.0
            score*=miniscore
          end          
        end  

There are 2 problems I see with this. First of all, the score increases if the user has Shadow Tag/Arena Trap, but this wouldn't matter because it's switching out anyway. Secondly, the score severely decreases if the opponent has Unaware, but Unaware only ignores stat changes on the opponent, so lowering the Pokemon's stats with Unaware would still work (and is arguably more helpful to lower them on than a regular Pokemon).

 

EDIT: Also, the AI for Reflect and Light Screen, when increasing the score if the attacker has Sturdy or Focus Sash, it doesn't check if the attacker is at full HP (Aurora Veil does this though). Many checks with Sturdy also fail to check if the opponent/attacker has Mold Breaker as well, which is important to note, as this seems inconsistent. The AI also checks existing weather for sturdy in weather setting moves while it should assume the weather that would be set by the move

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...