Dismiss Notice
Wynncraft, the Minecraft MMORPG. Play it now on your Minecraft client at (IP): play.wynncraft.com. No mods required! Click here for more info...

Guide [java] Wynncraft Horse Breeding Calculator

Discussion in 'Wynncraft' started by RojoM, Apr 21, 2017.

Thread Status:
Not open for further replies.
  1. RojoM

    RojoM Well-Known Adventurer VIP+

    Messages:
    88
    Likes Received:
    50
    Trophy Points:
    49
    Minecraft:
    Hey there! I just made a forum account! Hai! I'm RojoM! <insert cheesy 5 paragraph long introduction here>

    Anyway, I coded a wynncraft horse simulator in Java using the probability values on the wiki (up-tiering a horse is a 20% chance, same-tiering is 50%, down-tiering is 30%). What it does is it simulates the process of buying brown horses when needed, breeding same-tiered horses together, and repeating that process over and over until it reaches a certain objective number of X-tier horse. This allows me to brute force the question of "How much LE does it take to make each type of horse?", running an extremely high number of trials to get an accurate average cost. To do this, I ran trials in which I had the simulator attempt to make 1,000,000 of each type of horse (separately from each other, of course) while keeping track of how many brown horses it bought. At the end, it would print the results, including the cost. With 10,000,000 horses as an objective, there was an extremely low cost difference between trials.
    Tl;dr - Made a java program that simulates the buying and breeding of horses to reach an objective amount of tier-X horses. Brute-forced (10,000,000 as the objective number) the average cost of each tier of horse.

    The results -

    In order to breed 10000000 tier 1 horses, 59981900 brown horses had to be bought.
    This means an average of 5.99819 brown horses were needed per horse, or 143.95656 EB per horse.
    This is equal to 2.24932125 LE

    In order to breed 10000000 tier 2 horses, 435046601 brown horses had to be bought.
    This means an average of 43.5046601 brown horses were needed per horse, or 1044.1118424 EB per horse.
    This is equal to 16.3142475375 LE

    In order to breed 10000000 tier 3 horses, 3173297785 brown horses had to be bought.
    This means an average of 317.3297785 brown horses were needed per horse, or 7615.914684 EB per horse.
    This is equal to 118.9986669375 LE

    Now, obviously, this is very different from the calculations of @Yuno F Gasai's on their thread (can't link it because new forum account. Can someone link it below?). There is one difference between what we did, however. His post calculated the value of the horse by subtracting the EB values of the other horses that were bred. Instead, in my program, I was breeding the other "spare" horses together, like a normal wynncraft player would do while breeding horses. I feel his calculations oversimplified that aspect by simply giving those "spare" horses an EB value even though normally those would be bred as well. At the same time, I don't blame him. Trying to calculate probability while having the entire complexity of breeding the spare horses is a headache, to say the least. I've debugged my code and made sure a variety of things are not skewing my calculations, and I can't find any bugs on my side. I'll post it below to let you guys look at it and check for bugs.

    Aaaaaand yep there was a bug. Calculations have been fixed and now they are within tolerance of Yuno's values.

    Tl;dr -
    Made a java program that simulates horse breeding. Got different (higher) costs for each tier of horse compared to @Yuno F Gasai 's calculations. There is a fundemental difference between how we calculated the value, with him simplifying the prescence of "spare" horses to an EB value rather than breeding them, which might be why. My code is in the below post.

    Feel free to check for bugs or oversights and please tell me if you find any!
    Rojo
    PS. Refering to Yuno as a "him" because that's what his forum profile says.
    PPS. I don't expect this to change the economy at all. I just wanted to post this because I feel it's an interesting finding.
    ________________________________


    Alrighty, here's the code! It's been commented in order to make it more understandable.
    Code:
    public class WynnCraftHorseBreedingSimulator {
        public static int[] breedHorses(int tier, int[] horses) { //Method that breeds the horses. Uses Java.Math's RNG to generate randomness. Returns new array of horses
            double RNG = Math.random();
            horses[tier] -= 2;
            if (RNG < 0.2) { //For a 20% chance, add one up-tiered horse
                horses[tier + 1] += 1;
            }
            if (RNG >= 0.2 & RNG < 0.7) { //For a 50% chance, add one same-tiered horse
                horses[tier] += 1;
            }
            if (RNG >= 0.7) { //For a 30% chance, add one down-tiered horse. If the horse is already tier 0, add another tier 0 horse.
                if (tier == 0) {
                    horses[tier] += 1;
                } else {
                horses[tier - 1] += 1;
                }
            }
            return horses; //Return the new arrangement of horses
        }
        public static void main(String[] args) {
            //Initializing variables. Array horses is an array with a value of {brown, black, white, chestnut}.
            int[] horses = {0,0,0,0};
            //Keeps track of how many horses have been bought. THis integer is known for going higher than int's maximum, so I changed it to a long to make sure if won't go negative.
            long brownHorsesBought = 0;
            //Which horse is the objective? (0 for brown, 1 for black, 2 for chestnut, 3 for white)
            int targetHorse = 1;
            //How many of this horse do you want?
            int objectiveNum = 10000000;
            while (horses[targetHorse] < objectiveNum) { //While the number of horses you have is below the objective, keep breeding
                for (int i = targetHorse - 1; i >= 0; i--) { //Goes from the objective tier down, breeding horses using the above method
                    if (horses[i] >= 2) {
                        horses = breedHorses(i, horses);
                    }
                }
                if (horses[0] < 2) { //If there are less than 2 brown horses, buy horses and update the brownHorsesBought int accordingly
                    brownHorsesBought += 2 - horses[0];
                    horses[0] = 2;
                }
            }
            //Now that the program is done, write the results into console. First line is number of horses need. Second is averaging. Third is price in LE and EB.
            System.out.println("In order to breed " + objectiveNum + " tier " + targetHorse + " horses, " + brownHorsesBought + " brown horses had to be bought.");
            System.out.println("This means an average of " + (double) brownHorsesBought / objectiveNum + " brown horses were needed per horse, or " + (double) 24 * brownHorsesBought / objectiveNum + " EB per horse.");
            System.out.println("This is equal to " + (double) 24 * brownHorsesBought / (objectiveNum * 64) + " LE");
        }
    }
    
    
    EDIT: Bug fixed at 4:53pmPST on 4-21. Improper conditions for when to make a horse of the same tier (essentially giving it a 0% chance of happening). Code and calculations replaced with new ones. Thanks @motoki1!
     
    Last edited: Apr 21, 2017
    Luckygamerdx, Ryuu, Quilin and 16 others like this.
  2. Pokextreme

    Pokextreme Avos Air Archer HERO

    Messages:
    5,335
    Likes Received:
    13,637
    Trophy Points:
    215
    Minecraft:
    @Yuno F Gasai kek
     
  3. Meroboter

    Meroboter pie

    Messages:
    570
    Likes Received:
    1,709
    Trophy Points:
    89
    Minecraft:
    this is like the first thread ever that contains an actual code
     
    Power :3, MagicMike, RogP and 6 others like this.
  4. BMW

    BMW Well-Known Adventurer

    Messages:
    444
    Likes Received:
    290
    Trophy Points:
    70
    Minecraft:
    I was looking at the code improvising a smart and educated face, trying to avoid reading the comments to the lines, but then remember I only could code plugins for bukkit following the guides on youtube, and it's kinda sad.
    Good job, also thank you for the code, I probably have a personal use for it, opensource ftw
     
    RojoM likes this.
  5. RedstoneLogic

    RedstoneLogic Has a neato shop haha please buy my stuff HERO

    Messages:
    471
    Likes Received:
    548
    Trophy Points:
    83
    Minecraft:
    Here I was thinking I was the only forums member that knew java.
     
    MagicMike, TwageTomato and RojoM like this.
  6. Kaelan~

    Kaelan~ RIP VIP

    Messages:
    2,369
    Likes Received:
    4,022
    Trophy Points:
    207
    Guild:
    Minecraft:
    Rip dreams
     
  7. flip

    flip Chef HERO

    Messages:
    3,748
    Likes Received:
    8,333
    Trophy Points:
    215
    Minecraft:
    For anyone who can't speak maths

    TL;DR White horse is a f*cking lot
     
  8. Villageacules

    Villageacules Famous Adventurer HERO

    Messages:
    675
    Likes Received:
    3,150
    Trophy Points:
    157
    Minecraft:
    lol I made my white horse with 5 LE and a few smart trades
     
    MagicMike, Thom_Com, Thunder and 3 others like this.
  9. RojoM

    RojoM Well-Known Adventurer VIP+

    Messages:
    88
    Likes Received:
    50
    Trophy Points:
    49
    Minecraft:
    Ayyy you aren't alone! :D
     
    RedstoneLogic likes this.
  10. motoki1

    motoki1 The Damage Calculation Scientist HERO

    Messages:
    3,344
    Likes Received:
    4,494
    Trophy Points:
    215
    Guild:
    Minecraft:
    Shouldn't this part be:
    if(RNG >= 0.2 & RNG < 0.7)
    ?

    Other than that, your code is beautiful :3
     
    Last edited: Apr 21, 2017
    RojoM and Villageacules like this.
  11. RojoM

    RojoM Well-Known Adventurer VIP+

    Messages:
    88
    Likes Received:
    50
    Trophy Points:
    49
    Minecraft:
    Yep. There's the bug!
    *cries* I checked that method so many times whyyyyyy *facepalm*
    Recalculating values now. Thanks!
     
    Villageacules likes this.
  12. TempleOfLegends

    TempleOfLegends Emma CHAMPION

    Messages:
    3,505
    Likes Received:
    4,730
    Trophy Points:
    215
    Minecraft:
    i didnt
     
  13. Saya

    Saya you win at uwynn HERO

    Messages:
    2,930
    Likes Received:
    6,872
    Trophy Points:
    207
    Guild:
    Minecraft:
    well den
    I thought of doing this but was too lazy :P

    great job
     
    RojoM likes this.
  14. TwageTomato

    TwageTomato Coder | Like-Giver | Tomato | Musician CHAMPION

    Messages:
    1,018
    Likes Received:
    881
    Trophy Points:
    128
    Minecraft:
    Wait. This is Java though. You need two && signs in order to use logical-AND. A single & is a bitwise-AND.

    Idk it may not make a difference in this case
     
    MagicMike and JackyKit like this.
  15. JackyKit

    JackyKit Any gamebreaking glitch founder, fixed by Jumla HERO

    Messages:
    2,918
    Likes Received:
    2,671
    Trophy Points:
    147
    Guild:
    Minecraft:
    is it just that thinks that the // explanation is too excessive
     
  16. Yuno F Gasai

    Yuno F Gasai Forum God, FW

    Messages:
    13,439
    Likes Received:
    28,735
    Trophy Points:
    227
    Guild:
    Minecraft:
    oh boy what a way to start the morning
    https://forums.wynncraft.com/threads/horses-breeding-prices.90224/ there ya go

    @Kepler_17c @Szei @YuuuuSama did something similar to you with a program.

    tier 2*
    I got 2.25le on my thread

    I got 16.3125le on my thread

    I got 118.96875le on my thread

    as I actually calculated the prices instead of averaging the prices of a lot of breeding operations my prices are more accurate

    we did the same thing, the only difference is that I didnt have a breeding program, the subtracted prices on my thread act as the breed again phase.

    refer to me however you like
     
  17. RicochetfromtheD

    RicochetfromtheD 赵二

    Messages:
    1,039
    Likes Received:
    1,111
    Trophy Points:
    128
    Minecraft:
    Good job fam.
    Now release the api for further open source wynncraft horse breeding computation engine development
     
  18. motoki1

    motoki1 The Damage Calculation Scientist HERO

    Messages:
    3,344
    Likes Received:
    4,494
    Trophy Points:
    215
    Guild:
    Minecraft:
    I heard & and && works the same.
     
  19. RojoM

    RojoM Well-Known Adventurer VIP+

    Messages:
    88
    Likes Received:
    50
    Trophy Points:
    49
    Minecraft:
    In this context, both work in the same manner.
    ________________________________
    Yeah, once I found the bug and corrected it our prices were extremely close. I greyed out the text about how our prices conflicted and bolded the part about the bug and how our prices were within tolerance. So yeah. My program now confirms your work. :D
    ________________________________
    Try having a better PhD :3
     
    Last edited: Apr 22, 2017
  20. Yuno F Gasai

    Yuno F Gasai Forum God, FW

    Messages:
    13,439
    Likes Received:
    28,735
    Trophy Points:
    227
    Guild:
    Minecraft:
    well, you gave me a reason to revive my thread.
    thanks!
     
Thread Status:
Not open for further replies.