go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/matchmaker/pkg/sim/simulation_config.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package sim 9 10 import "time" 11 12 // SimulationConfig are parameters to the simulation. 13 type SimulationConfig struct { 14 SimulationLength time.Duration 15 TickInterval time.Duration 16 ServerCount int 17 GameTeamSize int 18 GameDuration time.Duration 19 20 PlayerCount int 21 PlayerActiveDuration time.Duration 22 PlayerNaturalRatingMedian float64 23 PlayerNaturalRatingStdDev float64 24 PlayerRatingHistoryLen int 25 PlayerMinimumRating int 26 } 27 28 func (sc SimulationConfig) SimulationLengthOrDefault() time.Duration { 29 if sc.SimulationLength > 0 { 30 return sc.SimulationLength 31 } 32 return 48 * time.Hour 33 } 34 35 func (sc SimulationConfig) TickIntervalOrDefault() time.Duration { 36 if sc.TickInterval > 0 { 37 return sc.TickInterval 38 } 39 return 5 * time.Second 40 } 41 42 func (sc SimulationConfig) ServerCountOrDefault() int { 43 if sc.ServerCount > 0 { 44 return sc.ServerCount 45 } 46 return 4096 47 } 48 49 func (sc SimulationConfig) GameTeamSizeOrDefault() int { 50 if sc.GameTeamSize > 0 { 51 return sc.GameTeamSize 52 } 53 return 6 54 } 55 56 func (sc SimulationConfig) GameDurationOrDefault() time.Duration { 57 if sc.GameDuration > 0 { 58 return sc.GameDuration 59 } 60 return 15 * time.Minute 61 } 62 63 func (sc SimulationConfig) PlayerActiveDurationOrDefault() time.Duration { 64 if sc.PlayerActiveDuration > 0 { 65 return sc.PlayerActiveDuration 66 } 67 return 2 * time.Hour 68 } 69 70 func (sc SimulationConfig) PlayerNaturalRatingMedianOrDefault() float64 { 71 if sc.PlayerNaturalRatingMedian > 0 { 72 return sc.PlayerNaturalRatingMedian 73 } 74 return 1000 75 } 76 77 func (sc SimulationConfig) PlayerNaturalRatingStdDevOrDefault() float64 { 78 if sc.PlayerNaturalRatingStdDev > 0 { 79 return sc.PlayerNaturalRatingStdDev 80 } 81 return 200 82 } 83 84 func (sc SimulationConfig) PlayerRatingHistoryLenOrDefault() int { 85 if sc.PlayerRatingHistoryLen > 0 { 86 return sc.PlayerRatingHistoryLen 87 } 88 return 15 89 } 90 91 func (sc SimulationConfig) PlayerMinimumRatingOrDefault() int { 92 if sc.PlayerMinimumRating > 0 { 93 return sc.PlayerMinimumRating 94 } 95 return 100 96 }