1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Ranking system based on a number?

Discussion in 'Development' started by Lowkey, May 16, 2017.

  1. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    yes i agreed, it's kinda a cheap way to separate players enough so using foreach wont take forever
     
  2. falk

    falk Slime Poggit Reviewer

    Messages:
    75
    GitHub:
    falkirks
    If you always want to pick the closest one, you just put players in an array with EloPlayer objects (just encapsulate the player and the elo value). Then when you want to get the opponent you do an order n operation to search. Then you do two constant time operations to find the neighbours (if they exist). Then you find which neighbour is closer. So I would say that is pretty decent. Everytime a player joins or quits, you would run a sort on the array (which could be async if you really felt like it).

    Also, if a player performs a kill or dies, you would need to perform a small update to the array, which shouldn't be too expensive. But if you wanted to you could just ignore this, because it's not like they are going to get 100000 kills in one session and completely change their ranking, they will still be in the same ballpark.

    This can be dropped to constant time, by being able to retrieve the rank of a player in constant time. There are multiple ways to accomplish this.
     
    Last edited: May 17, 2017
    0x15f likes this.
  3. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Very simple, calculate an ELO for each player, I'll put my system below. Then when you are matching players just do this:
    PHP:
    $max 100;//players MUST be within 100 ELO of each other
    if(max($elo1$elo2) - min($elo1$elo2) > $max)
    {
        return;
    //or break/continue if its a loop
    }
    My ELO calculating system:
    PHP:
    class Elo
    {
        private 
    $wins;
        private 
    $losses;
        private 
    $elo;

        public function 
    __construct($wins$losses)
        {
            
    $this->wins $wins;
            
    $this->losses $losses;

            
    $this->calculate();
        }

        public function 
    calculate()
        {
            
    $wins $this->wins;
            
    $losses $this->losses;

            
    $this->elo 1200 + (($wins $losses) * 25);
        }

        public function 
    getElo()
        {
            return 
    $this->elo;
        }
    }
    ^^ Thats not the whole class, the rest is private (someone is gonna nag me for using a class for a simple function)
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i dont think that's truely ELO mathematically speaking,
    most mathematical things just flew over my head while reading wiki but the elo is deducted off opponent and missing a K factor
    i feel like it's more sudo ELO
     
  5. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Code:
    I wrote that for this thread, I have a much longer ELO system that this threads owner probs wouldn't understand.
     
  6. Lowkey

    Lowkey Slime

    Messages:
    94
    I wish too see the longer Elo system :).
     
  7. falk

    falk Slime Poggit Reviewer

    Messages:
    75
    GitHub:
    falkirks
    What do you mean by "Code:"?
     
  8. Thouv

    Thouv Slime

    Messages:
    84
    GitHub:
    adeynes
    What I would do is put the players in a group based on their ELO
    For example 0-100 would be group 1, 100-200 group 2, 200-300 group 3, etc etc.
    Then you just get all the players who are in the same group as the player and are online and pick a random one to match him/her up with the player
     
  9. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Whoopsies, I was typing the code for what you said. I had to read it a few times before I fully got it. Forgot to paste it :p, don't have it anymore (didn't save it) :facepalm:.
     
    jasonwynn10 likes this.
  10. RyanIsBack

    RyanIsBack Spider

    Messages:
    10
    So easy:
    $rank = $this->config->get($pl.'-rank'); // EXEMPLE return number
    if($rank == 0) $rank = 'Joueur';
    if($rank == 1) $rank = 'Admin';

    echo 'You rank is: '.$rank;
     
  11. Lowkey

    Lowkey Slime

    Messages:
    94
    This is not what I'm looking for. Read up. Are you stupid?
     
  12. RyanIsBack

    RyanIsBack Spider

    Messages:
    10
    Ahhh i have look for a Ranks systems, sorry !
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.