Skip to content

Instantly share code, notes, and snippets.

@dwbapst
Last active June 29, 2021 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwbapst/f145b3d795c82bda87de419890ff7a78 to your computer and use it in GitHub Desktop.
Save dwbapst/f145b3d795c82bda87de419890ff7a78 to your computer and use it in GitHub Desktop.
Calculating The Chances for Catching Perfect IV Pokemon in Pokemon GO using Brute Force Simulations of Catching and Purification of Shadow Pokemonn
nruns <- 1000000 # one million runs

probability of getting a perfect wild pokemon without weather boosting

minIV <- 0
maxIV <- 15

perfects <- 0
for(i in 1:nruns){
    pokemon <- sample(x = minIV:maxIV, size = 3, replace = TRUE)
    if(all(pokemon == c(15, 15, 15))){
        perfects <- perfects + 1
        }
    }
perfects/nruns

## [1] 0.00024

probability of getting a perfect wild pokemon with weather boosting

minIV <- 4
maxIV <- 15

perfects <- 0
for(i in 1:nruns){
    pokemon <- sample(x = minIV:maxIV, size = 3, replace = TRUE)
    if(all(pokemon == c(15, 15, 15))){
        perfects <- perfects + 1
        }
    }
perfects/nruns

## [1] 0.000535

probability of getting a perfect purified former-shadow pokemon (no weather boosting)

minIV <- 1
maxIV <- 15

purify <- function(x){
    min(x+2, 15)
    }

perfects <- 0
for(i in 1:nruns){
    shadowPokemon <- sample(x = minIV:maxIV, size = 3, replace = TRUE)
    pokemon <- purify(shadowPokemon)
    if(all(pokemon == c(15, 15, 15))){
        perfects <- perfects + 1
        }
    }
perfects/nruns

## [1] 0.007866

probability of getting a perfect purified former-shadow pokemon (Weather boosted)

minIV <- 4
maxIV <- 15

purify <- function(x){
    min(x+2, 15)
    }

perfects <- 0
for(i in 1:nruns){
    shadowPokemon <- sample(x = minIV:maxIV, size = 3, replace = TRUE)
    pokemon <- purify(shadowPokemon)
    if(all(pokemon == c(15, 15, 15))){
        perfects <- perfects + 1
        }
    }
perfects/nruns

## [1] 0.015625

probability of getting a perfect from a lucky trade

minIV <- 12
maxIV <- 15

perfects <- 0
for(i in 1:nruns){
    pokemon <- sample(x = minIV:maxIV, size = 3, replace = TRUE)
    if(all(pokemon == c(15, 15, 15))){
        perfects <- perfects + 1
        }
    }
perfects/nruns

## [1] 0.015623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment