本文整理汇总了Python中server.games.game.Game.compute_rating方法的典型用法代码示例。如果您正苦于以下问题:Python Game.compute_rating方法的具体用法?Python Game.compute_rating怎么用?Python Game.compute_rating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.games.game.Game
的用法示例。
在下文中一共展示了Game.compute_rating方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_compute_rating_computes_ladder_ratings
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import compute_rating [as 别名]
async def test_compute_rating_computes_ladder_ratings(game: Game, players):
await game.clear_data()
game.state = GameState.LOBBY
players.hosting.ladder_rating = Rating(1500, 250)
players.joining.ladder_rating = Rating(1500, 250)
add_connected_players(game, [players.hosting, players.joining])
await game.launch()
await game.add_result(players.hosting, 0, 'victory', 1)
await game.add_result(players.joining, 1, 'defeat', 0)
game.set_player_option(players.hosting.id, 'Team', 1)
game.set_player_option(players.joining.id, 'Team', 1)
groups = game.compute_rating(rating='ladder')
assert players.hosting in groups[0]
assert players.joining in groups[1]
示例2: test_compute_rating_balanced_teamgame
# 需要导入模块: from server.games.game import Game [as 别名]
# 或者: from server.games.game.Game import compute_rating [as 别名]
async def test_compute_rating_balanced_teamgame(game: Game, create_player):
await game.clear_data()
game.state = GameState.LOBBY
players = [
(create_player(**info), result, team) for info, result, team in [
(dict(login='Paula_Bean', id=1, global_rating=Rating(1500, 250.7)), 0, 1),
(dict(login='Some_Guy', id=2, global_rating=Rating(1700, 120.1)), 0, 1),
(dict(login='Some_Other_Guy', id=3, global_rating=Rating(1200, 72.02)), 0, 2),
(dict(login='That_Person', id=4, global_rating=Rating(1200, 72.02)), 0, 2),
]
]
add_connected_players(game, [player for player, _, _ in players])
for player, _, team in players:
game.set_player_option(player.id, 'Team', team)
game.set_player_option(player.id, 'Army', player.id - 1)
await game.launch()
for player, result, _ in players:
await game.add_result(player, player.id - 1, 'score', result)
result = game.compute_rating()
for team in result:
for player, new_rating in team.items():
assert player in game.players
assert new_rating != Rating(*player.global_rating)