如何计算每个球员的最长连胜纪录

发布于 2024-11-26 05:10:20 字数 269 浏览 2 评论 0原文

我有一个名为 TournamentXPlayer 的 mySQL 扑克数据库,其中包含一个名为 TournamentXPlayerID 的主索引以及 TournamentID、PlayerID、Finish 和 Payout。 我一直在寻找方法来计算每个玩家获得现金奖励的最长连续记录。后来我想包括其他一些东西,比如球员的个人连胜记录(并非所有球员都参加每场比赛,但有些球员在参加比赛时表现得非常好)、最长的连胜记录,甚至最长的连胜记录。然而目前我根本不知道如何最好地计算连胜。 这可以做到吗?

谢谢 特里

I have a mySQL poker database called TournamentXPlayer that contains a primary index called TournamentXPlayerID and TournamentID, PlayerID, Finish, and Payout.
I've been looking at ways to count each players longest streak of finishing with a cash prize. Later I would like to include other things like a players personal streak (Not all player play every game but some do really well when they do play), longest winning streaks, and even longest streak without winning a prize. However at the moment I can't work out how best to count a streak at all.
Can this be done?

Thanks
Terry

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

肤浅与狂妄 2024-12-03 05:10:20

我假设tournamentID 会自动递增,因此它提供了数据的时间顺序。

这是组内排序的经典问题。为此,您需要考虑以下变量:

mysql> set @p_id:=-1; set @streak:=0;
mysql> select playerID,max(streak) from (select playerID,@streak:=if(Payout=0,0,if(@p_id=playerID,@streak+1,1)) streak, @p_id:=playerID from (select playerID,TournamentID,Payout from table order by 1,2) a) a group by 1;

在本例中,etap 为:

  • 按玩家排序,然后
  • 为每个玩家进行锦标赛:
    • 如果有支付,则增加 streak 变量
    • 如果没有则设置为 0
  • 如果玩家更换, streak 设置为 0。 p_id!=玩家ID。 p_id封装了最后考虑的玩家的信息。

I assumed that tournamentID is automatically incremented so it provides the chronology of the data.

This is the classic problem of the order by inside a group. For that purpose, you need to consider variables such as :

mysql> set @p_id:=-1; set @streak:=0;
mysql> select playerID,max(streak) from (select playerID,@streak:=if(Payout=0,0,if(@p_id=playerID,@streak+1,1)) streak, @p_id:=playerID from (select playerID,TournamentID,Payout from table order by 1,2) a) a group by 1;

In this example, the etaps are :

  • sort by player then tournament
  • for each player :
    • increment the streak variable if there was a payout
    • set to 0 if not
  • set streak to 0 if there was a change of player. p_id!=playerID. p_id encapsuled the information of the last player considered.
×纯※雪 2024-12-03 05:10:20

当您要计算连胜数时,您需要知道玩家完成锦标赛的时间。否则,如果玩家进行多桌比赛,您将得到错误的结果,因为他可能在一场超级筹码锦标赛中玩了 15 个小时并获得了奖金,同时注册并退出了多个超级筹码锦标赛。您可以按 ID(相对于开始时间)对锦标赛进行排序,但如果您没有时间,当玩家完成时,您将永远不会得到正确的结果。

如果我们假设玩家根本不参加多桌比赛,则使用以下算法:

  1. 读取一名玩家的所有锦标赛。
  2. 按锦标赛 ID 排序
  3. 搜索最长连胜
  4. 输出最长连胜

留下评论,如果您有问题,我将编辑/完成我的答案

When You are going to calculate streaks, You need to know the time, when a player finished the tournament. Otherwise, You will get wrong results if a players is multitabling, because, he might be playing one superstack tourney for 15 hours and finish in the money and in the meanwhile register and drop out of multiple hyperturbo tourneys. You can sort the tournaments by ID-s (relative to starting time), but You'll never get the right result, if You don't have the time, when player finished.

If we assume, that players don't multitable at all, then use the following algorithm:

  1. Read all one player's tournaments.
  2. Sort them by Tournament ID
  3. Search for longest streak
  4. Output the longest streak

Leave a comment, if You got questions, I will edit/complete my answer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文