コード例 #1
0
ファイル: test_ai_player.py プロジェクト: coconut750750/pokai
    def setup_method(self):
        hand = Hand(Card.strs_to_cards(TestAIPlayer.card_strs_lv2))
        self.test_ai_player_lv2 = AIPlayer(hand, 0, "")

        hand = Hand(Card.strs_to_cards(TestAIPlayer.card_strs_lv3))
        self.test_ai_player_lv3 = AIPlayer(hand, 0, "")

        self.game_state = GameState(17, 17)
        self.game_state_is_setup = False
コード例 #2
0
    def setup_method(self):
        hand_lv1 = Hand(Card.strs_to_cards(TestMC.card_strs_lv1))
        self.test_player_lv1 = Player(hand_lv1, 0, "")

        hand_lv2 = Hand(Card.strs_to_cards(TestMC.card_strs_lv2))
        self.test_player_lv2 = Player(hand_lv2, 0, "")

        hand_lv3 = Hand(Card.strs_to_cards(TestMC.card_strs_lv3))
        self.test_player_lv3 = Player(hand_lv3, 0, "")

        hand_lv4 = Hand(Card.strs_to_cards(TestMC.card_strs_lv4))
        self.test_player_lv4 = Player(hand_lv4, 0, "")

        self.game_state = GameState(17, 17)
コード例 #3
0
ファイル: ai_simulations.py プロジェクト: coconut750750/pokai
def setup_game(card_strs):
    hand = Hand(Card.strs_to_cards(card_strs))
    print("Starting hand:", hand)
    aiplayer = AIPlayer(hand, 0, "")
    player = Player(hand, 0, "")
    game_state = GameState(17, 17)
    return aiplayer, player, game_state
コード例 #4
0
    def generate_game_state(computer_card_strs, unrevealed_card_strs,
                            n_cards1):
        game_state = GameState(20, 17)
        game_state.unused_cards = Card.strs_to_cards(computer_card_strs +
                                                     unrevealed_card_strs)
        game_state.used_cards = game_tools.remove_from_deck(
            get_new_ordered_deck(), game_state.unused_cards)
        game_state.player_cards = [
            len(computer_card_strs), n_cards1,
            len(unrevealed_card_strs) - n_cards1
        ]
        computer_hand = Hand([])
        computer_hand.add_cards(card_strs=computer_card_strs)
        computer = Player(computer_hand, 0, "")

        return game_state, computer
コード例 #5
0
ファイル: main.py プロジェクト: coconut750750/pokai
def get_ai_hand():
    """constructs the hand for the computer based on player's cards"""
    deck = get_new_ordered_deck()
    taken = get_cards_from_file(player_1_file) +\
            get_cards_from_file(player_2_file)

    unused_deck = remove_from_deck(deck, taken)
    return Hand(unused_deck)
コード例 #6
0
def simulate_one_random_game(player, game_state, display):
    """
    Simulates 1 random game with:
    player -- the player object
    game_state -- game information
    display -- print out results if True

    Returns if hand wins the game
    """
    n_cards1 = game_state.get_player_num_cards((player.position + 1) % 3)
    deck = game_tools.get_new_shuffled_deck()
    deck = game_tools.remove_from_deck(deck, player.get_cards())
    deck = game_tools.remove_from_deck(deck, game_state.used_cards)

    player1 = Player(Hand(deck[0: n_cards1]), 1, "")
    player2 = Player(Hand(deck[n_cards1:]), 2, "")

    return simulate_one_game([player, player1, player2], game_state, display)
コード例 #7
0
ファイル: test_ai_player.py プロジェクト: coconut750750/pokai
 def generate_player_from_card_strs(card_strs):
     hand = Hand(Card.strs_to_cards(card_strs))
     return Player(hand, 0, "")