Skip to content

Commit bbd62e8

Browse files
committedApr 10, 2015
Tweak sorting algorithm
1 parent d4c55a3 commit bbd62e8

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed
 

Diff for: ‎server.py

+26-14
Original file line numberDiff line numberDiff line change
@@ -290,27 +290,39 @@ def sort(self):
290290
def server_points(server):
291291
points = 0
292292

293-
# 1 per client
294-
# Only 1/16 per client with a guest or all-numeric name
295-
for name in server["clients_list"]:
296-
if name.startswith("Guest") or \
297-
name.isdigit():
298-
points += 1/16
299-
else:
300-
points += 1
293+
# 1 per client, but only 1/8 per client with a guest
294+
# or all-numeric name.
295+
if "clients_list" in server:
296+
for name in server["clients_list"]:
297+
if name.startswith("Guest") or \
298+
name.isdigit():
299+
points += 1/8
300+
else:
301+
points += 1
302+
else:
303+
# Old server
304+
points = server["clients"] / 4
305+
306+
# Penalize highly loaded servers to improve player distribution.
307+
# Note: This doesn't just make more than 16 players stop
308+
# increasing your points, it can actually reduce your points
309+
# if you have guests/all-numerics.
310+
if server["clients"] > 16:
311+
points = server["clients"] - 16
301312

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

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

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

312-
# -6 per second of ping
313-
points -= server["ping"] * 6
323+
# -8 per second of ping over 0.4s
324+
if server["ping"] > 0.4:
325+
points -= (server["ping"] - 0.4) * 8
314326

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

0 commit comments

Comments
 (0)