Slots Allocation - Team Builder with rules of affinity and anti-affinity

Events happening in the community are now at Drupal community events on www.drupal.org.
mobcdi's picture

Hi Drupal Ireland,

I was hoping the group could lend their collective knowledge of modules and drupal power to point me in the direction of how the following might be accomplished in D7 or higher.

Is it possible to create a team sign up system which can ensure certain conditions are met. The following theoretical game may help the discussion.
Say there is a sport called DrupalBall made up of 6 players with specific positions (A,B,C,D,E) I have 4 teams and I need to get players to sign up to play positions C,D,E but to ensure strong teams I need to add additional logic or more correctly rules of affinity and anti-affinity so say if "Tom" is on team 2 then "Sam" can't be but "John" can

So when the Sam logs in he can see he can't be on Team 1 (Tom already signed up) Team 2 is full so he is left with Team 3 or 4

I'm trying for a quick and dirty solution without custom coding just module and setting configuration so if you know of other web-based systems that can accomplish it I'd welcome hearing that as well.

Comments

seeded players

conorc's picture

Drupalball sounds like a great idea, though kicking the pointy bit of the drop might be sore on your toes ;-)

Someone else might be better able to go into details, but have you tried to seed players using the Weight module, and then set up the Rules module to handle the allocation

https://www.drupal.org/project/weight
https://www.drupal.org/project/rules

Found this searching and maybe it might be useful to compare
http://stackoverflow.com/questions/22959408/algorithm-for-placement-of-3...

Hope it helps

Ah you assumed the game

mobcdi's picture

Ah you assumed the game involved your feet :)

The weight module appears at first glance to weight by a single value where as I (just to awkward) need a bit more control by saying Tom can play in position C,D when he likes but only A & E at certain other times.

Or did you mean weight the teams so the under-populated float to the top?

thresholds

conorc's picture

you're right i did, maybe it's more like dodgeball or team handball? In that case the trailing tip might improve aerodynamics... like half an american football crossed with half a spherical ball, hmmmmm. Will you have this ready in time for DrupalCon LA? Could be big :-)

Anyway, I think i was thinking that there would be a larger pool of players, not all might eventually apply for each game, and as you said, whoever would be playing could be applying to play in an arbitrary order.

Giving each player a weight or a seed, might give you more granular control over the composition of each team. So something like the sum of player weights must fall between a range, and there can't be more than 2 players above or below specified weight thresholds? I'm just thinking aloud, so maybe someone else might be better experienced in this.

Try Rooms, Weight, and

markconroy's picture

Try Rooms, Weight, and Rules.

I have a feeling that you could accomplish this with the Rooms module, coupled with weight and rules.

Rooms is very flexible for booking "things" - not just "rooms". So you could use that approach to book a team, and if a certain player is already booked in that team, then a certain other player (based on weight or something else) cannot not.

And totally off the top of my head, I'd suggest perhaps Organic Groups (not just because it's one of my favourite modules). So, a team could be a group and if Mark is in one group, then Conor couldn't be in it (because Mark and Conor can't get on with each other LOL!). Again, you'd probably need to use Rules here.

And finally, I've a feeling you are not going to get a quick and dirty solution for this; get ready to write some code.

Thanks for the suggestions,

mobcdi's picture

Thanks for the suggestions, rooms looks interesting alright.

Is there a way to implement affinity/repulsion conditions in rules?

Some simple solutions with

paean99's picture

Some simple solutions with the bare minimum modules.

If its a direct affinity between users independent of the teams, you could use an entity reference field. Name it 'repulsion field'. Then the rules just has to check that field with the team users.

For a weighed condition, you might use 2 integer fields. One on the team (team_weight) and the other on the users (player_weight). Than you just have to add the player_weight to team_weight when a player signs up and compares it to a predetermined maximum quantity (which could also be a field on the team if it is different for each team).

taxonomy

conorc's picture

Instead of weight, you could just tag the good and bad players with any number of vocabularies using taxonomy.

And with the Rooms or similar module, limit ability to book different positions by tag, and availability. here's a list of modules similar to Rooms
https://groups.drupal.org/node/89449

I've never used it but the merci one looks like it might merit further investigation.

Best of luck :-)

Ireland

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: