dongzou7134 2013-02-11 19:15
浏览 13
已采纳

PHP游戏公式[关闭]

Basically I'm trying my hand at writing a simple football game in PHP. I'm struggling to think how a formula would work for teams to win games.

Lets take for example a team has 11 players each on the pitch and each player can have a maximum rank of 100 therefore a team would have a maximum of 1100xp to have a maxed out football team.

How could I do a PHP formula to determine which team would win or draw? I was thinking to do percentages for a team to win, but I was unsure how I would add a draw in to the formula.

Any help would be appreciated

  • 写回答

1条回答 默认 最新

  • dream_life5200 2013-02-11 19:22
    关注

    Your question doesn't make sense as are you developing it as an app "Basically I'm trying my hand at writing a simple football game in PHP". If you're trying to do maths with php, like the team with most exp will win, then its fine. If you know the basics of PHP:

    $winner = ($team_1_exp > $team_2_exp ? team1:team2);
    return $winner; 
    

    If Probability is required:

    $t1 = "team 1 exp points";
    $t2 = "team 2 exp points";
    
    $total = $t1 + t2;
    
    $t1 = $t1 / $total * 100; // % amount of chances of winning of team1.
    $t2 = $t2 / $total * 100; // % amount of chances of winning of team2.
    
    
    $winner = ($t1 > $t2 ? team1 : team2);
    echo $winner."has more chances of winning this game"; // The probability which team can win!
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答