diff --git a/source/tools/XpartaMuPP/ELO.py b/source/tools/XpartaMuPP/ELO.py index da46de0811..aa71e1ece4 100644 --- a/source/tools/XpartaMuPP/ELO.py +++ b/source/tools/XpartaMuPP/ELO.py @@ -1,5 +1,32 @@ -from config import elo_sure_win_difference, elo_k_factor_constant_rating +"""Copyright (C) 2013 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . +""" +############ Constants ############ +# Difference between two ratings such that it is +# regarded as a "sure win" for the higher player. +# No points are gained or lost for such a game. +elo_sure_win_difference = 600 + +# Lower ratings "move faster" and change more +# dramatically than higher ones. Anything rating above +# this value moves at the same rate as this value. +elo_k_factor_constant_rating = 2200 + +############ Functions ############ def get_rating_adjustment(rating, opponent_rating, games_played, opponent_games_played, result): """ Calculates the rating adjustment after a 1v1 game finishes using simplified ELO. diff --git a/source/tools/XpartaMuPP/LobbyRanking.py b/source/tools/XpartaMuPP/LobbyRanking.py index 5bf8d11fb8..b0f2306961 100644 --- a/source/tools/XpartaMuPP/LobbyRanking.py +++ b/source/tools/XpartaMuPP/LobbyRanking.py @@ -1,4 +1,21 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Copyright (C) 2013 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . +""" import sqlalchemy from sqlalchemy import Column, ForeignKey, Integer, String diff --git a/source/tools/XpartaMuPP/XpartaMuPP.py b/source/tools/XpartaMuPP/XpartaMuPP.py index b3a04702a5..6bb9bb5566 100644 --- a/source/tools/XpartaMuPP/XpartaMuPP.py +++ b/source/tools/XpartaMuPP/XpartaMuPP.py @@ -28,7 +28,9 @@ from sleekxmpp.xmlstream.matcher import StanzaPath from LobbyRanking import session as db, Game, Player, PlayerInfo from ELO import get_rating_adjustment -from config import default_rating, leaderboard_minimum_games, leaderboard_active_games +# Rating that new players should be inserted into the +# database with, before they've played any games. +leaderboard_default_rating = 1200 ## Class that contains and manages leaderboard data ## class LeaderboardList(): @@ -124,9 +126,9 @@ class LeaderboardList(): result = 1 if player1 == game.winner else -1 # Player's ratings are -1 unless they have played a rated game. if player1.rating == -1: - player1.rating == default_rating + player1.rating == leaderboard_default_rating if player2.rating == -1: - player2.rating == default_rating + player2.rating == leaderboard_default_rating rating_adjustment1 = int(get_rating_adjustment(player1.rating, player2.rating, len(player1.games), len(player2.games), result)) diff --git a/source/tools/XpartaMuPP/config.py b/source/tools/XpartaMuPP/config.py deleted file mode 100644 index 5e8147239c..0000000000 --- a/source/tools/XpartaMuPP/config.py +++ /dev/null @@ -1,22 +0,0 @@ -# Rating that new players should be inserted into the -# database with, before they've played any games. -default_rating = 1200 - -# Required minimum number of games to get on the -# leaderboard. -leaderboard_minimum_games = 10 - -# Required minimum number of games per month to -# qualify as an active player. -leaderboard_active_games = 5 - -# Difference between two ratings such that it is -# regarded as a "sure win" for the higher player. -# No points are gained or lost for such a game. -elo_sure_win_difference = 600 - -# Lower ratings "move faster" and change more -# dramatically than higher ones. Anything rating above -# this value moves at the same rate as this value. -elo_k_factor_constant_rating = 2200 -