def human_game(player_names, perspective): perspective_hand = None players = [] for player_name in player_names: if player_name == perspective: perspective_hand = manual_hand() player_is_perspective = (player_name == perspective) players.append( HumanPlayer(name=player_name, reference_player=reference_player, known_hand=player_is_perspective, ai_before=player_is_perspective)) game = LandlordGame(players, kitty_callback=manual_kitty) first_player = get_first_player(game) game.force_current_position(first_player) game.force_hand(perspective_position(game, perspective), perspective_hand) while not game.is_round_over(): current_player = game.get_current_player() current_position = game.get_current_position() best_move, best_move_q = current_player.decide_best_move(game) print(current_player.get_name(), "(" + game.get_position_role_name(current_position) + ", " \ + str(len(game.get_hand(current_position))) + "):", best_move, '(' + str(best_move_q) + ')') # play with known hand if it matches perspective game.play_move(best_move, hand_known=current_player.get_name() == perspective) if type(game.get_last_played()) == KittyReveal: print(game.get_last_played()) if game.has_winners(): for winner in game.get_winners(): print('WINNERS:', game.get_ai_players()[winner].get_name())
def play_against_two(players, show_q=True): game = LandlordGame(players) while not game.is_round_over(): current_player = game.get_current_player() current_position = game.get_current_position() best_move, best_move_q = current_player.decide_best_move(game) if show_q: best_move_q_str = '(' + str(best_move_q) + ')' else: best_move_q_str = '' print(current_player.get_name(), "(" + game.get_position_role_name(current_position) + ", " \ + str(len(game.get_hand(current_position))) + "):", best_move, best_move_q_str) game.play_move(best_move) if type(game.get_last_played()) == KittyReveal: print(game.get_last_played()) if game.has_winners(): for winner in game.get_winners(): print('WINNERS:', game.get_ai_players()[winner].get_name())