本文整理汇总了Python中Helper.evaluate_player_swap方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.evaluate_player_swap方法的具体用法?Python Helper.evaluate_player_swap怎么用?Python Helper.evaluate_player_swap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper
的用法示例。
在下文中一共展示了Helper.evaluate_player_swap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pickup
# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import evaluate_player_swap [as 别名]
def pickup(state):
"""
Recommends players to pick up to win the match of the week
:param state: current state of variables
:return: prints the best pick up for the week
"""
# Initialize variables
if state.opponent is None:
while 1:
state.opponent = raw_input("Who are you playing this week?: ")
if state.opponent not in state.teams:
print "Please enter a valid opponent name\n"
else:
break
taken_players = []
for users in state.teams:
state.teams[users] = Helper.lowercase(state.teams[users])
taken_players += state.teams[users]
players_on_team = Helper.lowercase(state.teams[state.current_user])
swap_dictionary = defaultdict(lambda: defaultdict(int))
# Constructs a list of players from best to worst
ranked_players = Helper.sort_dictionary(state.cumulative_player_statistics[state.iteration])
ranked_players = [ranked_players[x][0] for x in range(len(ranked_players))]
for n in range(len(ranked_players)):
# Removes players already on the team
if ranked_players[n] in players_on_team:
players_on_team.pop(players_on_team.index(ranked_players[n]))
# Prints other players
if ranked_players[n] not in taken_players and len(players_on_team) != 0:
# Determines the best player to drop and add
for player in players_on_team:
new_change = sum(Helper.evaluate_player_swap(copy.deepcopy(state.teams),
player, ranked_players[n],
state.normalized_player_statistics[state.iteration],
state, state.opponent)[0].values())
swap_dictionary[player][ranked_players[n]] = new_change
return swap_dictionary
示例2: waiver
# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import evaluate_player_swap [as 别名]
def waiver(state):
"""
Recommends players to pick up off the waiver
:param state: current state of variables
:return:
"""
# Initialize variables
swap_dictionary = defaultdict(lambda: defaultdict(int))
players = state.cumulative_player_statistics[state.iteration].keys()
team_stat = Helper.evaluate_teams(copy.deepcopy(state.teams), state.normalized_player_statistics[state.iteration], state)
print team_stat
"""
for player in players:
# Only iterates through players on waiver wire
# TODO: Replace with SQL query
if player not in state.taken_players and player not in state.players_on_team:
# Loops over all players on team
for other_player in state.players_on_team:
change_stat = copy.deepcopy(team_stat)
"""
# """
for player in players:
# Prints other players
if player not in state.taken_players and player not in state.players_on_team:
# Determines the best player to drop and add
for other_player in state.players_on_team:
new_change = sum(Helper.evaluate_player_swap(copy.deepcopy(state.teams), other_player, player,
state.normalized_player_statistics[state.iteration],
state)[0].values())
swap_dictionary[other_player][player] = new_change
# """
return swap_dictionary
示例3: swap
# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import evaluate_player_swap [as 别名]
def swap(state):
"""
Shows the change in statistics if a player is swapped from your team
:param state: current state of variables
:return: prints statistic changes
"""
# Initialize variables
for user in state.teams:
state.teams[user] = Helper.lowercase(state.teams[user])
state.teams_storage = copy.deepcopy(state.teams)
if state.player_to_obtain is None and state.player_to_trade is None:
state.update_player_to_trade(raw_input("Enter the player you want to remove from your team: ").lower())
state.update_player_to_obtain(raw_input("Enter the player you want to add to your team: ").lower())
print ""
# If the input is valid, analyze statistic changes
if state.player_to_trade in state.cumulative_player_statistics[state.iteration] \
and state.player_to_trade in state.teams[state.current_user] \
and state.player_to_obtain in state.cumulative_player_statistics[state.iteration] \
and state.player_to_obtain not in state.teams[state.current_user]:
state.teams = copy.deepcopy(state.teams_storage)
return Helper.evaluate_player_swap(state.teams, state.player_to_trade, state.player_to_obtain,
state.normalized_player_statistics[state.iteration], state)
# Notifies user if player is not in their team
elif state.player_to_trade not in state.teams[state.current_user]:
print state.player_to_trade.title(), "is not on your team"
elif state.player_to_obtain in state.teams["Chris S"]:
print state.player_to_obtain.title(), "is already on your team"
# Suggests player names if input is incorrect
elif state.player_to_trade not in state.cumulative_player_statistics[state.iteration]:
Helper.check_incorrect_input(state.player_to_trade, state.normalized_player_statistics[state.iteration].keys())
else:
Helper.check_incorrect_input(state.player_to_obtain, state.normalized_player_statistics[state.iteration].keys())