Documentation ¶
Index ¶
- type BalancedMatchmaker
- type Clock
- type ClusteredMatchmaker
- type Game
- type KeyProvider
- type Lookup
- type Matchmaker
- type MatchmakerConfig
- type MatchmakerGame
- type Player
- type PlayerLookup
- type Server
- type ServerLookup
- type SimpleMatchmaker
- type Simulation
- type SimulationConfig
- func (sc SimulationConfig) GameDurationOrDefault() time.Duration
- func (sc SimulationConfig) GameTeamSizeOrDefault() int
- func (sc SimulationConfig) PlayerActiveDurationOrDefault() time.Duration
- func (sc SimulationConfig) PlayerMinimumRatingOrDefault() int
- func (sc SimulationConfig) PlayerNaturalRatingMedianOrDefault() float64
- func (sc SimulationConfig) PlayerNaturalRatingStdDevOrDefault() float64
- func (sc SimulationConfig) PlayerRatingHistoryLenOrDefault() int
- func (sc SimulationConfig) ServerCountOrDefault() int
- func (sc SimulationConfig) SimulationLengthOrDefault() time.Duration
- func (sc SimulationConfig) TickIntervalOrDefault() time.Duration
- type SimulationResultState
- type SimulationResults
- type Tag
- type Team
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalancedMatchmaker ¶
type BalancedMatchmaker struct {
// contains filtered or unexported fields
}
BalancedMatchmaker will try to create "balanced" teams from the players currently in the queue according to average ratings.
func (*BalancedMatchmaker) FormGames ¶
func (bm *BalancedMatchmaker) FormGames(cfg MatchmakerConfig) (out []MatchmakerGame)
func (*BalancedMatchmaker) Init ¶
func (bm *BalancedMatchmaker) Init(r *rand.Rand)
func (*BalancedMatchmaker) Queue ¶
func (bm *BalancedMatchmaker) Queue(players ...*Player)
func (*BalancedMatchmaker) QueueLen ¶
func (bm *BalancedMatchmaker) QueueLen() int
type ClusteredMatchmaker ¶
type ClusteredMatchmaker struct {
// contains filtered or unexported fields
}
BalancedMatchmaker will try to create "balanced" teams from the players currently in the queue according to average ratings.
func (*ClusteredMatchmaker) FormGames ¶
func (cm *ClusteredMatchmaker) FormGames(cfg MatchmakerConfig) (out []MatchmakerGame)
func (*ClusteredMatchmaker) Init ¶
func (cm *ClusteredMatchmaker) Init(r *rand.Rand)
func (*ClusteredMatchmaker) Queue ¶
func (cm *ClusteredMatchmaker) Queue(players ...*Player)
func (*ClusteredMatchmaker) QueueLen ¶
func (cm *ClusteredMatchmaker) QueueLen() int
type Game ¶
type KeyProvider ¶
type KeyProvider[K comparable] interface { Key() K }
type Lookup ¶
type Lookup[K comparable, V KeyProvider[K]] map[K]V
Lookup is a helper for maps that constrains the elements to types that can report their own keys.
func NewLookup ¶
func NewLookup[K comparable, V KeyProvider[K]](values []V) Lookup[K, V]
NewLookup returns a new lookup from a given array of elements..
type Matchmaker ¶
type Matchmaker interface { Init(r *rand.Rand) Queue(...*Player) QueueLen() int FormGames(MatchmakerConfig) []MatchmakerGame }
type MatchmakerConfig ¶
type MatchmakerGame ¶
type Player ¶
type Player struct { ID uuid.UUID IdleAt time.Time QueuedAt time.Time TimedOutAt time.Time Rating int NaturalSkill int Games int Wins int QueuedElapsed []time.Duration Recent *c9s.Queue[*Game] }
func (Player) QueuedElapsedStats ¶
func (Player) WinrateRecent ¶
type PlayerLookup ¶
Player is an alias to lookup for player.
type ServerLookup ¶
ServerLookup is an alias to lookup for server.
type SimpleMatchmaker ¶
type SimpleMatchmaker struct {
// contains filtered or unexported fields
}
SimpleMatchmaker randomly assigns players once there are enough players to fill both teams.
This can be used as a "control" for how effective more sophisticated mm algorithms might work.
func (*SimpleMatchmaker) FormGames ¶
func (sm *SimpleMatchmaker) FormGames(cfg MatchmakerConfig) (out []MatchmakerGame)
func (*SimpleMatchmaker) Init ¶
func (sm *SimpleMatchmaker) Init(_ *rand.Rand)
func (*SimpleMatchmaker) Queue ¶
func (sm *SimpleMatchmaker) Queue(players ...*Player)
func (*SimpleMatchmaker) QueueLen ¶
func (sm *SimpleMatchmaker) QueueLen() int
type Simulation ¶
type Simulation struct { // Config holds configuration options that will // be satisfied by defaults if they're not set. Config SimulationConfig // Clock is the source of time for the simulation. // // If it's not set, it will be assigned a default. Clock Clock Matchmaker Matchmaker RandSource rand.Source // contains filtered or unexported fields }
func (*Simulation) Init ¶
func (s *Simulation) Init()
Init sets up internal data stores and resolves dependencies.
You must call `Init` before you call `Simulate`.
func (*Simulation) Simulate ¶
func (s *Simulation) Simulate() SimulationResults
Simulate runs the simulation and returns results.
type SimulationConfig ¶
type SimulationConfig struct { SimulationLength time.Duration TickInterval time.Duration ServerCount int GameTeamSize int GameDuration time.Duration PlayerCount int PlayerActiveDuration time.Duration PlayerNaturalRatingMedian float64 PlayerNaturalRatingStdDev float64 PlayerRatingHistoryLen int PlayerMinimumRating int }
SimulationConfig are parameters to the simulation.
func (SimulationConfig) GameDurationOrDefault ¶
func (sc SimulationConfig) GameDurationOrDefault() time.Duration
func (SimulationConfig) GameTeamSizeOrDefault ¶
func (sc SimulationConfig) GameTeamSizeOrDefault() int
func (SimulationConfig) PlayerActiveDurationOrDefault ¶
func (sc SimulationConfig) PlayerActiveDurationOrDefault() time.Duration
func (SimulationConfig) PlayerMinimumRatingOrDefault ¶
func (sc SimulationConfig) PlayerMinimumRatingOrDefault() int
func (SimulationConfig) PlayerNaturalRatingMedianOrDefault ¶
func (sc SimulationConfig) PlayerNaturalRatingMedianOrDefault() float64
func (SimulationConfig) PlayerNaturalRatingStdDevOrDefault ¶
func (sc SimulationConfig) PlayerNaturalRatingStdDevOrDefault() float64
func (SimulationConfig) PlayerRatingHistoryLenOrDefault ¶
func (sc SimulationConfig) PlayerRatingHistoryLenOrDefault() int
func (SimulationConfig) ServerCountOrDefault ¶
func (sc SimulationConfig) ServerCountOrDefault() int
func (SimulationConfig) SimulationLengthOrDefault ¶
func (sc SimulationConfig) SimulationLengthOrDefault() time.Duration
func (SimulationConfig) TickIntervalOrDefault ¶
func (sc SimulationConfig) TickIntervalOrDefault() time.Duration
type SimulationResultState ¶
type SimulationResultState struct {
// contains filtered or unexported fields
}
SimulationResultState holds mutable simulation result state that will be used for computing final results at the end of the simulation.
type SimulationResults ¶
type SimulationResults struct { GamesPlayed int GamesLobsided int GamesTied int QueueTimeMean time.Duration QueueTimeP95 time.Duration WinrateP20 float64 WinrateMean float64 WinrateP80 float64 PlayerNaturalSkillToRatingCorrelation float64 Players []*Player PlayerTop10 []*Player PlayerBottom10 []*Player PlayerCountsByRank []Tag }