Jump to content

Shuffle array based on ELO rating


Staggan

Recommended Posts

Hello

I am looking for some help....

 

I am trying to shuffle an array based on an ELO rating as part of a tournament system....

 

I currently select the teams taking part and create an array which is currently ordered by their team ID... but this can result in tournaments where the competitors in each round are always the same

 

Instead I would to order the array by the teams ELO which is a numerical rating from 0 upwards

 

 

What I would like to do is as follows:

 

At the start of each round split the array into 2...  so one new array contains teams with higher ELOs and another with the lower

 

Then randomize each array

 

Then add the arrays back together taking one element from each of the two arrays at a time...

 

Ending up with something like...

 

Array 1 element 1

Array 2 element 1

Array 1 element 2

Array 2 element 2

 

and so on...

 

I also need it to work with an odd number of teams to start

 

With the final array my system then creates the tournament games and rounds etc....

 

I have no idea where to start.. so any suggestions would be greatly appreciated

 

Thanks

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/282776-shuffle-array-based-on-elo-rating/
Share on other sites

I almost have this working now...

 

But how do I combine my two final, shuffled arrays back into a single array without one just being tagged on the end of the other..

 

This is what I want to do:

 

Array1  =  1,3,5,7

Array2 = 2,4,6,8

 

finalArray = 1,2,3,4,5,6,7,8

 

 

So my merge takes 1 element from each array at a time when merging...

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.