#Match making code why can’t it be this simple ? I’m just starting out coding take it easy

6 messages · Page 1 of 1 (latest)

livid wagon
#

class Player:
def init(self, id, rank, rating):
⁦self.id⁩ = id
self.rank = rank
self.rating = rating

class MatchMaker:
def init(self):
self.players = []
self.ranks = ["Bronze", "Silver", "Gold", "Platinum", "Paragon"]
self.rank_tiers = {
"Bronze": ["Bronze", "Silver"],
"Silver": ["Bronze", "Silver"],
"Gold": ["Gold", "Platinum"],
"Platinum": ["Gold", "Platinum", "Paragon"],
"Paragon": ["Platinum", "Paragon"]
}

def add_player(self, player):
    self.players.append(player)

def find_match(self, player):
    # Filter players with similar rank
    similar_rank_players = [p for p in self.players if p.rank in self.rank_tiers[player.rank]]

    # Sort players by rating in descending order
    similar_rank_players.sort(key=lambda p: p.rating, reverse=True)

    # Find the player with the highest rating and similar rank
    match = similar_rank_players[0] if similar_rank_players else None

    return match
little sky
#

Bro, matchmaking isn't the problem... it's basic math. Try this instead:

if (players.Count == 0) return match = "Play against bots, buddy.";

Also you forgot a crucial line of code! Let me fix it for you:

return match = "out of players";
mellow lotus
#

Omeda, hire this guy

ember herald
#

This would fix the game! Please add!

silent ingot
#

Why do we return the highest rated player?

hidden spoke
#

Omeda can't afford this kind of quality of service...... to pay him doing this kind of work...