Internal information about Shoddy Battle

X-Act

np: Biffy Clyro - Shock Shock
is a Site Content Manager Alumnusis a Programmer Alumnusis a Smogon Discord Contributor Alumnusis a Top Researcher Alumnusis a Top CAP Contributor Alumnusis a Top Tiering Contributor Alumnusis a Top Contributor Alumnusis a Smogon Media Contributor Alumnusis an Administrator Alumnus
I downloaded Shoddy Battle recently. I played a few games with it, and I got the feeling that something was wrong with the damage inflicted. Now, I don't know about you, but I don't like my Pokemon being dealt 2% more damage than it should. So, since it's written in Java, I decided to download its source code and start investigating.

After 5 minutes rummaging through the code (which is extremely well-commented, by the way), I got to the part where the program calculates the damage done:

Code:
.
.
.
int power = (int)(((int)((int)(((int)((2 * attacker.getLevel()) / 5.0 + 2.0)
        * attack
        * move.getPower())
        / defence)
        / 50.0)
        + 2)
        * multiplier
        * (stab ? 1.5 : 1.0)
        * (random / 255.0));
if (move.canCriticalHit() && isCriticalHit(move, attacker, defender)) {
            power *= attacker.hasAbility("Sniper") ? 3 : 2;
.
.
.
Let's translate this to mathematics:

Damage = floor((floor(floor((floor((2 * Level) / 5 + 2) * Attack * BasePower) / Defense) / 50) + 2) * TypeEffectiveness * STAB * (Random / 255)) * CH

Random is a random whole number between 217 and 255, by the way, which has been proven wrong not only for DP, but for ADV as well. Oh, and who cares about TypeEffectiveness, STAB and (Random/255) possibly all being decimals... just multiply them out and then floor the answer! And I haven't even started to look into how the item, ability and berry modifiers are implemented...

I have told Colin about this, but, for now, be aware of the fact that your damage calculations might not correspond to the damage you'll be dealing in Shoddy Battle... you'll end up dealing around 2% more or less damage than you're supposed to be dealing. Which, in the case when my opponent was left with 1% health after I hit him with a move that I was certain to OHKO him with, is rather frustrating at times.
 
Nice work. I'm not sure if I like shoddy getting better and better since it seems to go against Smogon in a way, but then again Competitor will kick its ass sooner or later anyway and for now it's nice to have a simulator be as accurate as possible.
 

obi

formerly david stone
is a Site Content Manager Alumnusis a Programmer Alumnusis a Senior Staff Member Alumnusis a Smogon Discord Contributor Alumnusis a Researcher Alumnusis a Top Contributor Alumnusis a Battle Simulator Moderator Alumnus
I'm not really worried about a Java program overtaking Competitor, if nothing else than because of how incredibly slow it is.
 

X-Act

np: Biffy Clyro - Shock Shock
is a Site Content Manager Alumnusis a Programmer Alumnusis a Smogon Discord Contributor Alumnusis a Top Researcher Alumnusis a Top CAP Contributor Alumnusis a Top Tiering Contributor Alumnusis a Top Contributor Alumnusis a Smogon Media Contributor Alumnusis an Administrator Alumnus
Yeah, I noticed it too. Also, it seems to crash often, or maybe it's just me.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top