예제 #1
0
def play_game(red_brain_fn=random_ai_brain_fn, blue_brain_fn=human_brain_fn,
              initial_red_hand_str=None, initial_blue_hand_str=None,
              verbose=True):
    game = GameStatus()
    red_player = Player(Color.red, brain_fn=red_brain_fn, hand_str=initial_red_hand_str)
    blue_player = Player(Color.blue, brain_fn=blue_brain_fn, hand_str=initial_blue_hand_str)

    while not game.is_over:
        red_card, blue_card = _get_played_cards(red_player, blue_player, game)
        result = resolve_fight(red_card, blue_card, game)
        if verbose:
            result_string = 'red {} vs. blue {} -> {}'
            print result_string.format(redify(red_card.name),
                                       blueify(blue_card.name),
                                       result.name)
            print game.score_summary

    # Game's over when while loop exits
    _notify_game_over(red_player, blue_player, game)

    if verbose:
        if game.winner:
            print game.winner.name.title(), 'wins!'
        else:
            print 'tie!'
        print  # extra newline for readability

    return game
예제 #2
0
def play_game(red_brain_fn=random_ai_brain_fn, blue_brain_fn=human_brain_fn):
    game = GameStatus()
    red_player = Player(Color.red, brain_fn=red_brain_fn)
    blue_player = Player(Color.blue, brain_fn=blue_brain_fn)

    while not game.is_over:
        red_card, blue_card = _get_played_cards(red_player, blue_player, game)
        resolve_fight(red_card, blue_card, game)
        print game.score_summary

    # Game's over when while loop exits
    if game.winner:
        print game.winner.name.title(), 'wins!'
    else:
        print 'tie!'
    print  # extra newline for readability

    return game