def init_game(self): ''' Initialize players and state Returns: (tuple): Tuple containing: (dict): The first state in one game (int): Current player's id ''' # Initalize payoffs self.payoffs = [0 for _ in range(self.num_players)] # Initialize a dealer that can deal cards self.dealer = Dealer() # Initialize four players to play the game self.players = [Player(i) for i in range(self.num_players)] # Deal 7 cards to each player to prepare for the game for player in self.players: self.dealer.deal_cards(player, 7) # Initialize a Round self.round = Round(self.dealer, self.num_players) # flip and perfrom top card top_card = self.round.flip_top_card() self.round.perform_top_card(self.players, top_card) # Save the hisory for stepping back to the last state. self.history = [] player_id = self.round.current_player state = self.get_state(player_id) return state, player_id
def init_game(self): # Initialize a dealer that can deal cards self.dealer = Dealer() # Initialize four players to play the game self.players = [Player(i) for i in range(self.num_players)] # Deal 7 cards to each player to prepare for the game for player in self.players: # print(player.get_player_id(), end=':') self.dealer.deal_cards(player, 7) # for card in player.hand: # print(card.get_str(), end=',') # Initialize a Round self.round = Round(self.dealer, self.num_players) # flip and perfrom top card top_card = self.round.flip_top_card() # print test print('top: ', top_card.get_str()) self.round.perform_top_card(self.players, top_card) for player in self.players: player.print_hand() print(len(self.dealer.deck)) # ## self.played_cards = []
def test_player_get_player_id(self): player = Player(0, np.random.RandomState()) self.assertEqual(0, player.get_player_id())
def test_player_get_player_id(self): player = Player(0) self.assertEqual(0, player.get_player_id())