Results 1 to 3 of 3

Thread: Is it possible to determine odds of winning with PHP?

  1. #1

    Joined
    Jan 2013
    Posts
    2,113
    Thanks
    1,851
    Thanked
    2,614/827
    DL/UL
    403/1
    Mentioned
    734 times
    Time Online
    120d 8h 12m
    Avg. Time Online
    42m

    Is it possible to determine odds of winning with PHP?

    I mean, I want a set value/range of values to determine if I win or lose in a minigame for example.

    It's for a website me and my friend are making, we need a game that upon clicking will bring another page telling you if you won or not based on odds previously coded for each opponent... the problem is coding the odds... :x

    Anybody care to help? :3

  2. #2
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    Quote Originally Posted by Discord View Post
    I mean, I want a set value/range of values to determine if I win or lose in a minigame for example.

    It's for a website me and my friend are making, we need a game that upon clicking will bring another page telling you if you won or not based on odds previously coded for each opponent... the problem is coding the odds... :x

    Anybody care to help? :3
    If it's a simple true/false, totally random odds:
    PHP Code:

    function rollOdds($winPercent)
    {
        
    $randPercent mt_rand(1100);
        return 
    $randPercent <= $winPercent;
    }

    if(
    rollOdds(50))
    {
        
    $winner $PLAYERS[0];
    }
    else
    {
        
    $winner $PLAYERS[1];

    But I'd recommend something more like this: (you need an account to see links)

  3. The Following User Says Thank You to Zachafer For This Useful Post:

    Ban (11-04-2013)

  4. #3

    Joined
    Jan 2013
    Posts
    2,113
    Thanks
    1,851
    Thanked
    2,614/827
    DL/UL
    403/1
    Mentioned
    734 times
    Time Online
    120d 8h 12m
    Avg. Time Online
    42m
    Quote Originally Posted by Zachafer View Post
    If it's a simple true/false, totally random odds:
    PHP Code:

    function rollOdds($winPercent)
    {
        
    $randPercent mt_rand(1100);
        return 
    $randPercent <= $winPercent;
    }

    if(
    rollOdds(50))
    {
        
    $winner $PLAYERS[0];
    }
    else
    {
        
    $winner $PLAYERS[1];

    But I'd recommend something more like this: (you need an account to see links)
    Yes!
    That link, it's exactly what I was looking for, thanks <3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •