Your Trainer ID and Secret ID is generated by the seed that is randomly generated when you start the game for the very first time. It is not defined by your name or gender. There is no possible way to change your IDs without restarting completely or using a save editor or cheating device.
In Generations III, VI and V, your Trainer ID and Secret ID is used in conujunction with a Pokemon's personality to determine shininess. There is a 1/8192 chance of getting a shiny Pokemon.
First, your Trainer ID and Secret ID are XOR-ed (Exclusive OR - one or the other but not both, Ex. 11010111 xor 01101010 = 10111101). That result is saved as variable E.
Then, the encountered Pokemon's two personality values are XOR-ed, with the result saved to variable F.
Finally, E and F are XOR-ed one last time, then checked to see if the final result is less than 8. If so, your encountered Pokemon is shiny.
Here is an example on Bulbapedia, which includes all integer to binary translations.
As of Sun & Moon, the post below is no longer accurate. I will leave it below unedited for reference purposes.
New in Sun & Moon:
- 81 new Pokemon with their own National Pokedex number
- 18 new regional variants (Alolan Forms) of Gen I Pokemon (Rattata, Raticate, Raichu, Sandshrew, Sandslash, Vulpix, Ninetales, Diglett, Dugtrio, Meowth, Persian, Geodude, Graveler, Golem, Grimer, Muk, Exeggutor, Marowak)
- 11 new additional storable Formes (1 Zygarde, 3 Oricorio, 1 Lycanroc, 6 Minior)
- 17 new additional Item-induced Formes (Silvally)
- 6 new Battle-activated Formes (1 Zygarde, 1 Wishiwashi, 1 Minior, 1 Mimikyu, 1 Solgaleo, 1 Lunala)
- All of these in a shiny version, of which 18 are unobtainable (4 Tapus, Cosmog, Cosmoem, Solgaleo, Lunala, 7 Ultra Beasts, Necrozma, Magearna, Marshadow)
This puts the new totals at 1990 unique storable sprites (1789+(81+18+10)*2-18 +1 Zygarde), 2018 including unobtainable ones and 2133 total sprites (1889+(81+18+10)*2-18+(17+5)*2 -1 Solgaleo -1 Lunala +2 Zygarde).
After quite some research time and thanks to Jerry's help, I was able to compile a complete list. Here are the numbers involved. As per the question, Mega Evolutions are excluded. Also excluded is Spiky-Eared Pichu, which only existed in Gen IV and cannot be transferred to newer generations, as well as Spinda, which has an absurd amount of technically different sprites (one per 32-bit PID).
- There are currently 721 Pokémon on the National Pokédex, including Diancie, Hoopa and Volcanion.
- Of these, 91 females have minor gender differences and 7 females have major differences (Hippopotas, Hippowdon, Unfezant, Frillish, Jellicent, Pyroar and Meowstick).
- The number of additional storable (permanent) alternate formes is 81 (27 Unown, 3 Deoxys, 2 Burmy, 2 Wormadam, 1 Shellos, 1 Gastrodon, 1 Basculin, 3 Deerling, 3 Sawsbuck, 1 Keldeo, 19 Vivillon, 4 Flabébé, 4 Floette, 4 Florges, 3 Pumpkaboo, 3 Gourgeist).
- There are 34 additional Item-activated alternate formes (5 Rotom, 1 Giratina, 1 Shaymin, 17 Arceus, 1 Tornadus, 1 Thundurus, 1 Landorus, 2 Kyurem, 4 Genesect, 1 Hoopa).
- You can transform Pokémon into 7 additional Battle-based formes (3 Castform, 1 Cherrim, 1 Darmanitan, 1 Meloetta, 1 Aegislash).
- Then there are 10 additional special formes (9 Furfrou, 1 Xerneas).
- And lastly, all of these exist in a shiny version, except for 8 non-obtainable shinies and 3 alternate formes (Celebi, Victini, Keldeo, Resolute Keldeo, Meloetta, Poké Ball Vivillon, Fancy Vivillon, Zygarde, Diancie, Hoopa, Volcanion).
This means that the total number of storable unique sprites is 1789 ( (721+91+7+81)*2 -8 -1 Keldeo -2 Vivillon, interestingly exactly 1800 including currently unobtainable ones).
The total number of sprites including battle-induced, item-induced and special forms is 1889 (1789 + (34+7+10)*2 -1 Meloetta -1 Hoopa).
Best Answer
Yes, but it's unlikely you've ever met them.
You might be familiar with the Trainer Hill found in Pokémon Emerald, but it's a little known fact that connecting the e-Reader to a Japanese version of Pokémon Emerald lets you add trainers to the Hill based on which cards you've scanned. Two of these trainers, Pokéfan Francisco and Pokéfan Kimberly, can, depending on whether their cards were scanned first or second on a floor, battle using 3 different Unown each.
For the international release of Pokémon Emerald, Pokéfan Francisco and Pokéfan Kimberly can be fought on the 4th floor of the Trainer Hill's Variety Mode, where they will, again, both have a team of 3 Unown.
In Pokémon Crystal, Unown can be randomly fought in the Battle Tower's level 10 challenge, but it's never fought again in any other similar attraction in later games.