Jump to content

Tournament System - psuedo code


Kemik

Recommended Posts

Hello all,

 

I’m building a tournament system and I’m going through the planning stages, specifically making the psuedo code.

 

I’m trying to think how I would take a list of players, add a number of passes if there are spaces left (total spaces - number of users signed up) and then randomise who each user plays against.

 

The system is using user_ids to identify users.

 

So, on click of “Make fixtures” the following occurs:

 

1. Get $maxusers and $nosignedup.

2. $passes = $nosignedup - $maxusers.

3. Get array of users ($users [user_id])

4. A loop to add a user with the user_id of -1 for each pass to $users array.

 

Here’s where I’m stuck. I need to randomise the user_id in the array and then some how make fixtures for the tournament. E.g. if the tournament has max users of 8 it will make 4 fixtures.

 

Any ideas would be appreciated.

Link to comment
Share on other sites

Oh thanks! Never heard of that function.

 

Should be easy enough to make the fixtures from there.

 

5. Use shuffle function.

6. $nofixtures = $maxusers / 2

7. Loop for $nofixtures create a new fixture with incremental $fixture_id, $userone = incremental user, $usertwo = next user in the array.

 

I'm going to do a bit more searching for the loops so I don't have much experience with loops and getting incremental information so feel free to post suggestions.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.