Kemik Posted December 30, 2007 Share Posted December 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/83761-tournament-system-psuedo-code/ Share on other sites More sharing options...
jos. Posted December 30, 2007 Share Posted December 30, 2007 try using the shuffle($user_id_array) function... Jos. Quote Link to comment https://forums.phpfreaks.com/topic/83761-tournament-system-psuedo-code/#findComment-426175 Share on other sites More sharing options...
Kemik Posted December 30, 2007 Author Share Posted December 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/83761-tournament-system-psuedo-code/#findComment-426181 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.