from __future__ import print_function
import random


def play_match(game, players, verbose=True):
    """Plays a match between the given players"""
    game = game.copy()
    if verbose:
        print(game)
    while not game.is_over():
        cur_player = players[game.cur_player]
        move = cur_player.choose_move(game.copy())
        game.make_move(move)
        if verbose:
            print(game)
    return game.outcomes()


def play_series(game, players, n_matches=100, verbose=True):
    """Plays a series of 'n_matches' matches between the given players"""
    stats = {'p1_wins': 0, 'p2_wins': 0, 'draws': 0}
    for n_match in range(n_matches):
        print('Match {}:'.format(n_match), end=' ')
        outcomes = play_match(game, players, verbose=False)
        if outcomes[0] == 'W':
            stats['p1_wins'] += 1
        elif outcomes[1] == 'W':
            stats['p2_wins'] += 1
        else:
            stats['draws'] += 1
        print(outcomes)
        game.reset()
    print(stats)


def default_util_func(game, player):
    if game.outcomes()[player] == 'W':
        return 1.0
    elif game.outcomes()[player] == 'L':
        return -1.0
    else:
        return 0.0

@@ -1054,148 +1054,104 @@
     
-if game.outcomes()%5Bplayer%5D == 'W':%0A        return 1.0%0A    elif game.outcomes()%5Bplayer%5D == 'L':%0A        return -1.0%0A    else:%0A        return 0.0
+player_outcome = game.outcomes()%5Bplayer%5D%0A    return %7B'W': 1.0, 'L': -1.0, 'D': 0.0%7D%5Bplayer_outcome%5D
 %0A

Refactor default_util_func