예제 #1
0
def test_pokemon_capture_gen2():
    """Test simulation of capture Pokémons of generation II"""
    pokemon = Pokemon(PokemonType.Electabuzz)
    catch_arr = []
    HPmax = pokemon.HP
    hp_arr = [i for i in range(1, HPmax)]

    # Simulate
    for i in range(1, HPmax):
        catch_sum = 0
        pokemon.HPcurrent = i

        for j in range(1000):
            a = capture_simulation_gen2(pokemon, BallType.MasterBall)
            catch_sum += a

        catch_arr.append(catch_sum/10)


    fig, ax = plt.subplots()
    fig.suptitle('Pokemon gen2 simulation', fontsize=17, fontweight='bold')
    ax.set_title(pokemon.name, fontsize=16)
    ax.plot(hp_arr, catch_arr, label="Catch Probability", color='m')
    ax.set_xlabel('Current HP', fontsize=15)
    ax.set_ylabel('Ratio', fontsize=15)
    legend = ax.legend()

    plt.show()
예제 #2
0
def test_pokemon_capture_gen1():
    """Test simulation of capturing Pokémons of catch algorithm generation 1"""
    pokemon    = Pokemon(PokemonType.Pikachu, State.asleep)
    HPmax      = pokemon.HP
    catch_arr  = []
    shakes_arr = np.zeros(HPmax-1)
    hp_arr     = [i for i in range(1,HPmax)]

    # Simulate
    for i in range(1,HPmax):

        catch_sum = 0
        shake_sum = 0
        pokemon.HPcurrent = i

        for j in range(400):
            a, b = capture_simulation_gen1(BallType.UltraBall, pokemon)
            catch_sum += float(a/4.0)

        catch_arr.append(catch_sum)

    fig, ax = plt.subplots()
    fig.suptitle('Pokemon gen1 simulation', fontsize=17, fontweight='bold')
    ax.set_title(pokemon.name, fontsize=16)
    ax.plot(hp_arr, catch_arr, label="Catch Probability")
    ax.set_xlabel('Current HP', fontsize=15)
    ax.set_ylabel('Ratio', fontsize=15)
    legend = ax.legend()

    plt.show()