Javascript percentage of winning algorithm












-1















I have a slots machine game HTML5 + Javascript.
I have found the below algoritm on Stackoverflow, but i need another percentage



this.d = Math.random();

if (this.d < 0.3333) {
this.nextSymbols = [
['320', '320', 'jackpot'],
['jackpot', '320', '400'],
['320', '320', 'jackpot'],
];
} else if (this.d < 0.005) {
this.nextSymbols = [
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
];
} else {
this.nextSymbols = [
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
];
}


I need to have:



 1 of 3 spins to be a winning prize 2 

1 of 200 spins wins big prize


Any math expert advice would be much appreciate.



Thanks










share|improve this question




















  • 1





    How is "I have 10 big prizes" relevant for the probability of a single spin?

    – Bergi
    Nov 19 '18 at 22:04






  • 2





    Hint: 1/3 = 0.3333…, 1/200 = 0.005 (compared to 50% = 0.5, 20% = 0.2 in the existing code)

    – Bergi
    Nov 19 '18 at 22:05













  • @Bergi thanks. I figured out

    – PixelArtie
    Nov 19 '18 at 22:21






  • 1





    < means less than. So if (this.d < 0.005) means that the value is less than 0.005. Any value where that is the case is also less than 0.3333. However the if-test for <0.005 is in the else clause of the <0.3333, so nobody will ever win the big prize.

    – Richardissimo
    Nov 19 '18 at 22:39
















-1















I have a slots machine game HTML5 + Javascript.
I have found the below algoritm on Stackoverflow, but i need another percentage



this.d = Math.random();

if (this.d < 0.3333) {
this.nextSymbols = [
['320', '320', 'jackpot'],
['jackpot', '320', '400'],
['320', '320', 'jackpot'],
];
} else if (this.d < 0.005) {
this.nextSymbols = [
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
];
} else {
this.nextSymbols = [
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
];
}


I need to have:



 1 of 3 spins to be a winning prize 2 

1 of 200 spins wins big prize


Any math expert advice would be much appreciate.



Thanks










share|improve this question




















  • 1





    How is "I have 10 big prizes" relevant for the probability of a single spin?

    – Bergi
    Nov 19 '18 at 22:04






  • 2





    Hint: 1/3 = 0.3333…, 1/200 = 0.005 (compared to 50% = 0.5, 20% = 0.2 in the existing code)

    – Bergi
    Nov 19 '18 at 22:05













  • @Bergi thanks. I figured out

    – PixelArtie
    Nov 19 '18 at 22:21






  • 1





    < means less than. So if (this.d < 0.005) means that the value is less than 0.005. Any value where that is the case is also less than 0.3333. However the if-test for <0.005 is in the else clause of the <0.3333, so nobody will ever win the big prize.

    – Richardissimo
    Nov 19 '18 at 22:39














-1












-1








-1








I have a slots machine game HTML5 + Javascript.
I have found the below algoritm on Stackoverflow, but i need another percentage



this.d = Math.random();

if (this.d < 0.3333) {
this.nextSymbols = [
['320', '320', 'jackpot'],
['jackpot', '320', '400'],
['320', '320', 'jackpot'],
];
} else if (this.d < 0.005) {
this.nextSymbols = [
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
];
} else {
this.nextSymbols = [
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
];
}


I need to have:



 1 of 3 spins to be a winning prize 2 

1 of 200 spins wins big prize


Any math expert advice would be much appreciate.



Thanks










share|improve this question
















I have a slots machine game HTML5 + Javascript.
I have found the below algoritm on Stackoverflow, but i need another percentage



this.d = Math.random();

if (this.d < 0.3333) {
this.nextSymbols = [
['320', '320', 'jackpot'],
['jackpot', '320', '400'],
['320', '320', 'jackpot'],
];
} else if (this.d < 0.005) {
this.nextSymbols = [
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
['320', 'jackpot', '400'],
];
} else {
this.nextSymbols = [
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
[Symbol.random(), Symbol.random(), Symbol.random()],
];
}


I need to have:



 1 of 3 spins to be a winning prize 2 

1 of 200 spins wins big prize


Any math expert advice would be much appreciate.



Thanks







javascript algorithm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 22:07







PixelArtie

















asked Nov 19 '18 at 21:59









PixelArtiePixelArtie

43




43








  • 1





    How is "I have 10 big prizes" relevant for the probability of a single spin?

    – Bergi
    Nov 19 '18 at 22:04






  • 2





    Hint: 1/3 = 0.3333…, 1/200 = 0.005 (compared to 50% = 0.5, 20% = 0.2 in the existing code)

    – Bergi
    Nov 19 '18 at 22:05













  • @Bergi thanks. I figured out

    – PixelArtie
    Nov 19 '18 at 22:21






  • 1





    < means less than. So if (this.d < 0.005) means that the value is less than 0.005. Any value where that is the case is also less than 0.3333. However the if-test for <0.005 is in the else clause of the <0.3333, so nobody will ever win the big prize.

    – Richardissimo
    Nov 19 '18 at 22:39














  • 1





    How is "I have 10 big prizes" relevant for the probability of a single spin?

    – Bergi
    Nov 19 '18 at 22:04






  • 2





    Hint: 1/3 = 0.3333…, 1/200 = 0.005 (compared to 50% = 0.5, 20% = 0.2 in the existing code)

    – Bergi
    Nov 19 '18 at 22:05













  • @Bergi thanks. I figured out

    – PixelArtie
    Nov 19 '18 at 22:21






  • 1





    < means less than. So if (this.d < 0.005) means that the value is less than 0.005. Any value where that is the case is also less than 0.3333. However the if-test for <0.005 is in the else clause of the <0.3333, so nobody will ever win the big prize.

    – Richardissimo
    Nov 19 '18 at 22:39








1




1





How is "I have 10 big prizes" relevant for the probability of a single spin?

– Bergi
Nov 19 '18 at 22:04





How is "I have 10 big prizes" relevant for the probability of a single spin?

– Bergi
Nov 19 '18 at 22:04




2




2





Hint: 1/3 = 0.3333…, 1/200 = 0.005 (compared to 50% = 0.5, 20% = 0.2 in the existing code)

– Bergi
Nov 19 '18 at 22:05







Hint: 1/3 = 0.3333…, 1/200 = 0.005 (compared to 50% = 0.5, 20% = 0.2 in the existing code)

– Bergi
Nov 19 '18 at 22:05















@Bergi thanks. I figured out

– PixelArtie
Nov 19 '18 at 22:21





@Bergi thanks. I figured out

– PixelArtie
Nov 19 '18 at 22:21




1




1





< means less than. So if (this.d < 0.005) means that the value is less than 0.005. Any value where that is the case is also less than 0.3333. However the if-test for <0.005 is in the else clause of the <0.3333, so nobody will ever win the big prize.

– Richardissimo
Nov 19 '18 at 22:39





< means less than. So if (this.d < 0.005) means that the value is less than 0.005. Any value where that is the case is also less than 0.3333. However the if-test for <0.005 is in the else clause of the <0.3333, so nobody will ever win the big prize.

– Richardissimo
Nov 19 '18 at 22:39












1 Answer
1






active

oldest

votes


















0














To summarize - as @Bergi and @Richardissimo written in comments.
1 / 3 is 0.(3), but you can just write thid.d < 1/3 interpreter will calculate it for you.
And if you are making else if the second case will never fire. You have to change the order of conditions.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383239%2fjavascript-percentage-of-winning-algorithm%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To summarize - as @Bergi and @Richardissimo written in comments.
    1 / 3 is 0.(3), but you can just write thid.d < 1/3 interpreter will calculate it for you.
    And if you are making else if the second case will never fire. You have to change the order of conditions.






    share|improve this answer




























      0














      To summarize - as @Bergi and @Richardissimo written in comments.
      1 / 3 is 0.(3), but you can just write thid.d < 1/3 interpreter will calculate it for you.
      And if you are making else if the second case will never fire. You have to change the order of conditions.






      share|improve this answer


























        0












        0








        0







        To summarize - as @Bergi and @Richardissimo written in comments.
        1 / 3 is 0.(3), but you can just write thid.d < 1/3 interpreter will calculate it for you.
        And if you are making else if the second case will never fire. You have to change the order of conditions.






        share|improve this answer













        To summarize - as @Bergi and @Richardissimo written in comments.
        1 / 3 is 0.(3), but you can just write thid.d < 1/3 interpreter will calculate it for you.
        And if you are making else if the second case will never fire. You have to change the order of conditions.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 23:25









        KonowyKonowy

        339420




        339420






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383239%2fjavascript-percentage-of-winning-algorithm%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]