Skip to content

Commit

Permalink
Fix bad load balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
freyacodes committed Dec 18, 2023
1 parent 7cfe7ab commit 2d14959
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ docs/

.idea/artifacts
!**/build/generated/
core/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ public class LoadBalancer(
playerPenalty = stats.playingPlayers

cpuPenalty = 1.05.pow(100 * stats.cpu.systemLoad).toInt() * 10 - 10
if ((stats.frameStats != null) && stats.frameStats?.deficit != 1) {
val frameStats = stats.frameStats
if (frameStats != null) {
val frameDeficit = frameStats.deficit.coerceAtLeast(0).toFloat()
val frameNulls = frameStats.nulled.coerceAtLeast(0).toFloat()

deficitFramePenalty =
(1.03.pow(((500f * (stats.frameStats?.deficit?.toFloat() ?: (0 / 3000f)))).toDouble()) * 600 - 600).toInt()
(1.03.pow(
((500f * frameDeficit / 3000f)).toDouble()
) * 600 - 600).toInt()
nullFramePenalty =
(1.03.pow(((500f * (stats.frameStats?.nulled?.toFloat() ?: (0 / 3000f)))).toDouble()) * 300 - 300).toInt() * 2
(1.03.pow(
((500f * frameNulls / 3000f)).toDouble()
) * 300 - 300).toInt() * 2
} else {
deficitFramePenalty = 0
nullFramePenalty = 0
Expand Down

0 comments on commit 2d14959

Please sign in to comment.