Add proper licences to lobby bot files. Also remove extranious config file.

This was SVN commit r14434.
This commit is contained in:
JoshuaJB 2013-12-29 18:46:00 +00:00
parent 45cfdf47f1
commit d756e8d70e
4 changed files with 50 additions and 26 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
"""
############ 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.

View file

@ -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 <http://www.gnu.org/licenses/>.
"""
import sqlalchemy
from sqlalchemy import Column, ForeignKey, Integer, String

View file

@ -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))

View file

@ -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