• Be sure to join the discussion on our discord at: Discord.gg/serebii
  • If you're still waiting for the e-mail, be sure to check your junk/spam e-mail folders

Formula questions

Status
Not open for further replies.

ekkoper

Member
Hi!
I'm writing a PHP script for a pokemon game and I would like it to be as perfect as possible resambling the original games. That's why I'm continuously looking for formulae. Some things will be very simple, but then I just don't know how it is calculated, but sometimes there are advanced formulae needed.
I hope some of you can help me out with both of these questions.

Thanks!
Eduard


My first question is how is the order of attacking in battles determined concerning your pokemon VS an enemy. Is it just the SPEED stat which must be higher or is there a random (of specified) number involved?

My next question is about the strategy the enemy uses, where is it based on? Is it random or is it a (very) complicated formula?
 
Last edited:

TogeticTheRuler

Well-Known Member
Usually in-game trainers are dumb as a rock so no complicated thoughts in their head ^ ^
As for your 1st question,that is the entire purpose of speed,not a random number<_<
If 2 pokemons speeeds are the same,its 50 chance of one being the 1st
 

Slim

Crazy Trainer
The attack priority is:
5: Helping Hand
4: Magic Coat, Snatch
3: Protect, Detect, Endure, Follow Me
1: Quick Attack, Mach Punch, Extremespeed, Fake Out
0: All other attacks
-1: Vital Throw
-3: Focus Punch
-4: Revenge
-5: Counter, Mirror Coat
-6: Whirlwind, Roar

Attacks with the same priority, the faster pokemon goes first.

I'm not sure how the AI is, most of the time it is random. But it seems Gym leaders and the E4 have some strategy, or at least know what's going on.

As far as other formulas, I've found a bunch at The Ultimate Pokemon Center, Bulbapedia, and the not-so-forever Pokemon Forever
 

Mudskipper

The Earthquaker
If 2 pokemons speeeds are the same,its 50 chance of one being the 1st

In addition to that, If Pokemon A has the same Speed as Pokemon B, there is a fifty percent chance that either will attack first, however every turn the order will switch, causing each Pokemon to attack twice in a row except for the initial attack.
 

ekkoper

Member
I have a new question!
I was wondering how IV's are given to a pokemon.
I know that it is some kind of a random number between 1 and 31, but I really would like to know what the random-formula is for this number.
Is it known?

Thanks!
 

ekkoper

Member
I'm using a normal distribution now, so that the mean numbers (13-18) are more common than the extremes.

Thanks anyway
 

Slim

Crazy Trainer
what I would imagine is a number is created 0-65535 (or some other binary-friendly number) and then divided by 32. Take the remainder to get your random number.

Since there's really no such thing as a random number "formula," in computing it's called psudo-random. Typically it will use the computer's clock to give a seed to a random number generator, which is basically a look-up table someone made.
 

ekkoper

Member
what I would imagine is a number is created 0-65535 (or some other binary-friendly number) and then divided by 32. Take the remainder to get your random number.

Since there's really no such thing as a random number "formula," in computing it's called psudo-random. Typically it will use the computer's clock to give a seed to a random number generator, which is basically a look-up table someone made.

Hi,
I appreciate your response, but I doubt if it will really makes a difference to my own approach.
Now I'm using a normal distribution formula where each number between 0 and 31 has it chance of occurence (0, 1 and 2 has a 1% chance, together with 29, 30 and 31). All these occurences are put into an array (0, 1, 2, 29, 30 and 31 are all put in once, the 2%-chances are put in twice, etcetera) so I have an array of about 100 items. Then a random item is picked out of this array and that item, that number is provided to the stat of a pokemon.

Dividing a number takes randomizing too, if you want not always have the same number divided by the same other number.. And the PHP-randomizing is pretty good. Ah well, good enough.

Thanks anyway
Eduard
 

Slim

Crazy Trainer
All except that in Pokemon, the chances of it being 15 is equally as likely as it being 0, or 5, or 31 or any other number in between. From what I understand you are saying, you're making it so the inner numbers are more common than the outer numbers, which is not the case.
 

ekkoper

Member
Well, I read somewhere that the inner numbers appear more often than the lower and higher ones. That's why I looked for a formula for it, but if it's just a random number between 0 and 31, that's a lot easier!
 

ekkoper

Member
I have an new question, and it may be hard to answer, but I ask it anyway..

I'm putting all the pokemon in a databasetable, and I want to fill in their experience-gaining-formula. I know that there are a few formula used in the game: (found on serebii.net)
Erratic
Fast
Medium-Fast
Medium-Slow
Slow
Fluctuating

My question is: Is it known which pokemon uses which formula?
I found one list, but it was for older pokemon games and used only 4 (or 5) formulae and only for 251 pokemon.

Could anyone help me out with this?

I found a list on http://web.archive.org/web/20050308110302/pokefor.greenchu.de/meowth346/gba/pokemon/
thanks anyway :)
 
Last edited:

Whompithian

Dynamo Trainer
Ultimate Pokemon Center has some guides that cover the type of information you're loodking for:

http://upc.pkmn.co.uk/games/rs/guides/

It's current through the third generation, too. Also, if you want a database of all the Pokemon, MetalKid compiled a nice one for his Program:

http://www.metalkid.org/Pokemon/Download.aspx

You'll need Excell 2000 or later (or the ability to convert) in order to access the database outside of the Program. But, you should check out the Program, as well, to get some ideas for your project.
 

ekkoper

Member
Hi,
I'm back programming and having plenty of questions!

The first one is:
How is it determined if your pokemon can flee or not from a wild battle?

Is it by level, or just a random number, or what?

Thank you,
Eduard
 

masterzam

Yeah, I'm a rockstar
Though I'm not an expert, I have observed some (unproven) patterns related to fleeing.

1. level, as in the lower level you are compared to the wild pokemon, the less chance.

2. speed, as in the lower speed stat you are compared to the wild pokemon, the less chance.

As in, a level 3 rattata would have slim chances to run away from, say a level 30 growlithe.

And I've noticed my slow pokemon, for instance, graveler, have a hard time running from golbats!

That's my unprofessional input.
 

Slim

Crazy Trainer
The Ultimate Pokemon Center has a page on how Pokemon run away. Note that this guide is in the Gold and Silver section, but I can imagine it being the same for the Advanced generation also.

if your Pokemon's speed is greater or equal to the opponent's, escape is successful. Otherwise, use the following formula:

X = int(Pokemon's Speed*32)/(int(Foe's Speed/4)%255) + (30*# of Run attempts)

if (int(D/4)%255) = 0, escape is successful. (note that otherwise a divide by zero error occurs.

Then, a random number 0-255 is chosen, and if this random number is less than or equal to X, escape is successful.

And you probably already know, but for anyone else,
int() means remove the decimal portion,
and % means divide and take the remainder.
 

TRJessie579

Obsessive Beader/Mod
You're welcome to make a new thread for a new question, but do not post in threads that are over a month old.

-Closed
 
Status
Not open for further replies.
Top