pkedpker Posted July 4, 2009 Share Posted July 4, 2009 I'm trying to calculate the odds of you losing or winning a match. To get started a team can have up to 6 fighters from level 1 to level 100 per fighter.. Now I want to calculate which team has a better odds of winning based on level and count of fighters per team as someone could enter with a team of 1 fighter.. which is level 100 and another person enters 6 fighters in his team all level 10.. it's obvious that 1 fighter will win.. but how can I get the percentage here? ATM when sql query is returning row.. I add up every fighters Level's together and the amount of fighters goes up by 1 everytime.. I do this for my team and opponent team and here is where I calculate the percentage of myself winning <?php $myLvls = 0; $myAmount = 0; $oppLvls = 0; $oppAmount = 0; //MYSQL Query.... etc while($r=mysql_fetch_array($res)) { $myLvls += $r["lvl"]; $myAmount += 1; } while($r=mysql_fetch_array($res)) { $oppLvls += $r["lvl"]; $oppAmount += 1; } if(($myLvls > 0 && $myAmount > 0) && ($oppLvls > 0 && $oppAmount > 0)) { $totalStrength = ($myAmount > $oppAmount ? 10 : (($myAmount / $oppAmount) * 10)); $totalStrength += ($myLvls > $oppLvls ? 100 : (($myLvls / $oppLvls) * 100)); $totalStrength = ($totalStrength == 200) ? 100 : $totalStrength; $totalStrength = number_format($totalStrength, 2); } ?> The Lvl's calculation is pretty good but when I add up that with amount of fighters percentage it's soo high it passes the 100% mark when its obvious you will lose or have a nearly impossible chance of winning.. I was having ideas like the amount the percentage for amount of fighters has to be calculated by a base of 6 which will make sense like.. like 1/6 = 16.67% 2/6 = 33.33% 3/6 = 50% 4/6 = 66.67% 5/6 = 83.33% 6/6 = 100% but of course thats only the amount of players I have now that percentage has to be lowered by the level total.. I guess since the highest level possible is 600 (100 per fighter if they are maximum level) then I have to use 600 somehow with whatever It's way to confusing for me.. can someone lend me a hand. 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.