class CountingBotPlayer(DummyBotPlayer): """ Robot player that counts played cards. """ def __init__(self, name): DummyBotPlayer.__init__(self, name) self.cards_left = CardSet() def vote(self): """ Vote for rami or nolo. """ self.cards_left = CardSet.new_full_deck() - self.hand super(CountingBotPlayer, self).vote() def card_played(self, player, card, game_state): """ Signal that a card has been played by the given player. """ if player == self: return if game_state.state == GameState.VOTING: pass elif game_state.state == GameState.ONGOING: # print "removing %s from %s" %(card, self.cards_left) try: self.cards_left.remove(card) except ValueError: print "Oops: removing card %s failed" % card
def _start_new_hand(self): """ Start a new hand. """ logging.info('New hand') self.state.tricks = [0, 0] # create a full deck deck = CardSet.new_full_deck() logging.debug('deck is %s', str(deck)) deck.shuffle() logging.debug('shuffled deck %s', str(deck)) deck.deal([player.hand for player in self.players]) for player in self.players: player.hand.sort() logging.debug("%s's hand: %s", player.player_name, str(player.hand)) # voting self.state.mode = NOLO self.state.rami_chosen_by = None self._set_state(GameState.VOTING) # uncomment following to skip voting #self._set_state(GameState.ONGOING) # start the game self._next_in_turn(self.state.dealer + 1) self._signal_act()
def vote(self): """ Vote for rami or nolo. """ self.cards_left = CardSet.new_full_deck() - self.hand super(CountingBotPlayer, self).vote()
def __init__(self, name): DummyBotPlayer.__init__(self, name) self.cards_left = CardSet()