def get_reward(player, state_1, state_2, win_reward, winner=None):
    """
    Reward is calculated as follows:
        1. Score component: Change in net advantage between states
        2. Game Over component: If game is over, + win_reward if win and - win_reward if lose

    :param player: Player object for which to calculate reward
    :param state_1: Initial state
    :param state_2: Next state
    :param win_reward: Amount gained or loss for ultimately winning/losing the game
    :param winner: If None, game is not over. If not None, specifies the player object who won the entire game
    :return: Reward
    """
    player_index = state_2.game.players.index(player)
    state_2_score = state_2.scores_vector[player_index]
    state_1_score = state_1.scores_vector[player_index]
    score_component = state_2_score - state_1_score
    game_component = 0

    if winner is not None:
        if player == winner:
            game_component += win_reward
        else:  # Lose
            game_component -= win_reward

    return score_component + game_component