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. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    At first I did not trust @Yuno F Gasai 's calculation either. But thinking about it some time I finally understood the way it worked.
    In my eyes this direct probability calculation is one of the best ways and gives you the result trying out would yield to performing infinite breeds.
    At that time I started working on the wiki, too, and decided to put the values there: https://wiki.wynncraft.com/index.php?title=Horses#Breeding
    Btw here are my breeding counts:
    I did not choose a number but a timer of 1h for each tier and put all results in a text file.
    If you are interested in the data, I will be happy to share it.
     
    Yuno F Gasai likes this.
  2. TwageTomato

    TwageTomato Coder | Like-Giver | Tomato | Musician CHAMPION

    Messages:
    1,018
    Likes Received:
    881
    Trophy Points:
    128
    Minecraft:
    Eh, double && conducts Boolean logic (alongside ! and || ). Boolean logic is, of course, comparing the intersection of true and false statements. When this operation encounters anything but Boolean variables, it treats all non-zero values as true.

    On the other hand, single & conducts a bitwise operation (alongside ~, ^, and | ). Bitwise operations look directly into the individual bits (10010011) and compare them one-by-one. These 4 symbols are much more useful for certain operations, and can be used for things like checking if a given input character is uppercase, lowercase, or a printable digit. They can also change the bits to return a new character.

    However, in this instance, they end up having the same effect. If anyone would like a more in depth explanation and thus an even longer wall of text, let me know. I don't want to type it all out if no one cares to read it.
     
    motoki1 likes this.
  3. motoki1

    motoki1 The Damage Calculation Scientist HERO

    Messages:
    3,344
    Likes Received:
    4,494
    Trophy Points:
    215
    Guild:
    Minecraft:
    Thanks, your explanation cleared up.
    I was trying to say & and && works the same in this context, well sorry, I'm not professional on coding. xD
     
    TwageTomato likes this.
  4. YuuuuSama

    YuuuuSama King of the Trade HERO

    Messages:
    439
    Likes Received:
    197
    Trophy Points:
    70
    Guild:
    Minecraft:
    Java? Eww.
    I have my belief in Standard ML now.
     
  5. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:

    The & and && are different in their strength of binding (called precedence):

    Code:
    public class Ands {
        public static void main(String[] args) {
            boolean a = true;
            boolean b = false;
            boolean c = false;
          
            boolean B0 = a || b && c; // true
            boolean B1 = a || b & c; // true
            boolean B2 = a | b && c; // false
            boolean B3 = a | b & c; // true
          
            System.out.println(B0);
            System.out.println(B1);
            System.out.println(B2);
            System.out.println(B3);
        }
    }
    You would expect the AND to bind stronger than the OR and all results being the same.
    But check the third one: Single signs bind stronger so you get >>> true | false && false > true && false > false

    There is another aspect, too:
    Code:
    public class Ands {
        public static void main(String[] args) {
            
            System.out.println("Calc a");
            boolean a = false && f();
            
            System.out.println("Calc b");
            boolean b = false & f();
            
            System.out.println(a);
            System.out.println(b);
        }
        
        private static boolean f() {
            System.out.println("Hi I'm f().");
            return true; // actually not important ;)
        }
    }
    
    The output of this code is:
    Code:
    Calc a
    Calc b
    Hi I'm f().
    false
    false
    
    Also my compiler already warned me at f() behind the && to have detected dead code (code that will never get executed).
    This is caused by the && operator that does not care about the second one if the first already is false.
    The & operator instead calculates everything, first and second argument.
    Put aside that calling calculative functions in if-clauses and similar is bad style:
    It is always better (except bad style code) to use the && not only to have the optical difference between bit-ops and booleans but also to avoid longer calculation. Imagine an easy argument like function a() comparing two booleans and a difficult function b() doing some longer working stuff but also ending up with a boolean you need to be calculated. ANDing those in order b() && a() will always do the huge task. While a() && b() will only do task b() when necessary (when a() returns true).

    I know it is a lot but the topic is quite complicated and I did not know about this until I had programming at university (second semester starting next week)...
     
    TwageTomato likes this.
  6. Yuno F Gasai

    Yuno F Gasai Forum God, FW

    Messages:
    13,439
    Likes Received:
    28,735
    Trophy Points:
    227
    Guild:
    Minecraft:
    I know I'm head of the translation project but I have no idea what you are talking about
     
    TwageTomato likes this.
  7. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    What is the translation project and what is it what you do not understand?
     
  8. Yuno F Gasai

    Yuno F Gasai Forum God, FW

    Messages:
    13,439
    Likes Received:
    28,735
    Trophy Points:
    227
    Guild:
    Minecraft:
    We translate the quests in wynncraft to different languages.
    I don't speak code
     
    JackyKit likes this.
  9. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    1. Cool project! :) Please link if there is a thread. What languages are you (the team) already working on and what do you still need?
    2. For those who do not speak code:

    There are different operator signs used to link variables. They can be compared with more specific mathematical functions (like +, -, *, /, ...). The signs that where discussed here are && and &. These are so called logic operators:
    && -> used to link booleans (a boolean is a value of type 'truth': true/false)
    & -> can have the same use as && with different side effects
    & -> normally used for bit-operations (it applies the AND-function on every bit separately)
    Examples are:
    Code:
    false && false >>> false
    false && true >>> false
    true && false >>> false
    true && true >>> true
    both booleans (b1 AND b2) have to be true to result in true
    
    Try it with something similar that you are familiar with:
    Replace false with 0 and true with 1. Then use the * (times) operation.

    The AND on bits can be shown on just one link (two numbers of four binary digits):
    Code:
    0011 AND 0101 >>> 0001
    The values are the same like in the example columns above.
    
    The core of the discussion was about the differences of the two operators && and &. My part was adding the information about the side effects.
    Importand for this to understand is that different operators bind stronger than others. Just like in mathematics:
    Brackets > powers> times/divide> plus/minus
    The same applies for logic operators:
    Brackets () > NOT > XOR > AND > OR
    This means that these two formulas are exactly the same in result and calculation order:
    T AND F OR F XOR NOT T = ( ( T AND F ) OR ( F XOR ( NOT T ) ) )
    The calculation would be:
    ((T AND F) OR (F XOR (NOT T)))
    = ((true && false) || (false ^ (!true)))
    = ((false) || (false ^ (false)))
    = (false || (false ^ false))
    = false || false
    = false

    A short explanation for what the functions do:
    NOT -> inverts the value of the following boolean (false > true ||| true > false)
    XOR -> is true if only one of the booleans is true
    AND -> is true if both booleans are true
    OR -> is true if at least one boolean is true

    The way these functions bind their neighbor values is called precedence. This is the way programmers describe the order to perform calculations in.


    Going deeper into details the other thing I mentioned was the way how double operators (&& ||) are different from single sign operators (& |). It is their way of checking their related values. So double signed are lazy and predict what will come out. This means that for && it is enough when the first boolean is false (AND with a false argument can never return true) as well as a true is enough for || return true (there is only a single true necessary). Single sign operators &, |, ^ treat this in a different way: They always check both arguments though it might not be necessary (the last note is true for & and |). You might wonder why there is no double version of ^ like ^^. This is because the XOR requires by its definition to check both arguments while & and | do not. Try it yourself: Do you know that only one argument is true when checking only one and ignoring the other?



    And another long post. I really am sorry and hope you forgive me. It really is a lot to explain...
    Are there any questions left that I did not take care of in my bomb of text?
     
    Yuno F Gasai likes this.
  10. TwageTomato

    TwageTomato Coder | Like-Giver | Tomato | Musician CHAMPION

    Messages:
    1,018
    Likes Received:
    881
    Trophy Points:
    128
    Minecraft:
    Well. That was more than even I would've have taken the time to write, so thanks.
     
  11. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    I somehow like explaining and helping others. And practice writing in English, what is not my mother tongue (hint to @Yuno F Gasai ;) do you need someone for German in your project?), is also good ;)
    So it is win win for you and me.
     
    Yuno F Gasai and TwageTomato like this.
  12. TwageTomato

    TwageTomato Coder | Like-Giver | Tomato | Musician CHAMPION

    Messages:
    1,018
    Likes Received:
    881
    Trophy Points:
    128
    Minecraft:
    I must say that you've gotten a pretty good grip on it. I was offered a job in a writing center and even I can't find anything noticeably wrong with what you wrote. You're definitely one of the more advanced non-native English speakers.
     
  13. Yuno F Gasai

    Yuno F Gasai Forum God, FW

    Messages:
    13,439
    Likes Received:
    28,735
    Trophy Points:
    227
    Guild:
    Minecraft:
  14. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    Thank you, it means a lot to getting a compliment from native speakers!

    @Yuno F Gasai Thank you for the link :)
     
    Yuno F Gasai likes this.
  15. Aya

    Aya Very Serious Gensokyo Journalist

    Messages:
    5,151
    Likes Received:
    7,905
    Trophy Points:
    215
    Minecraft:
    coding seems hurtful
     
  16. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    Well it can get hurtful.
    When you do everything right on first attempt, it is fine. But when there is any logical error, the problems begin...
    In most situations you find the error quickly but if you do not, you have to do debugging (step by step analyzing) or rewriting the code.
     
    TwageTomato likes this.
  17. RojoM

    RojoM Well-Known Adventurer VIP+

    Messages:
    88
    Likes Received:
    50
    Trophy Points:
    49
    Minecraft:
    Nah it's funnnnnnnn
     
    Kepler_17c likes this.
  18. Kepler_17c

    Kepler_17c Well-Known Adventurer CHAMPION

    Messages:
    169
    Likes Received:
    47
    Trophy Points:
    55
    Minecraft:
    Yea, but bugs can destroy it all ;D
     
Thread Status:
Not open for further replies.