When you begin the game, roll a D20 (20 Sided Die). The number you roll will determine the number of Pokémon you may have at a time (in the party and Box), and 1, 2, and 3 are rerolls.
Whenever you finish a battle, you must get a random number generator (min. 1 and max. 99999). If the number found matches the ID of any Pokémon used in the battle, it cannot be used for the next two gyms.
Whenever you defeat a gym leader, you must assign a number to each of their Pokémon. Then, you must use a random number generator to find a Pokémon out of those (min. 1 and max. = X, where X is the total number of Pokémon the leader has). Whichever Pokemon is found, you cannot catch any more of it. (You can catch its evolutions.) Ex.: If you just beat Brock in FireRed or LeafGreen, you make the max. 2. If you assign 1 to Geodude and 2 to Onix, and you roll a 1, you can no longer catch any more Geodudes (You can still catch Graveler or Golem).
You may only trade Pokémon to evolve them (i.e. Machamp, Gengar, Graveler) if you sacrifice 1 Pokémon.