Sobes.tech
Senior

Formalization of matchmaking system requirements: how to search for a match, what to do if no opponent is found, how to validate moves, is a timer needed, how to update ratings, is a game history needed, what to do in case of disconnect?

sobes.tech AI

Answer from AI

For matchmaking systems, it is important to formalize the following aspects:

  1. Matchmaking:

    • Use a waiting queue with filters based on rating, region, level, and other parameters.
    • Periodically expand search criteria if no opponent is found within a set time.
  2. If no opponent is found:

    • Notify the player about the delay and offer to wait or exit.
    • Automatically expand search parameters (e.g., increase allowable rating difference).
  3. Move validation:

    • The server should verify the correctness of each move according to game rules.
    • Discard incorrect or suspicious moves.
  4. Timer:

    • A timer is necessary to limit move time to prevent hangs.
    • When time expires, the move is considered skipped or a loss.
  5. Rating update:

    • Use algorithms like Elo, Glicko, or their modifications.
    • Update the rating after the game based on the result and rating difference.
  6. Game history:

    • Store the sequence of moves for analysis, repetitions, and dispute resolution.
    • Can be used for AI training or statistics.
  7. Disconnect:

    • Implement a timeout for reconnection.
    • If the player does not return, count as a loss or draw according to rules.
    • Possible substitution with a bot to continue the game.

Example of a simplified Go match search structure:

func findMatch(player Player, queue []Player) *Player {
    for _, opponent := range queue {
        if isCompatible(player, opponent) {
            return &opponent
        }
    }
    return nil
}

Where isCompatible checks search criteria (rating, region, etc.).