Skip to content

Commit

Permalink
Tweak sorting algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed Apr 10, 2015
1 parent d4c55a3 commit bbd62e8
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions server.py
Expand Up @@ -290,27 +290,39 @@ def sort(self):
def server_points(server):
points = 0

# 1 per client
# Only 1/16 per client with a guest or all-numeric name
for name in server["clients_list"]:
if name.startswith("Guest") or \
name.isdigit():
points += 1/16
else:
points += 1
# 1 per client, but only 1/8 per client with a guest
# or all-numeric name.
if "clients_list" in server:
for name in server["clients_list"]:
if name.startswith("Guest") or \
name.isdigit():
points += 1/8
else:
points += 1
else:
# Old server
points = server["clients"] / 4

# Penalize highly loaded servers to improve player distribution.
# Note: This doesn't just make more than 16 players stop
# increasing your points, it can actually reduce your points
# if you have guests/all-numerics.
if server["clients"] > 16:
points = server["clients"] - 16

This comment has been minimized.

Copy link
@est31

est31 Apr 10, 2015

Contributor

This should perhaps be points = 16 (It is realistic for just test to have > 32 players). Also, I dont see how it can reduce points.

This comment has been minimized.

Copy link
@ShadowNinja

ShadowNinja Apr 15, 2015

Author Member

Oops, this was supposed to be points -= server["clients"] - 16.


# 1/2 per month of age, limited to 2
points += min(2, server["game_time"] / (60*60*24*30) * (1/2))
# 1 per month of age, limited to 8
points += min(8, server["game_time"] / (60*60*24*30))

# 1/8 per average client, limited to 1
points += min(1, server["pop_v"] * (1/8))
# 1/2 per average client, limited to 4
points += min(4, server["pop_v"] / 2)

# -8 for unrealistic max_clients
if server["clients_max"] >= 128:
points -= 8

# -6 per second of ping
points -= server["ping"] * 6
# -8 per second of ping over 0.4s
if server["ping"] > 0.4:
points -= (server["ping"] - 0.4) * 8

# Up to -8 for less than an hour of uptime (penalty linearly decreasing)
HOUR_SECS = 60 * 60
Expand Down

1 comment on commit bbd62e8

@kilbith
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for inflict those penalties 👍 Although "just test" server is still enthroned on top of the list...

Please sign in to comment.