RocketBot icon indicating copy to clipboard operation
RocketBot copied to clipboard

Transferring IV's

Open maddhadder90 opened this issue 10 years ago • 20 comments

When using the duplicate transfer does it take IV into account or is it based solely on CP? Is leaveStrongest the only one that takes IV into consideration?

maddhadder90 avatar Jul 24 '16 14:07 maddhadder90

Only CP as far as I know. The IV algorithm isn't implemented.

v7nce avatar Jul 24 '16 15:07 v7nce

It's in there. It's right here https://github.com/DetectiveSquirrel/Pokemon-Go-Rocket-API/pull/32

maddhadder90 avatar Jul 24 '16 17:07 maddhadder90

I don't see these changes in the latest version of the bot. Are you using leaveStrongest? Can you confirm it's implemented? Transferring according to IV is very important for late game.

v7nce avatar Jul 24 '16 17:07 v7nce

I have version 1.2.2.7 It's under Program.cs Line 505-528

public static float Perfect(PokemonData poke) { return ((float)(poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina) / (3.0f * 15.0f)) * 100.0f; }

    private static async Task TransferAllGivenPokemons(Client client, IEnumerable<PokemonData> unwantedPokemons, float keepPerfectPokemonLimit = 95.0f)
    {
        foreach (var pokemon in unwantedPokemons)
        {
            if (Perfect(pokemon) >= keepPerfectPokemonLimit) continue;
            ColoredConsoleWrite(ConsoleColor.White, $"Pokemon {pokemon.PokemonId} with {pokemon.Cp} CP has IV percent less than {keepPerfectPokemonLimit}%");

            if (pokemon.Favorite == 0)
            {
                var transferPokemonResponse = await client.TransferPokemon(pokemon.Id);

                /*
                ReleasePokemonOutProto.Status {
                    UNSET = 0;
                    SUCCESS = 1;
                    POKEMON_DEPLOYED = 2;
                    FAILED = 3;
                    ERROR_POKEMON_IS_EGG = 4;
                }*/

maddhadder90 avatar Jul 24 '16 18:07 maddhadder90

Oh ok I see it. Well to answer your question, no track of any reference to the IV function in the TransferDuplicatePokemon function:

private static async Task TransferDuplicatePokemon(Client client)
        {

            //ColoredConsoleWrite(ConsoleColor.White, $"Check for duplicates");
            var inventory = await client.GetInventory();
            var allpokemons =
                inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
                    .Where(p => p != null && p?.PokemonId > 0);

            var dupes = allpokemons.OrderBy(x => x.Cp).Select((x, i) => new { index = i, value = x })
                .GroupBy(x => x.value.PokemonId)
                .Where(x => x.Skip(1).Any());

            for (var i = 0; i < dupes.Count(); i++)
            {
                for (var j = 0; j < dupes.ElementAt(i).Count() - 1; j++)
                {
                    var dubpokemon = dupes.ElementAt(i).ElementAt(j).value;
                    if (dubpokemon.Favorite == 0)
                    {
                        var transfer = await client.TransferPokemon(dubpokemon.Id);
                        string pokemonName;
                        if (ClientSettings.Language == "german")
                        {
                            string name_english = Convert.ToString(dubpokemon.PokemonId);
                            var request = (HttpWebRequest)WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" + name_english);
                            var response = (HttpWebResponse)request.GetResponse();
                            pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
                        }
                        else
                            pokemonName = Convert.ToString(dubpokemon.PokemonId);
                        ColoredConsoleWrite(ConsoleColor.DarkGreen,
                            $"Transferred {pokemonName} with {dubpokemon.Cp} CP (Highest is {dupes.ElementAt(i).Last().value.Cp})");

                    }
                }
            }
        }

I'm not sure to understand correctly how this leaveStrongest option works.

            var unwantedPokemonTypes = new[]
            {
                PokemonId.Pidgey,
                PokemonId.Rattata,
                PokemonId.Weedle,
                PokemonId.Zubat,
                PokemonId.Caterpie,
                PokemonId.Pidgeotto,
                PokemonId.NidoranFemale,
                PokemonId.Paras,
                PokemonId.Venonat,
                PokemonId.Psyduck,
                PokemonId.Poliwag,
                PokemonId.Slowpoke,
                PokemonId.Drowzee,
                PokemonId.Gastly,
                PokemonId.Goldeen,
                PokemonId.Staryu,
                PokemonId.Magikarp,
                PokemonId.Clefairy,
                PokemonId.Eevee,
                PokemonId.Tentacool,
                PokemonId.Dratini,
                PokemonId.Ekans,
                PokemonId.Jynx,
                PokemonId.Lickitung,
                PokemonId.Spearow,
                PokemonId.NidoranFemale,
                PokemonId.NidoranMale
            };

This means that every single Pokemon will be transferred, except the highest IV's from this list? So it will throw away a Gyarados 2000CP but it will keep a Magikarp with a high IV?

v7nce avatar Jul 24 '16 18:07 v7nce

would be nice to have the IV implemented on teh duplicated mode!! if someone could do it everybody would be very thankfull :D

NicolasGB avatar Jul 24 '16 19:07 NicolasGB

Yeah I'm not too sure. When I run the program I see when I catch a pokemon and it'll say that it wasn't above the 95℅ and it will trade it. I don't know if it takes into account the ones that I manually caught.

maddhadder90 avatar Jul 24 '16 21:07 maddhadder90

@NicolasGB I've done it for myself. Here's the modified method (this will transfer lower IV's pokemon if you have more than one of the same kind, ignoring CP)

private async Task TransferDuplicatePokemon(Client client)
        {
            var inventory = await client.GetInventory();
            var allpokemons =
                inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
                    .Where(p => p != null && p?.PokemonId > 0);

            // Modified for IV logic instead of CP logic
            var dupes = allpokemons.OrderBy(x => (x.IndividualAttack + Math.Sqrt(x.IndividualDefense) +
                Math.Sqrt(x.IndividualStamina)) / (15 + 2 * Math.Sqrt(15))).Select((x, i) => new { index = i, value = x })
                .GroupBy(x => x.value.PokemonId)
                .Where(x => x.Skip(1).Any());

            for (var i = 0; i < dupes.Count(); i++)
            {
                for (var j = 0; j < dupes.ElementAt(i).Count() - 1; j++)
                {
                    var dubpokemon = dupes.ElementAt(i).ElementAt(j).value;
                    if (dubpokemon.Favorite == 0)
                    {
                        // IV Logic instead of CP logic, show IV's and percentage on screen
                        var ivPercentage = ((dubpokemon.IndividualAttack + Math.Sqrt(dubpokemon.IndividualDefense) +
                                               Math.Sqrt(dubpokemon.IndividualStamina)) / (15 + 2 * Math.Sqrt(15))) * 100;

                        var ivPercentageMax = ((dupes.ElementAt(i).Last().value.IndividualAttack + Math.Sqrt(dupes.ElementAt(i).Last().value.IndividualDefense) +
                                               Math.Sqrt(dupes.ElementAt(i).Last().value.IndividualStamina)) / (15 + 2 * Math.Sqrt(15))) * 100;

                        if (ivPercentage.Equals(ivPercentageMax)) continue;

                        var transfer = await client.TransferPokemon(dubpokemon.Id);
                        ColoredConsoleWrite(Color.DarkGreen,
                            $"Transferred {dubpokemon.PokemonId} [{dubpokemon.Cp} CP] [{Math.Round(Convert.ToDecimal(ivPercentage), 2)}% IV ({dubpokemon.IndividualAttack}/{dubpokemon.IndividualDefense}/{dubpokemon.IndividualStamina})] (Highest is {dupes.ElementAt(i).Last().value.Cp} CP, {Math.Round(Convert.ToDecimal(ivPercentageMax), 2)}% IV ({dupes.ElementAt(i).Last().value.IndividualAttack}/{dupes.ElementAt(i).Last().value.IndividualDefense}/{dupes.ElementAt(i).Last().value.IndividualStamina}))");
                    }
                }
            }
        }

There are two formulas for calculating IV perfection. The most known is (A + D + S) / 15

But I'm using [A + sqrt(D) + sqrt(S)] / [ 15 + 2*sqrt(15)]

Since is how the game actually works. Source

Here's what you see on screen Here's what you see on screen

The code is for Window version. For console version, just replace ColoredConsoleWrite(Color.DarkGreen, ... with ColoredConsoleWrite(ConsoleColor.DarkGreen, ...

If someone wants it to work with the first formula instead of the corrected one, just let me know.

EDIT: I'll send a pull request with a new transfer method based on IV's in a couple of hours (I'm kinda busy right now), but if it's accepted, you will not have to mess with code, just configuration variables :).

barrenechea avatar Jul 25 '16 03:07 barrenechea

Maybe I'm blind but how do you access the windowed version of the program?
Sebastian by changing the formula it doesn't break any other functions? And would it be able to tell the IV of pokemon you manually caught?

maddhadder90 avatar Jul 25 '16 04:07 maddhadder90

@maddhadder90 After you caught a pokemon, it will compare it against other pokemons of the same kind, and will transfer the lower IV you have (ignoring CP).

If you open the game on your phone and you caught some pokemons, the app will instantly transfer the lower IV pokemons, and you will be left with only your higher IV pokemon of that kind.

Nope, it doesn't break any function. I'm using it since two days ago and almost all my pokemons are 80%+ now :P (I hate my 98% Magikarp with 50CP, but hoping to find a 100% Magikarp with higher CP haha).

Oh, and for the Window Form version of the app, you must set the PokemonGo.RocketAPI.Window as Startup project (right click->Set as StartUp Project) and run the app.

barrenechea avatar Jul 25 '16 04:07 barrenechea

Ok thanks @SebastianBar . One last question where would I paste this code at? And what would I have to delete?

maddhadder90 avatar Jul 25 '16 10:07 maddhadder90

@SebastianBar thanks for the answer, where do i have to add your code in order to work? and do i have to make any more changes?

NicolasGB avatar Jul 25 '16 11:07 NicolasGB

okey guys, just change the "duplicate" function code for the @SebastianBar code and it will be great! thx man apreciate a lo!

NicolasGB avatar Jul 25 '16 12:07 NicolasGB

I must've done something wrong, I used @SebastianBar 's code bit but I don't see any IV information in my window at all. Bot works of course, but no IVs displayed.

Nzash avatar Jul 25 '16 13:07 Nzash

@Nzash it's in duplicate mode. You have to be in that mode for @SebastianBar code to work

mrlongttvn avatar Jul 25 '16 14:07 mrlongttvn

@SebastianBar Do I delete the current duplicate transfer code and replace it with yours?

maddhadder90 avatar Jul 25 '16 19:07 maddhadder90

@maddhadder90 Exactly :)

barrenechea avatar Jul 25 '16 23:07 barrenechea

When I tried that @SebastianBar I kept getting errors.

maddhadder90 avatar Jul 25 '16 23:07 maddhadder90

@maddhadder90 I think because is not "private async Task TransferDuplicatePokemon(Client client)" but should be "private static async Task TransferDuplicatePokemon(Client client)" I changed like this and it worked for the console version :)

KRgh avatar Jul 25 '16 23:07 KRgh

This seemed to fix it @KRgh thanks. I'm also using the console version.

maddhadder90 avatar Jul 26 '16 00:07 maddhadder90