产生“团队”的算法被称为“团队”。基于数字技能值 [英] Algorithm that creates "teams" based on a numeric skill value

查看:89
本文介绍了产生“团队”的算法被称为“团队”。基于数字技能值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个有助于管理飞盘帽子比赛的应用程序。人们的想法是报名参加帽子比赛。他们注册时,向我们提供介于1到6之间的数字值,代表他们的技能水平。

I am building an application that helps manage frisbee "hat tournaments". The idea is people sign up for this "hat tournament". When they sign up, the provide us with a numeric value between 1 and 6 which represents their skill level.

目前,我们正在收集大量签约人员,并根据每个玩家的技能水平手动尝试从中创建团队。我想,我可以通过创建一种算法来实现这一点的自动化,该算法将团队尽可能平均地分开。

Currently, we are taking this huge list of people who signed up, and manually trying to create teams out of this based on the skill levels of each player. I figured, I could automate this by creating an algorithm that splits up the teams as evenly as possible.

唯一输入该数据的是玩家数组,所需的团队数量。一般来说,我们要看的是120个玩家和8个团队。

The only data feeding into this is the array of "players" and a desired "number of teams". Generally speaking we are looking at 120 players and 8 teams.

我目前的思维过程是基本上为每个团队分配一个连续的得分。此跑步分数是所有分配的球员技能水平的总和。我遍历每个技能级别。一旦进入技能水平循环,我就会经历几轮选秀。

My current thought process is to basically have a running "score" for each team. This running score is the total of all assigned players skill levels. I loop through each skill level. I go through rounds of picks once inside skill level loop. The order of the picks is recalculated each round based on the running score of a team.

这实际上可以很好地完成工作,但并不完美。例如,我的样本数据数组中有5点的范围。我可以很容易地手动交换球员,使团队之间的差异不超过1分。.问题是通过编程实现。

This actually works fairly well, but its not perfect. For example, I had a range of 5 pts in my sample data array. I could very easily, manually swap players around and make the discrepancy no more then 1 pt between teams.. the problem is getting that done programatically.

这是我的代码,因此远: http://pastebin.com/LAi42Brq

Here is my code thus far: http://pastebin.com/LAi42Brq

数据摘要如下:

[2] => Array
    (
        [user__id] => 181
        [user__first_name] => Stephen
        [user__skill_level] => 5
    )

[3] => Array
    (
        [user__id] => 182
        [user__first_name] => Phil
        [user__skill_level] => 6
    )

有人能想到一种更好,更容易,更有效的方法吗?

Can anyone think of a better, easier, more efficient way to do this? Many thanks in advance!!

推荐答案

我想你使事情变得太复杂了。如果您有T队,请根据他们的技能水平对他们进行排序。选择顶级的T球员作为球队的队长。然后,从队长1开始,每个队长依次选择他想要加入的队员。

I think you're making things too complicated. If you have T teams, sort your players according to their skill level. Choose the top T players to be captains of the teams. Then, starting with captain 1, each captain in turn chooses the player (s)he wants on the team. This will probably be the person at the top of the list of unchosen players.

此算法已在操场上发挥了作用(我敢说是在加利福尼亚的飞盘领域)。并会产生比任何更复杂的伪统计方法都公平的结果。

This algorithm has worked in playgrounds (and, I dare say on the frisbee fields of California) for aeons and will produce results as 'fair' as any more complicated pseudo-statistical method.

这篇关于产生“团队”的算法被称为“团队”。基于数字技能值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆