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 关于无人驾驶的航向角
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退