How would I implement this?

Talk about game designs and what goes behind designing games.
Post Reply
Genaga
Posts: 86
Joined: Fri Dec 11, 2009 7:05 pm

How would I implement this?

Post by Genaga »

The rate of Pokémon encounter is determined from a simple mathematical formula:
1 in (187.5 / ( x )) per step

Let x equal the a value which determines how rare the Pokémon is. The higher the encounter rate, the more common the Pokémon is.

Encounter-rate table
Encounter Type Encounter Rate
Very Common 10
Common 8.5
Semi-Rare 6.75
Rare 3.33
Very Rare 1.25

But I can't figure out how i would implement this into a game, anyone got an idea on how its done?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: How would I implement this?

Post by Jackolantern »

Honestly, you already have it all outlined here, but it will be a bit easier if you change your formula a bit. Instead of having the variable in your formula, just make a simple random roll and then check the results (not your specific numbers, but you can easily change them):

Code: Select all

//generate a random number between 1 and 1200
$chance = rand(1, 1200);

//check to the random number for results
if ($chance < 100) {
    pullVeryRare();
} else if ($chance < 200) {
    pullRare();
} else if ($chance < 300) {
    pullSemiRare();
} else if ($chance < 500) {
    pullCommon();
} else if ($chance < 800) {
    pullVeryCommon();
} else {
    //Nothing happens. No pokemon pulled
}
Then you can either have pokemon in separate tables in your database and pull from whichever table is called for, or you can just have rarity stored in one master pokemon table and use a query like:

Code: Select all

SELECT * FROM pokemon WHERE rarity = "verycommon" AND level >= 10 AND level <= 20 LIMIT 1
Of course you would have to calculate the correct levels and use variable, and adjust it any other ways you need to.
The indelible lord of tl;dr
Genaga
Posts: 86
Joined: Fri Dec 11, 2009 7:05 pm

Re: How would I implement this?

Post by Genaga »

Thanks ;D That probably is the best way to go about it, I couldn't think at all -.-'

I'll try get it done now :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: How would I implement this?

Post by hallsofvallhalla »

you could go a bit deeper to make it even harder to get a rare pokemon..you will find the random system is not as "random" as you might like

Code: Select all

$chance = rand(1, 5);
$secondchance(1,100);

switch ($chance) {
case "1":
         if($secondchance < 10){echo "found very-rare";}
        else {echo " found common";}
        break;   
case "2":
         if($secondchance < 20){echo "found rare";}
        else {echo " found common";}
        break;   
 case "3":
         if($secondchance < 30){echo "found semi-rare";}
        else {echo " found very common";}
        break;
case "4":
        if($secondchance < 50){echo "found common";}
        else {echo " found very common";}
        break;
case "5":
        echo "found very common";
        break;
Post Reply

Return to “Game Design”