Monkuar Posted January 29, 2012 Share Posted January 29, 2012 $card1 = rand(1,3); $card2 = rand(1,3); /// check money win //////// if($card1 == "1" && $card2 == "1" ){ echo "You won 100$?"; exit; mysql_query("UPDATE card SET money='$win_money' WHERE name='$name'"); } My code works wonderfully prob tho how can I show the odds of winning out of 100 to my suer? Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 29, 2012 Share Posted January 29, 2012 google found me this http://gwydir.demon.co.uk/jo/probability/calcdice.htm#cond1 and thats on dice, but i figured dice are 6 and yours are 3, so i came up with 1 in 6, as each one has a 1 in 3 chance 'm not to good on odd calculating but the link might help a bit Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted January 29, 2012 Share Posted January 29, 2012 It's 1 in 9. Basic statistics have nothing to do with PHP. Also, this code has an exit() call BEFORE the mysql_query, that query will never run. There's also a random closing curly brace. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2012 Share Posted January 29, 2012 If you have 3 picks from a pool of 36 numbers, and none of the numbers can repeat, the chances are 36*(36-1)*(36-2), or 1 in 42840. How to calculate the chances if the order of the numbers picked is required to match the order of the numbers drawn, I don't know. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted January 29, 2012 Share Posted January 29, 2012 Pika.......what? He has two numbers, 1-3 each. And he wants to know the odds of getting a 1,1. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2012 Share Posted January 29, 2012 Oh yeah, I kind of glossed over the code, thinking it was the same code from the other thread, with 3 non-repeating numbers from a pool of 36. I are sorry : ( Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted January 29, 2012 Share Posted January 29, 2012 Ok, at least you're not crazy. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2012 Share Posted January 29, 2012 Oh, that doesn't mean I'm not crazy. Quote Link to comment Share on other sites More sharing options...
Monkuar Posted January 30, 2012 Author Share Posted January 30, 2012 Im still confused $card1 = rand(1,4); $card2 = rand(1,4); if ($ibforums->input['id'] == "1"){ if($card1 == "1" && $card2 == "1"){ if my stuff is 1 in 4 chances and it both has to equal the same "1" that would be 25% divided by 2 which is 12.5% of winning right? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted January 30, 2012 Share Posted January 30, 2012 Again, basic statistics have nothing to do with PHP. You want to study basic probability. The probability of the first number being 1 is 1/4. The probability of the second number being 1 is also 1/4. You multiply the odds together to get your answer: 1/4 x 1/4 = 1/16, or 6.25% Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 30, 2012 Share Posted January 30, 2012 This should allow you to dynamically determine the odds based upon a max number. $max_num = 4; $card1 = rand(1, $max_num); $card2 = rand(1, $max_num); $odds = pow((1/$max_num), 2); //2 is the number of 'cards' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.