The Azure Heights Forum


Post New Topic  New Poll  Post A Reply
my profile | search | faq | forum home
  next oldest topic   next newest topic
» The Azure Heights Forum   » Main Campus   » Research Lab   » Battle Formula -- Need Programmers!

UBBFriend: Email this page to someone!    
Author Topic: Battle Formula -- Need Programmers!
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-25-2000 01:54 PM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
Okay, folks... I'm new here, so I don't know if anyone has posted this yet or not, but I am literally inches away from figuring out the battle formula code that runs Pokemon and Pokemon Stadium. What I need are some people that are good with Assembly and following code. If you are, then please email me directly at kittyfox@uswest.net.

For the rest of you, I'm short one variable and I know where it draws its base value from. One of the interesting things I've taken note of during this research is that the attack value of your battling Pokemon will actually raise slightly (by 2-6 points of the ones I've tested) after it is attacked by something that lowers other stats. For instance, my L24 Geodude Tackles a L16 Voltorb. It does 14 damage with an Attack value of 36 (hex). The Voltorb then does Screech and my Defense is significantly lowered. I then check the values of the stored Attack value of my Geodude and it has gone up to 3C (hex) and that value is used in the next tackle, suddenly let me do a couple more points of damage

Just thought people might like to know that when one stat is lowered, it appears that others are raised. The same thing happened when a Sandshrew used Sand Attack, again my attack value of my Meowth this time was raised at the same time the Accuracy value was lowered.

Mind you, this is all *in-game* code extrapolation. It isn't something you can just look at stats and see... cause at the end of the battle, the values return to normal. But try to do a tackle against a friend, see how much damage you do, then have them Screech/Sand Attack/etc., then attack them again with Tackle... the second one will do more damage (assuming neither are crit hits).

------------------
*> KittyFox <*


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
Meowth346
Farting Nudist
Member # 166

posted 04-25-2000 02:12 PM      Profile for Meowth346   Author's Homepage        Edit/Delete Post  Reply With Quote 
Well, you could have easily misread something or made a mistake, but since there are chances that you didn't (I don't know your research EXP), I'll probably try this soon.

--Meowth346

------------------
PokéResearcher in charge of Pokémon Forever
found via http://anime.at/pokefor


Registered: Mar 2000  |  IP: Logged
Meowth346
Farting Nudist
Member # 166

posted 04-25-2000 02:32 PM      Profile for Meowth346   Author's Homepage        Edit/Delete Post  Reply With Quote 
Okay, I'm in battle with hex HEX values for stats:
Attack/19
Defense/14
Speed/1D
Special/15

And...my Pokémon struggles and defeates the enemy. Okay, new battle, same stats.

RATTATA attacks with Screech.

Attack/19-->1C
Defense/14-->0A
Speed/1D-->20
Special/15-->17

So, +3, -10, +3, +2

Let's have another round of Screeh here.

Attack/19-->1C-->1F
Defense/14-->0A-->05
Speed/1D-->20-->24
Special/15-->17-->19

Now, the latest change:
+3, -5, +4, +2

Let's try again:
Attack/19-->1C-->1F-->22
Defense/14-->0A-->05-->04
Speed/1D-->20-->24-->28
Special/15-->17-->19-->1C

Which is:
+3, -1, +4, +3

So, after three Screeches:
+9, -16, +11, +7

Good with the bad, eh? Good find. I'm guessing that Azure Heights already knew about this, but I never really payed any attention.

--Meowth346

------------------
PokéResearcher in charge of Pokémon Forever
found via http://anime.at/pokefor


Registered: Mar 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 04-25-2000 04:15 PM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
The battle damage formula, what I think you are asking for, is (I know its a much longer version, but it covers pretty much everything):

ABCDEF((GHIJKLM/128NOPQ)+1)

Where
A = 1.09 for the maximum damage of the attack; 100/109 for the minimum damage.
B = 0.5 if Reflect is in effect on the opponent and the attack is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost; 1 if the attack is type Fire, Water, Electric, Grass, Ice, or Psychic or the attack is a critical hit.
C = 0.5 if Light Screen is in effect on the opponent and the attack is type Fire, Water, Electric, Grass, Ice, or Psychic; 1 if the attack is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost or the attack is a critical hit.
D = 0 if the attack has no affect on the opponent's first type, 0.5 if the attack is not very effective to the opponent's first type, 2 if it's super effective to the opponent's second type, 1 if it is none of these.
E = 0 if the attack has no affect to the opponent's second type, 0.5 if the attack is not very effective to the opponent's second type, 2 if it's super effective to the opponent's second type, 1 if it is none of these.
F = 1.5 if the attack matches either of the attacking pokémon's types, 1 if it does not.
G = 0.75 if the attacking pokémon is burned and was not protected by Mist at the time of the burn (if it was and has been switched out since then, G = 0.75) and the attack is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost; 1 if anything else.
H = the Attack of the pokémon using the ability if it is type type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost; 1 if the attack is type Fire, Water, Electric, Grass, Ice, or Psychic.
I = the Special of the pokémon using the ability if it is type Fire, Water, Electric, Grass, Ice, or Psychic; 1 if the attack is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost.
J = 2 if the attack critical hits and is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost; if not it is equal to 1 plus the attacking pokémon's number of normal Attack increases divided by 2 plus the number of great Attack increases minus the number of Attack decreases divided by 2 if the attack is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost. (If the value is negative or equal to 0, subtract 2 and use the negative reciprocal of the number.)
K = 2 if the attack critical hits and is type Fire, Water, Electric, Grass, Ice, or Psychic; if not it is equal to 1 plus the attacking pokémon's number of normal Special increases divided by 2 plus the number of great Special increases, minus the number of Special decreases divided by 2 if the attack is type Fire, Water, Electric, Grass, Ice, or Psychic. (If the value is negative or equal to 0, subtract 2 and use the negative reciprocal of the number.)
L = the attack's power.
M = the attacker's level.
N = the Defense of the pokémon defending if the ability is Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost; 1 if the attack is type Fire, Water, Electric, Grass, Ice, or Psychic.
O = the Special of the pokémon defending if the ability is Fire, Water, Electric, Grass, Ice, or Psychic; 1 if the attack is Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost.
P = 1 plus the defending pokémon's number of normal Attack increases divided by 2 plus the number of great Attack increases minus the number of Attack decreases divided by 2 if the attack is type Normal, Fighting, Poison, Ground, Flying, Bug, Rock, or Ghost (if the value is negative or equal to 0, subtract 2 and use the negative reciprocal of the number) and is not a critical hit; 1 if anything else.
Q = 1 plus the defending pokémon's number of normal Special increases divided by 2 plus the number of great Special increases minus the number of Special decreases divided by 2 if the attack is type Fire, Water, Electric, Grass, Ice, or Psychic (if the value is negative or equal to 0, subtract 2 and use the negative reciprocal of the number) and is not a critical hit; 1 if anything else or the number is .

Whew. Told you it was long . If you a simpler version, go to http://www.math.miami.edu/~jam/azure/compendium/combat.htm#bdf

And what you were talking about with the stat changes, I imagine that's a result of stat bleeding, but I don't know too much about it...

[This message has been edited by NeoSyrex (edited 04-25-2000).]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
cfalcon
OLDNBLD
Member # 19

Member Rated:
posted 04-25-2000 04:31 PM      Profile for cfalcon   Email cfalcon   Send New Private Message      Edit/Delete Post  Reply With Quote 
This sounds like the "stat bleeding" effect.

Let me guess. You haven't tested this on a link battle. You got in a 1P fight, and saw this, right?

All stat effects seem to help you out like this (Meditate slightly increases special, I remember hearing...)

I never tested any of it, as it is irrelevant to the multiplayer, last I heard...

Still, it is certainly interesting...

------------------
-cfalcon


From: 39°45' N, 104°52' W | Registered: Feb 2000  |  IP: Logged
cfalcon
OLDNBLD
Member # 19

Member Rated:
posted 04-25-2000 04:36 PM      Profile for cfalcon   Email cfalcon   Send New Private Message      Edit/Delete Post  Reply With Quote 

Didn't spy your post, Meowth.

Was yours also 1 player derived?

------------------
-cfalcon


From: 39°45' N, 104°52' W | Registered: Feb 2000  |  IP: Logged
Meowth346
Farting Nudist
Member # 166

posted 04-25-2000 05:40 PM      Profile for Meowth346   Author's Homepage        Edit/Delete Post  Reply With Quote 
Yeah, I battled Rattata and Spearow in the wild. Guess if I feel up to it again, I'll go ahead and make a 2nd Player save and try a two player go through (which is where most of my testing is...could be why I never picked up on the "stat bleed".

--Meowth346

------------------
PokéResearcher in charge of Pokémon Forever
found via http://anime.at/pokefor


Registered: Mar 2000  |  IP: Logged
Snorlax143
Farting Nudist
Member # 263

Member Rated:
posted 04-25-2000 07:32 PM      Profile for Snorlax143   Author's Homepage   Email Snorlax143   Send New Private Message      Edit/Delete Post  Reply With Quote 
I've noticed that sometimes when I use double team with my pokemon that were slower than the defending pokemon, they will be faster after the double teams.

------------------


From: Oregon, Ohio, USA | Registered: Apr 2000  |  IP: Logged
Mr. K
Racist
Member # 2

Member Rated:
posted 04-25-2000 07:55 PM      Profile for Mr. K   Author's Homepage   Email Mr. K   Send New Private Message      Edit/Delete Post  Reply With Quote 
Yeah, all this is a result of the "stat-bleeding" phenomenon.

We've known about it for some time, but since it doesn't apply to link battles, we've not put a high priority on reporting it.

I'm not even sure exactly where we'd mention it.

If we work on the site for an infinite amount of time, tho, it will surely be mentioned. If only I can get an infinite number of monkeys to help out...

------------------
KOFFING!
Azure Heights Pokémon Laboratory


From: Cinnabar Island | Registered: Feb 2000  |  IP: Logged
Givera
Farting Nudist
Member # 234

Member Rated:
posted 04-26-2000 10:38 PM      Profile for Givera   Author's Homepage        Edit/Delete Post  Reply With Quote 
WOW! I never realized that before... the whole "stat-bleeding" thing... do you think you guys could explain it a little more? I realize it's irrelevent in link-battles (And i'm assuming stadium) but it's an interesting... umm... phenomenon.
-Givera, Hacker of platinum pokemon

------------------
"My staff is complaining about the rats in the kitchen; I want to hire a new staff" -Lunchlady Doris on how to spend the School's oil money
"If any punk-a** Charmander tries to mount my Koffing, I'll have Wiggly crack his spine and Lee will throw him in a vat of Psyduck Surf!" -Mr. K on different species ability to breed
"Heh.....ditto is a G** D*** pimp in g/s....he gets all the a**.." -Argo on Ditto's ability to breed with anything/one
"My Mewtwo's slower than yours because he just had his way with that cute eevee over there, and now he's tired" -CFalcon making a pun on how sex (gender) affects stats


From: Plano, Tx | Registered: Apr 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-27-2000 09:45 AM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
Okay, folks... let me share the formula I have thus far and ask for people to verify it and help me finish it? This is what I pulled directly out of the assembly code, mind you, so it should be the ACTUAL formula for damage calculation.

(2 * A / 5 + 2) * B * C / D / 50 * E

A = Attacker's Level
B = Attacker's Attack or Special
C = Strength of Attack
D = Defender's Defense or Special
E = Type Modifier (weakness/resistance)

Now for my little problem with it... I've tested this a hundred times already and it has worked every time, BUT the value of B inside of the game and outside of the game seem to be different *sometimes*. Within the game (even when the pokemon is still in its slot and not active) the value of its Attack stat is equal to or slightly higher than the one reported when you view the stats on a pokemon with the menu options.

Can anyone help me figure out why this is the case? Thanks... just hoping to put an end to figuring out this formula...

[* Forgot to mention that all divisions are modulo. Disregard remainders. *]

------------------
*> KittyFox <*

[This message has been edited by KittyFox (edited 04-27-2000).]


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-27-2000 11:25 AM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Wow, lots of interesting stuff to reply to!

KittyFox1: As others have said, what you're noticing is known as stat bleeding, and it only seems to happen in the 1P game. Each increase is not a set # of points, but a proportion: 1/8 of the initial value of the stat.

Meowth346: That was some very nice emulator work! How are you picking out and tracking the stat values (if it can be explained to a basically non-computer person)?

KittyFox2: If I'm reading you right, your problem with the discrepancy in Attack is different from the stat bleeding problem you asked about earlier. If that's the case, I'm not sure what would account for it.

Regarding your formula, I see two significant omissions. First, the damage caused by physical and special attacks is variable. Have you seen a value which represents the spread of the distribution this creates?

Second, I don't see anything in the formula to account for the fact that if the Type Modifier value is 1, minimum damage is 1. Without something like the "+1" at the end of the damage formula on our Combat page, I'm not sure how your formula can account for this.

Finally, could you try an alternate expression of your formula? Reading it as best I can, it doesn't work at all when I plug in a few plausible values. Is it possible you mean D*50?


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-27-2000 11:53 AM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
The formula is read as per any mathematical expression.

Take the attacker's level, multiply by 2, divide by 5. Add 2 to that sum. Then take that total times the attacker's attack or special, and the strength of the attack. Then take that total, divide by the defender's defense or special, then divide by 50. Finally, take the last and multiply by the weakness/resistance factors.

Again, this is not a *finished* formula... but it is pulled directly out of the code and has tested accurately. All values should be decimal when put into the formula.

[* Wintermute: The difference between physical and special attacks is accounted for in the formula. Note: physical attacks: B=Attacker's Attack, D=Defender's Defense. special attacks: B=Attacker's Special, D=Defender's Special. *]

------------------
*> KittyFox <*

[This message has been edited by KittyFox (edited 04-27-2000).]


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-27-2000 12:41 PM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
The formula is read as per any mathematical expression.

Take the attacker's level, multiply by 2, divide by 5. Add 2 to that sum. Then take that total times the attacker's attack or special, and the strength of the attack. Then take that total, divide by the defender's defense or special, then divide by 50.

Then I'm afraid that I was right. You mean D*50. Writing

(2*A/5+2)*B*C/D/50*E

is ambiguous. If D is being divided by 50E, then when the full calculation is done, you'll need to invert D/50E, so that the numerator (2*A/5+2)*B*C is being multiplied by 50E. Then that result is divided by D.

What you mean to write is

(2*A/5+2)*B*C*E / D*50

Again, this is not a *finished* formula...

Understood! My understanding of the situation is that you were soliciting suggestions on what might be missing. I'm just trying to provide some.

Wintermute: The difference between physical and special attacks is accounted for in the formula. Note: physical attacks: B=Attacker's Attack, D=Defender's Defense. special attacks: B=Attacker's Special, D=Defender's Special.

No, that's not what I meant. Have you read our Pokemon Combat page? What I meant was that all physical attacks, and all special attacks, produce variable damage. If you have your L30 Raticate use Hyper Fang several times, you will notice that it doesn't do the same amount of damage each time. I was asking whether you had found any values in the code which account for this.


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-27-2000 02:32 PM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
Okay, let me see if I can make the formula look more pretty for easier understanding...

(2 * A) / 5 = W
(W + 2) * B * C = X
X / D = Y
Y / 50 = Z
Z * E = Damage Done

You NEED to do this by step because this is modulo division (remainders tossed away). So you can't simply invert division to multiplication.

As for variance. I haven't found any... in fact, going through the code, I've never found this formula to ever change... but the attack/defense/specials do seem to. Is it possible that this is changing a little and this is what is causing your variance you've noticed in damage done?


------------------
*> KittyFox <*

[This message has been edited by KittyFox (edited 04-27-2000).]


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-27-2000 04:20 PM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Well, the simple fact that remainders are tossed away doesn't preclude any particular order of operations.

According to you, modulo division entails more than this. It entails that the statement be read algorithmically from left to right. I wasn't aware of that, and I apologize.

(That being the case, it was misleading to say that it was "read as per any mathematical expression". That's simply not true: if it were, the normal order of operations would apply, and the expression would be ambiguous.)

At any rate, I understand the formula now. I'm concerned that there is still something missing.

I have a very large amount of data on the damage done by various pokemon using various attacks. Your formula does a superb job of predicting the maximum (not mean, which I find interesting) damage that an attack will do, but it is always about 1 point short (in cases where there are no Type Modifiers). Is there any chance that there is a +1 just before the last step you describe? It would address the concern I mentioned earlier (i.e. without it, it would be too easy for the damage to divide away into nothing, in circumstances when we know that the minimum is 1), and it would bring the values predicted by the formula perfectly in line with the data.

In answer to your question: sure! It's possible that variability in the stats could produce the damage distribution. Seems like a strange way to do it, but it could work.


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-27-2000 04:39 PM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Sorry, my mistake. Given that the remainders are dropped, the formula produces values that are consistently 2 points lower than the maximum damage found in the data (again, in the absence of Type Modifiers).

Do you have a spreadsheet program that will convert a Quattro Pro file? I could e-mail it to you...


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-27-2000 04:46 PM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
Yes, it is very possible that there are further operations upon this formula.

I pulled this from one of the routines in the assembly code. Ignore E, as that I added to the formula without actually finding the code yet that does it. The part (2 * A / 5 + 2) * B * C / D / 50 is done exactly in that order within the code and doesn't appear to deviate at all.

So consider this a 'chunk' of the master formula, if you will. What I need are people who can finish this off, or figure out why B is also equal to or a little higher than the base attack value.

If you use NO$CGB, I have the routine location and data structs. Just drop me an email. As for your database, I should be able to find something around here that can read it.

------------------
*> KittyFox <*


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
Meowth346
Farting Nudist
Member # 166

posted 04-27-2000 04:58 PM      Profile for Meowth346   Author's Homepage        Edit/Delete Post  Reply With Quote 
quote:
Originally posted by KittyFox:
B = Attacker's Attack or Special
Now for my little problem with it... I've tested this a hundred times already and it has worked every time, BUT the value of B inside of the game and outside of the game seem to be different *sometimes*.

Do you mean in battle and out of battle? If so, remember that four of the 8 badges increase your stats in battle.

quote:
Originally posted by Wintermute:
Meowth346: That was some very nice emulator work! How are you picking out and tracking the stat values (if it can be explained to a basically non-computer person)?

I'm not good at explaining, but:
You need a registered version of the NO$GMB emulator. Plus, you need to know the location of something, that something being what you're checking on. Any easy way to get the location is to take a gameshark that modifies what you're looking at.

Let's take this one from my not-online yet archieve:
01**25D0 Change In-Battle Pokémon's Attack (Higher)
01**26D0 Change In-Battle Pokémon's Attack (Lower)

Now, these codes alter your Pokémon's stats. This is for in battles only.

In order to use these for research, you much convert them to a usable format. NO$GMB is most always on page one, so you can drop the "01" off of the codes, plus you can take out the ** since the value of the location isn't part of the address.

That leaves you with:
25D0 Change In-Battle Pokémon's Attack (Higher)
26D0 Change In-Battle Pokémon's Attack (Lower)

Now, take the first two values and move them to the back:
25 D0 --> D0 25
26 D0 --> D0 26

There, your addresses for your Pokémon in battle's HP are:
D025
D026

So, go into battle on the game, then press escape to enter the debug screen. Click on the lower-left hand window, and press (I think) Control+G to jump to an address.

Type in "D025" (without the "s), and it'll take you there.

Then you can view the values at D025 and D026. You might see this:
12 54 A3 76 45 23 76 A3 76 45 BA 3D 76 02 84 2C

The values that I put in BOLD print are the two values for Attack. So, the attack, in Hex, is 2376 (this is a ficticious number here ^_^). Now, use an attack to raise attack, then press escape to return to the debugger, and you might see:
12 54 A3 76 45 24 9D A0 75 45 BA 3B 76 01 84 2C

Of course, this isn't EXACTLY how things would look, but if you notice the before and after strings, the attack went up. I also bled some stats down.

Now, I ask, if an opponent can lower a stat of yours, and it affects your other stats...if YOU raise your own stats with your own attack, does it affect your other stats? I guess that I'll have to try that, unless someone answers, plus check with in-battle stat-enhancing items.

--Meowth346

------------------
PokéResearcher in charge of Pokémon Forever
found via http://anime.at/pokefor

[This message has been edited by Meowth346 (edited 04-27-2000).]


Registered: Mar 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-27-2000 05:00 PM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Here's something else that may be helpful. I did some scribbling and found that given that your formula, plus 2, produces the maximum possible damage for an attack, in order to produce the minimum damage for an attack, the relevant offensive statistic would have to be multiplied by 5/6. This would produce a range across which the game would have to select a random integer each time the attack was used. I don't know if that sort of thing would be easy to spot.

I'll mail you. I use no$ all the time, but I don't really have the expertise to interpret assembly code. I'd probably get a kick out of looking at it, though.


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-27-2000 05:05 PM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Originally posted by Meowth346:
Now, I ask, if an opponent can lower a stat of yours, and it affects your other stats...if YOU raise your own stats with your own attack, does it affect your other stats?

Yep!

Thanks for the cool instructions, by the way. I'll give it a try.


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
White Cat
Nobody knows why I'm an admin.
Member # 42

Member Rated:
posted 04-28-2000 04:29 AM      Profile for White Cat   Author's Homepage   Email White Cat      Edit/Delete Post  Reply With Quote 
Then I'm afraid that I was right. You mean D*50. Writing

(2*A/5+2)*B*C/D/50*E

is ambiguous. If D is being divided by 50E, then when the full calculation is done, you'll need to invert D/50E, so that the numerator (2*A/5+2)*B*C is being multiplied by 50E. Then that result is divided by D.

What you mean to write is

(2*A/5+2)*B*C*E / D*50

Actually, KittyFox is right. To write it your way, you'd have to put parenthesis around the 'D*50' part. Multiplication doesn't take precendence over division like it does with addition and subtraction.

For example, a Mewtwo using Blizzard on a Mew gives a maximum damage of 137 using KittyFox's formula (within a couple points of Azure's formula). Your version gives 343328 points of damage.

If you add the parenthesis, your version is closer to the standard way of writing a formula, though.


From: Calgary | Registered: Feb 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-28-2000 05:31 AM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Originally posted by White Cat:
To write it your way, you'd have to put parenthesis around the 'D*50' part.

You're right of course. My mistake.


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 04-28-2000 10:00 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
WOW!!! YAY, talks about the Battle Damage Formual have started again! It is the MOST IMPORTANT formula in pokemon and we don't have it 100.000% accurate yet I am pretty sure.

KittyFox it is GREAT that you have some ability to rip ROM formula data to some extent. Keep working at it and I will also help give hints if I can. I would suggest ignoring the "stat-bleeding" effects for now...they are very interesting but have no place in 2P VS games and the Damage Formula itself is much more important! =D

I was gonna write that your Damage Formula is screwed up and the damages are too high, but then I read what Wintermute wrote. He observed that your formula gives fairly accurate values for the maximum possible damage attacks do, given randomness. That's great! But we are always off by 1 or 2 damage points it sucks. I'm gonna be working on the formula the next 2 weeks along with you guys...

I have imagined up probably over 50 different possibilities for the EXACT damage formula and I need to do way more testing...

Lemme try to comment on some things about Azure's BDF and KittyFoxes BDF though that I wonder about for now.

The Variability in damage randomness is not very well defined in the Azure formula. I believe understanding EXACTLY how the variability exists in the damage formula is one of the things we need before we can actually come up with the 100.000% accurate formula.

The way Azure describes the damage variability, is to multiply the average damage by 1.09 for max damage, and divide by 1.09 for min damage. This is fine, but if you do that, the "average damage" might no longer be truly the average damage!

In other words, maybe the game generates a random number between 1 and 1.09....and each possible random number to be generated has equal probability to come up (in other words a uniform distribution). Then it will either multiply by or divide by that number (half of the time each). If you do the math, you can actually calculate the average damage of all the possible damages given the probabilities that they will each occur, and it will NOT be the "average damage" we used in the first place. It will be off by a very tiny amount, probably around 0.1 to 1 damage. Possibly insignificant, but possibly not.

Instead, why couldn't the variable damage part of the formula be changed to "add or subtract, 0.09 * average damage, from the average damage". Then your average damage is probably more likely to be really the average. I don't see the significance of the number 0.09 either, and currently use the number 0.08333333 = 1/12 instead. Both are close enough that there's no way we can prove which is right and which is wrong because we aren't that accurate yet.

For KittyFoxes formula, it does make a lot of sense that the game might calculate the Max possible random damage to start out, rather than the average damage. In a lot of hypothetical BDF's I imagined up in the past, I calculated Min possible random damage as a base, rather than average (I never did Max though, and most of the time I try Average).

But Azure's BDF for average damage is VERY accurate and it is also simple and elegent, and uses computer numbers like 128. Also Nintendo reps said it, didnt they? Although who trusts those guys anyways. I think maybe Azure's formula is the right one, but it needs the variability part incorporated exactly somehow in a non-obvious way to work out. But who can argue with ROM-ripped info right? Aaaugh whats going on?! @_@

A final question for the Azure formula: why does min damage normally equal 2, not 1? This is easily explained by the 1.5 factor you get if your attack matches your pokemons type, but then the game must be rounding up somewhere. That is fine, but what about the randomness? Even a tiny tiny randomness in the negative direction woudl give you 1.48 damage which should round to 1 damage, yet pokemons ALWAYS do 2 damage when they suck but they use an attack that matches their type. Also, computers tend to round down (truncate/chop off/modulo or integer division) not up, nor even round as we would. I've already tried so many modifications to the BDF hehe! =D More testing I need to do...wahts going on waa aaa.......

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-28-2000 11:26 PM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
Well, in the process of moving... so the computer has been offline for the past few days... as soon as I can get it back up and a semblance of normality, I'll fire up NO$GMB and delve back into the code some more and see if I can determine what it is doing if my formula calculates the max value (or near to it)

Wintermute says it is always 2 under the max value, so tentatively the actual formula is:

(((((2*A) / 5) + 2)*B*C) / D) / 50) + 2)*E

Though I want to go back into the code and see if I can locate it adding 2 to this value. My cocern is that it messes with the value of B to get this discrepancy, but there is A LOT of jumping around in the assembly code which makes it hard to track at times. I will start stepping through the code past the 'max damage calculation' routine and see if I can locate the exact spot where it multiplies by E and see, if at the same time, I can locate where it might 'subtract a random value' from this max damage to provide the variation.

I'll keep everyone posted *^_^*

------------------
*> KittyFox <*


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 04-28-2000 11:36 PM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
This is the formula I found at TeamPA's site:

((2A/5+2)*B*C/D)/50)+2)*X)*Y/10)*Z/255

A = level
D = defense/special
B = attack/special
C = ability's power
X = type match (1, 1.5)
Y = type mods (20 = super, 10 = normal, 0 = no effect, etc.- the only reason the game does this that I can see is so you can go "in between" the normal bonuses)
Z = a random number between 217 and 255 (I think the ram address for this number is at D0B4,5)

Another thing I found is that it seems if a stat is increased above 997, it is set equal to 997 and 2 is added to it. This only means that 998 is basically equal to 999 for a stat.

------------------
NeoSyrex™
[ NeoSyrex@hotmail.com ]

[This message has been edited by NeoSyrex (edited 04-29-2000).]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-29-2000 12:01 AM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
Wow... mind if I ask what memory addresses you found these additional routines at so I can track them too?

Two things I noticed/inquiring about:

A should be Attacker's Level and
B should be Attacker's Attack in your formula, correct?

The next thing is X and Y are little obscure to me, perhaps not to others though =P ... X in your formula is the modifiers of using an attack? Like Lightning Attack on a Lightning Type? Y is the weakness/resistance factor?

Any deeper explanations and subroutine locations would be MOST appreciated.

------------------
*> KittyFox <*


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 04-29-2000 01:02 AM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
quote:
Originally posted by KittyFox:
A should be Attacker's Level and
B should be Attacker's Attack in your formula, correct?

Yep (just fixed it).

quote:
The next thing is X and Y are little obscure to me, perhaps not to others though =P ... X in your formula is the modifiers of using an attack? Like Lightning Attack on a Lightning Type? Y is the weakness/resistance factor?

Yep.

quote:

Any deeper explanations and subroutine locations would be MOST appreciated.

I don't know where in the rom the formula is, I just got the formula from this page:
http://tokyo.cool.ne.jp/z80/pokemon/poke_y/damage.html , scroll down to the bottom to find the formula. If you want to see the programming itself, I think the link at the top of the page (the second one) has the code (I don't know much about gameboy code, sorry).

------------------
NeoSyrex™
[ NeoSyrex@hotmail.com ]

[This message has been edited by NeoSyrex (edited 04-29-2000).]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
Wintermute
My custom title sucks.
Member # 5

Member Rated:
posted 04-29-2000 01:12 AM      Profile for Wintermute   Author's Homepage   Email Wintermute   Send New Private Message      Edit/Delete Post  Reply With Quote 
Originally posted by NeoSyrex:

This is the formula I found:

((2A/5+2)*B*C/D)/50)+2)*X)*Y/10)*Z/255

Holy, Neo! How long have you had that? It's great...


Y = type mods (20 = super, 10 = normal, 0 = no effect, etc.- the only reason the game does this that I can see is so you can go "in between" the normal bonuses)

Well, I imagine it's to handle "weak" and "super-weak" (is that what you meant?). Y=5, for weak, but how would they express 2.5 for super-weak, I wonder?

Z = a random number between 217 and 255 (I think the ram address for this number is at D0B4,5)

This squares superbly with the data! Nicely done.

Another thing I found is that it seems if a stat is increased above 997, it is set equal to 997 and 2 is added to it. This only means that 998 is basically equal to 999 for a stat.

Hmm, that's interesting. I seem to recall an odd result from a test long ago that would be explained by this, but I had no idea what was happening.


From: Winnipeg, Manitoba | Registered: Feb 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 04-29-2000 01:30 AM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
quote:
Originally posted by Wintermute:
Holy, Neo! How long have you had that? It's great...

I should've been more clear, I originally wrote a little paragraph about TeamPA's site in my message, and that I found this formula on one of the pages. But I deleted it before I sent the message (a little off-topic), and didn't check if the change made the message unclear. Sorry.

quote:

Y = type mods (20 = super, 10 = normal, 0 = no effect, etc.- the only reason the game does this that I can see is so you can go "in between" the normal bonuses)

Well, I imagine it's to handle "weak" and "super-weak" (is that what you meant?). Y=5, for weak, but how would they express 2.5 for super-weak, I wonder?


Yeah, that's what what I was wondering too...

------------------
NeoSyrex™
[ NeoSyrex@hotmail.com ]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
KittyFox
Orangutan Spouse
Member # 339

Rate Member
posted 04-29-2000 09:47 AM      Profile for KittyFox   Email KittyFox   Send New Private Message      Edit/Delete Post  Reply With Quote 
This is excellent =)

I'm going to be giving the web address to one of my friends who can read japanese and see what other information is on the page.

My next question... does anyone have a listing of the stat affecting attacks and how much they affect the stats?

------------------
*> KittyFox <*


From: Ames, IA, USA | Registered: Apr 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 04-29-2000 12:02 PM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
quote:
Originally posted by KittyFox:
I'm going to be giving the web address to one of my friends who can read japanese and see what other information is on the page.

Great! That's what I was hoping someone would do when I originally posted the link to their page. Here's their main page for g/s: http://members.cool.ne.jp/~z80/teamPA/ , and here's the main page for r/b/y/g: http://tokyo.cool.ne.jp/z80/pokemon/index.html . One thing that interests me is that on the g/s bdf page, they have 1.5 (probably for type matches), and right below it they have 0.5. Perhaps there's a disadvantage for using an attack that that is strong against your own type (ie Rhydon using Surf)?

quote:
My next question... does anyone have a listing of the stat affecting attacks and how much they affect the stats?

Well, the numbers may be different for g/s than g/r/b/y. Here's what I found on the g/s bdf page:

(-6/+6)0.33 (-5/+5)0.36 (-4/+4)0.43 (-3/+3)0.50 (-2/+2)0.60 (-1/+1)0.75 (0)1.00 (+1/-1)1.33 (+2/-2)1.66 (+3/-3)2.00 (+4/-4)2.33 (+5/-5)2.66 (+6/-6)300

I assume the last number should be 3.00, not 300. This looks much like the numbers we've been using (the +X/-Y is probably like X = the number of meditates, for example, while Y may be the number of tail whips.) If you want to see the numbers we use (the above numbers is probably just for g/s), go to the combat section in the compendium at this page.

------------------
NeoSyrex™
[ NeoSyrex@hotmail.com ]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 04:40 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
HOLY CRAP! That looks like it could be the formula, NeoSyrex!!! I've got a lot of data and I'll try to match it now. Maybe I won't have to do any more testing after all! Do you know how they came up with it?

How long has that Japanese WWW page been there? (and how long with formula)?

An interesting thing is that if you use that formula, there are now THREE spots in the BDF for damage multipliers, instead of two like before. Critical Hits and LightScreen/Reflect can multiply A instead of the other stuff.

That new BDF formula also uses additive damage variance instead of multiplicative, like I thought it should. (In other words, multiply average damage by 1.09 or divide isn't good, it should be add something or subtract something).

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 04:43 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
HEY!! About the stat-affecting attacks in G/S....

When G/S first came out, the FIRST thing I noticed (I told everyone on IRC in #pokemon) was that my Sand-Attack got suckier. I was really sure, but then after playing longer I wasn't so sure anymore. =D But my first impression may have been right after all!!!!!!

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 04:47 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
About the stat increasing abouve 997 thing, it could be. That's weird though, because in my tests the game will allow you to increase your stat as long as it is 998 or lower. If your stat is 999 it'll say "But, nothing happened!" It's weird that the game would still let you increase your stat worthlessly above 997. Oh well. =D

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 04:52 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
Hrm. About the 997 thing, I thought of something else. The game doesn't want to allow any stat under 2. Think about it, in the actual game, the lowest level pokemon you see is 2. I think I tried Gamesharking my stat to 1 or 0 before. I think 0 does something bad (crash game maybe) but I forgot already.

Maybe that 997 + 2 thing is because of that, or maybe it WAS because of that in an earlier beta version of Pokemon, but it got redundant but someone forgot to fix it up later on, since it was not really noticeable.

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 05-01-2000 05:09 PM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
quote:
Originally posted by Porcupine:
I think I tried Gamesharking my stat to 1 or 0 before. I think 0 does something bad (crash game maybe) but I forgot already.

A defending pokémon with 0 Defense or Special would definately crash the game if the formula requires the use of the 0. This is due to the fact that anything divided by 0 is positive infinity. Like that wouldn't crash the game :P. I'm not sure about why the game does the whole 997 + 2 thing, but that it does. It may be difficult to prove, however, if it is just temporarily changed right before the battle damage formula is applied...

------------------
NeoSyrex™
[ NeoSyrex@hotmail.com ]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 05:14 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
YUP, I think that formula is right! It can match up well with ALL my data (including Slash and Sky Attack if CH multiplies Level by 2 instead of Attack)!!!!! YAYYYY!!!!!

Also, I can see why I had SUCH a hard time experimentally matching my data to a formula. In fact that formula looks a lot like what I'd expect. There are MANY places to round and screw up in that formula, more than you'd think. At least 5. For example that 1.5x factor in and of itself rounds and screws stuff up.

In addition that formula predicts something I HAD noticed, but didn't know if it held for all attacks (turns out it does, by this formula) or just a few low damage weak attacks (Fire Spin) that I had noticed it on:

The maximum random damage an attack can possibly do can occur VERY rarely, more rarely than the other possible damage values. This formula says that for ALL attacks, the max possible damage will occur 1/39th of the time, when that Z = 255 ONLY. The other damage values for example might occur 1/10th or 1/2 of the time (for weak attacks). In addition this phenomena also screwed up half of my data because half of them were missing the highest possible damage, and the other half's highest possible damage was 1 damage too low. The minimum damage can also occur extra rarely by this formula, but it's not for all attacks, just some where the math comes out that way.

YAY!!!! DAMAGE FORMULA YAY YAY!!!!!!!!! I dunno if I could ever have come up with that experimentally because of so many places to round. Someone else did it for me yay. =D~~~

Hey, what else is on that TeamPA Japanese WWW page? Do they shed any light on other mysterious in Red/Blue such as Fire Blast, Psychic side-effect rates, etc?

Maybe later on I'll test that formula but I'm pretty sure it's right. First thing I'll do is take 2 L100 pokemons of equal stats, but set their attacks to 1 and defense to 500, and hit each other with a move that they get a 1.5x bonus from. I know from testing before they shoudl do exactly 2 damage each time, but this formula predicts that 1/39th of the time they will do 3 damage. Let's see it! I have confidence it'll show up!

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 07:44 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
Strangely enough, if I remember my test right, I had used 0 Attack on purpose, so that maybe it wouldn't crash. But it crashed anyway. That is what I remember, but it is really likely I remember wrong because it was so long ago. =D

That 997 + 2 bug, it only happens when dealing with large stats right? Like for a regular stat of 240, it wouldn't do any weird +2 crap to it?

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged
NeoSyrex
Farting Nudist
Member # 52

Member Rated:
posted 05-01-2000 07:50 PM      Profile for NeoSyrex   Author's Homepage   Email NeoSyrex   Send New Private Message      Edit/Delete Post  Reply With Quote 
Oh, a couple corrections:

I believe all decimals are truncated after every operation, so Porcupine, the damage for your tests will always be 2, and never reach 3. (somebody check this, I'm not positive)

And what I said about stats going to 997 and 2 is added was wrong. But, the information I found out is even more vital- all damage before the + 2 (before the type match is applied, reading left to right) is reduced to 997 if above 999. I tested this theory by fighting a wild level 165 Chansey with a level 255 Gengar with max Attack. I Screeched Chansey 3 times, and then I used Explosion. Chansey was left with about 1~5% HP. This proves that there is a max damage of 999, because the formula predicted at least about 33402 damage (Chansey's wild maximum is 1049). I then tested it under the exact same conditions, except this time with Pidgey (for a type match), and Chansey was taken down with one shot. Since a level 165 Chansey's minimum HP is 1000, it would be impossible for Pidgey to take out Chansey with one Explosion unless the type match is applied afterwords. I'd imagine the same would be true for type mods and the random factor.

Heh, by the way, while testing this, stat bleeding occured- I was using a Gengar with 909 Attack, and after Screeching Chansey 3 times he couldn't use Swords Dance- that's at least a 90 point increase! One thing's for certain, the increase for stats is a % of lvel or (more likely) the stat that the bleeding is increasing.

------------------
NeoSyrex™
[ NeoSyrex@hotmail.com ]

[This message has been edited by NeoSyrex (edited 05-01-2000).]


From: New Jersey, USA | Registered: Feb 2000  |  IP: Logged
Porcupine
Farting Nudist
Member # 46

Member Rated:
posted 05-01-2000 09:04 PM      Profile for Porcupine   Email Porcupine   Send New Private Message      Edit/Delete Post  Reply With Quote 
It's too late, I'm gonna have to do my 2 damage test tomorrow. =D

Yup I knew exactly how to use that formula. I read it C++ style, with all variables as integers or 8-bit integers. That's why I mentioned that formula rounds (truncates more specifically) in SO many spots (around 5) and that's what makes it difficult to experimentally determine the BDF, in addition to that weird max damage thing.

If you try the final BDF for my test, the first half of the formual is worthless because everything goes to 0 because you are so weak. Then you add 2 damage, then multiply by 1.5, then truncate. That gives you 3 damage so far. And that is the final max possible damage. However, formula says randomness is given by Z/255 with 39 possible values of Z. However, ONLY the value Z = 255 will give a final damage of 3. All other values of Z will truncate down to 2 damage. So that means you get a 1/39th chance of 3 damage in my test, but a 38/39th chance of 2 damage, which is what I have always seen so far. But I need to test for that 3, but I am very sure it'll show up, cause I have seen that weirdness before but wasn't sure how to mathematically describe it.

------------------


From: Honolulu, HI, USA | Registered: Feb 2000  |  IP: Logged


All times are ET (US)  
Post New Topic  New Poll  Post A Reply Close Topic    Move Topic    Delete Topic next oldest topic   next newest topic
Printer-friendly view of this topic
Hop To:


Contact Us | Azure Heights Pokémon Laboratory

© 2000-2016, Maximum Penetration Industries.

Karpe Diem


The views and opinions expressed on this page are strictly those of the author(s). The contents and links have not been reviewed or approved by the University of Miami.