Django车型的ELO评分
django-elo-rating的Python项目详细描述
Django ELO评级
安装
python3 -m pip install --user --upgrade django_elo_rating
配置
在settings.py
中添加以下行
ELO_START_VALUE=1000ELO_FACTOR_K=30
用法
fromdjango_elo_ratingimportEloRatedclassPlayer(EloRated):passplayer_1=Player()player_2=Player()print(player_1.elo_rating)# 1000 or whatever you set as ELO_START_VALUEprint(player_2.elo_rating)# 1000 or whatever you set as ELO_START_VALUEprobability_player_1_wins=player_1.probability(player_2)print(probability_player_1_wins)# 0.5# If player_1 wins a game against player_2 # update player_1's elo rating like thisplayer_1.elo_rating=player_1.updated_elo(player_2,1)# and player_2's like this player_2.elo_rating=player_2.updated_elo(player_1,0)# If they played a drawplayer_1.elo_rating=player_1.updated_elo(player_2,0.5)player_2.elo_rating=player_2.updated_elo(player_1,0.5)